Sha256: e1d52d8216ecd831ed892757bcaabaf9dd1036a8f94364cc105e607f29d71979

Contents?: true

Size: 1.93 KB

Versions: 42

Compression:

Stored size: 1.93 KB

Contents

module Redcar
  class Project
    module Adapters
      class Local
        def touch(new_file_path)
          FileUtils.touch(new_file_path)
        end

        def mkdir(new_dir_path)
          FileUtils.mkdir(new_dir_path)
        end

        def mv(path, new_path)
          FileUtils.mv(path, new_path)
          new_path = File.join(new_path, File.basename(path)) unless File.file?(new_path)
          Manager.update_tab_for_path(path,new_path)
        end

        def file?(path)
          File.file?(path)
        end

        def directory?(path)
          # JRuby's File.directory? seems to have a problem with multi-byte strings
          f = java.io.File.new(path.to_java)
          f.directory?
        end

        def empty_directory?(path)
          Dir.glob("#{path}/*", File::FNM_DOTMATCH).length <= 2
        end

        def fetch_contents(path, force=false)
          Dir.glob("#{path}/*", File::FNM_DOTMATCH).map do |fn|
            is_dir = directory?(fn)
            hash = {
              :fullname => fn,
              :type => (is_dir ? :dir : :file),
            }
            if is_dir
              hash[:empty] = empty_directory?(fn)
            end
            hash
          end
        end

        def load(file)
          File.open(file, 'rb') do |f|; f.read; end
        end

        def save(file, contents)
          File.open(file, "wb") {|f| f.print contents }
        end

        def mtime(file)
          File.mtime(file)
        end

        def exists?(file)
          File.exists?(file)
        end

        def delete(file)
          FileUtils.rm_rf(file) unless Trash.recycle(file)
          Manager.update_tab_for_path(file)
        end

        def load_contents(file)
          File.open(file, 'rb') do |f|; f.read; end
        end

        def save_contents(file)
          File.open(file, "wb") {|f| f.print contents }
        end

        def refresh_operation(tree)
          yield
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
redcar-dev-0.13.5dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.13.4dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.13.3dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.13.2dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.13.1dev plugins/project/lib/project/adapters/local.rb
redcar-0.12.1 plugins/project/lib/project/adapters/local.rb
redcar-dev-0.13.0dev plugins/project/lib/project/adapters/local.rb
redcar-0.12 plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.27dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.26dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.25dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.24dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.23dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.22dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.21dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.20dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.19dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.18dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.17dev plugins/project/lib/project/adapters/local.rb
redcar-dev-0.12.16dev-java plugins/project/lib/project/adapters/local.rb