Options: noop verbose
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'
Source Code
# File fileutils.rb, line 1017 def touch(list, options = {}) fu_check_options options, OPT_TABLE['touch'] list = fu_list(list) created = 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
<code/>and<pre/>for code samples.