I'm trying to create a tree of files and directories using the net-sftp library.
I can get a recursive listing of files by using the .glob method and can determine if one of the results is a directory by using the .opendir method.
I've been able to create a hash that has files and another hash that has directories, but I'd like to be able to create a tree.
files = []
directories = []
sftp.dir.glob("/home/**/**") do |entry|
fullpath = "/home/" + entry.name
file = Hash.new
file[:path] = fullpath
sftp.opendir(fullpath) do |response|
unless response.ok?
files.push(file)
else
directories.push(file)
end
end
else
end
end
Is creating such a tree possible from the results that net-sftp returns?