def file_hash_from_paths(local_paths)
local_paths.each_with_object({}) do |local_path, file_hash|
unless File.exist?(local_path)
raise ArgumentError, "#{local_path} does not exist."
end
basename = File.basename(local_path)
if File.directory?(local_path)
tar = create_dir_tar(local_path)
file_hash[basename] = {
content: tar.read,
permissions: filesystem_permissions(local_path)
}
tar.close
FileUtils.rm(tar.path)
else
file_hash[basename] = {
content: File.read(local_path, mode: 'rb'),
permissions: filesystem_permissions(local_path)
}
end
end
end