Sha256: 18666d70044841b32d70e4ca017c74d02752e1d28aaafd95c5864b2969605dd8

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

module ScopeFileAccessFlat
  def retrieve_files_from_system(system, paths)
    system.retrieve_files(paths, scope_file_store.path)
  end

  def write_file(system_file, target)
    raise Machinery::Errors::FileUtilsError, "Not a file" if !system_file.file?

    target_path = File.join(target, system_file.name)
    FileUtils.mkdir_p(File.dirname(target_path))
    FileUtils.cp(file_path(system_file), target_path)
  end

  def file_path(system_file)
    raise Machinery::Errors::FileUtilsError, "Not a file" if !system_file.file?

    File.join(scope_file_store.path, system_file.name)
  end

  def file_content(system_file)
    if !extracted
      raise Machinery::Errors::FileUtilsError, "The requested file '#{system_file.name}' is" \
        " not available because files for scope '#{scope_name}' were not extracted."
    end

    File.read(file_path(system_file))
  end

  def binary?(system_file)
    path = system_file.scope.file_path(system_file)
    return false if File.zero?(path)

    output = Cheetah.run("file", path, stdout: :capture)
    !output.include?("ASCII")
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
machinery-tool-1.13.0 lib/scope_file_access_flat.rb
machinery-tool-1.12.0 lib/scope_file_access_flat.rb
machinery-tool-1.11.2 lib/scope_file_access_flat.rb
machinery-tool-1.11.1 lib/scope_file_access_flat.rb
machinery-tool-1.11.0 lib/scope_file_access_flat.rb
machinery-tool-1.10.0 lib/scope_file_access_flat.rb