lib/pdk/util/filesystem.rb in pdk-2.7.1 vs lib/pdk/util/filesystem.rb in pdk-3.0.0
- old
+ new
@@ -12,32 +12,33 @@
content = content.encode(universal_newline: true)
# Make sure all written files have a trailing newline.
content += "\n" unless content[-1] == "\n"
- File.open(path, 'wb') { |f| f.write(content) }
+ File.binwrite(path, content)
end
module_function :write_file
def read_file(file, nil_on_error: false, open_args: 'r')
File.read(file, open_args: Array(open_args))
- rescue => e
+ rescue StandardError => e
raise e unless nil_on_error
+
nil
end
module_function :read_file
- #:nocov:
+ # :nocov:
# These methods just wrap core Ruby functionality and
# can be ignored for code coverage
def directory?(*args)
File.directory?(*args)
end
module_function :directory?
- def mkdir_p(*args)
- FileUtils.mkdir_p(*args)
+ def mkdir_p(*args, **kwargs)
+ FileUtils.mkdir_p(*args, **kwargs)
end
module_function :mkdir_p
def file?(*args)
File.file?(*args)
@@ -72,32 +73,32 @@
def exist?(*args)
File.exist?(*args)
end
module_function :exist?
- def rm(*args)
- FileUtils.rm(*args)
+ def rm(*args, **kwargs)
+ FileUtils.rm(*args, **kwargs)
end
module_function :rm
- def rm_f(*args)
- FileUtils.rm_f(*args)
+ def rm_f(*args, **kwargs)
+ FileUtils.rm_f(*args, **kwargs)
end
module_function :rm_f
- def rm_rf(*args)
- FileUtils.rm_rf(*args)
+ def rm_rf(*args, **kwargs)
+ FileUtils.rm_rf(*args, **kwargs)
end
module_function :rm_rf
def remove_entry_secure(*args)
FileUtils.remove_entry_secure(*args)
end
module_function :remove_entry_secure
def zero?(*args)
- File.zero?(*args)
+ File.empty?(*args)
end
module_function :zero?
def stat(*args)
File.stat(*args)
@@ -107,17 +108,17 @@
def symlink?(*args)
File.symlink?(*args)
end
module_function :symlink?
- def cp(*args)
- FileUtils.cp(*args)
+ def cp(*args, **kwargs)
+ FileUtils.cp(*args, **kwargs)
end
module_function :cp
- def mv(*args)
- FileUtils.mv(*args)
+ def mv(*args, **kwargs)
+ FileUtils.mv(*args, **kwargs)
rescue Errno::ENOENT
# PDK-1169 - FileUtils.mv raises Errno::ENOENT when moving files inside
# VMWare shared folders on Windows. So we need to catch this
# case, check if the file exists to see if the exception is
# legit and "move" the file with cp & rm.
@@ -130,9 +131,9 @@
else
FileUtils.remove_entry(src, opts[:force])
end
end
module_function :mv
- #:nocov:
+ # :nocov:
end
end
end