lib/zold/dir_items.rb in zold-0.17.4 vs lib/zold/dir_items.rb in zold-0.17.5

- old
+ new

@@ -19,11 +19,10 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. require 'shellwords' -require 'posix/spawn' # Items in a directory. # # We need this class because Dir.new() from Ruby is blocking. It doesn't # allow to write and read to any files in a directory, while listing it. @@ -38,15 +37,10 @@ def initialize(dir) @dir = dir end def fetch(recursive: true) - spawn = POSIX::Spawn::Child.new( - 'find', - *([@dir, '-type', 'f', '-print'] + (recursive ? [] : ['-maxdepth', '1'])) - ) - raise spawn.err unless spawn.status.success? - spawn.out + `find #{([@dir, '-type', 'f', '-print'] + (recursive ? [] : ['-maxdepth', '1'])).join(' ')}` .strip .split(' ') .select { |f| f.start_with?(@dir) && f.length > @dir.length } .map { |f| f[(@dir.length + 1)..-1] } end