I'm working with ruby 2.0 on windows 7 (unfortunately I have to) and have issue with this code:
FileUtils.touch(file)
This code is needed to update file.ctime (which probably will have problems too) So, when files is processed I 'touch' them and not processing them in next iteration.
How can I deal with it error?
ruby_path/fileutils.rb:1137:in 'utime': Permission denied 'path_to_file' Errno::EACCES
'block in touch'
'each'
'touch'
example:
file = File.new('file_path')
FileUtils.mkdir_p(path)
FileUtils.cp(file.path, path)
FileUtils.touch(file)
I tested with ruby 1.9 and 2.0.
FileUtils.touch
works without problems.Can you provide a MWE. Did you check the permissions on the file you want to check.
Especially: Are you sure, you don't touch a directory?
If you don't want to check for directories, you may extend FileUtils by
FileUtils.save_touch
:After update of question:
FileUtils.touch
has one parameter: a file name or path to a file.You have to adapt your example: