lib/vfs/drivers/local.rb in vfs-0.4.8 vs lib/vfs/drivers/local.rb in vfs-0.5.0

- old
+ new

@@ -28,13 +28,12 @@ attr_writer :buffer def buffer @buffer || DEFAULT_BUFFER end - # - # Attributes - # + # Attributes. + def attributes path path = with_root path stat = ::File.stat path attrs = {} @@ -51,18 +50,16 @@ rescue Errno::ENOENT nil end def set_attributes path, attrs - # TODO2 set attributes + # TODO2 set attributes. not_implemented end + # File. - # - # File - # def read_file path, &block path = with_root path ::File.open path, 'r' do |is| while buff = is.gets(self.buffer || DEFAULT_BUFFER) block.call buff @@ -86,14 +83,11 @@ # def move_file from, to # FileUtils.mv from, to # end - - # - # Dir - # + # Dir. def create_dir path path = with_root path ::Dir.mkdir path end @@ -108,25 +102,15 @@ if query path_with_trailing_slash = path == '/' ? path : "#{path}/" ::Dir["#{path_with_trailing_slash}#{query}"].each do |absolute_path| name = absolute_path.sub path_with_trailing_slash, '' block.call name, ->{::File.directory?(absolute_path) ? :dir : :file} - # if ::File.directory? absolute_path - # block.call relative_path, :dir - # else - # block.call relative_path, :file - # end end else ::Dir.foreach path do |name| next if name == '.' or name == '..' block.call name, ->{::File.directory?("#{path}/#{name}") ? :dir : :file} - # if ::File.directory? "#{path}/#{relative_name}" - # block.call relative_name, :dir - # else - # block.call relative_name, :file - # end end end end # def efficient_dir_copy from, to, override @@ -142,17 +126,15 @@ # end # end # end # end - # - # Other - # + # Other. + def local?; true end def tmp &block path = "/tmp/#{rand(10**6)}" - # tmp_dir = "#{::Dir.tmpdir}/#{rand(10**6)}" if block begin ::FileUtils.mkdir_p with_root(path) block.call path ensure \ No newline at end of file