touch(list, options = {})
private
Options: noop verbose mtime nocreate
Updates modification time (mtime) and access time (atime) of file(s) in
list. Files are created if they don’t exist.
FileUtils.touch 'timestamp'
FileUtils.touch Dir.glob('*.c'); system 'make'
Show source
def touch(list, options = {})
fu_check_options options, OPT_TABLE['touch']
list = fu_list(list)
nocreate = options[:nocreate]
t = options[:mtime]
if options[:verbose]
fu_output_message "touch #{nocreate ? '-c ' : ''}#{t ? t.strftime('-t %Y%m%d%H%M.%S ') : ''}#{list.join ' '}"
end
return if options[:noop]
list.each do |path|
created = nocreate
begin
File.utime(t, t, path)
rescue Errno::ENOENT
raise if created
File.open(path, 'a') {
;
}
created = true
retry if t
end
end
end