The only post I can find regarding ‘touch’ sez this:
fn = ‘/usr/aDirectory/aFile’
oops, we don’t have File.touch
File.open(fn, “w”).close unless File.exist?(fn)
As it’s by Matz, I’l take it as authoritative we got no ‘File.touch’.
I don’t want to do the file open close trick. I need to set the time back
to a while ago, and changing the platform time is out of the question; I’m
running on a busy server.
I’l shell to the GNU ‘touch’, but if folks don’t have it they are screwed.
Are there more primitive things I can do to get in ‘touch’?
Changes the access and modification times on a number of files. The
times must be instances of class Time or integers representing the
number of seconds since epoch. Returns the number of files
processed. Not available on all platforms.
File.utime(0, 0, "testfile") #=> 1
File.mtime("testfile") #=> Wed Dec 31 18:00:00 CST 1969
File.utime(0, Time.now, "testfile") #=> 1
File.mtime("testfile") #=> Sun Mar 04 23:28:25 CST 2001
Are there more primitive things I can do to get in ‘touch’?
–
Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
“He realized the fastest way to change is to laugh at your own
folly – then you can let go and quickly move on.” (p. 70)
Ah, I get it. In the original example someone was using ‘touch’ to make a
zero-length file exist, which the above won’t do. Hence the quote “no
touch”. Thanks.
···
–
Phlip greencheese.org
– This machine last rebooted during the Second Millenium –