Forum: Ruby Help on copy file

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Newb N. (Guest)
on 2009-04-28 11:21
is it possible to copy a file which is newer than the existing one.
how can i check that?
Any Ideas.

Kyle S. (Guest)
on 2009-04-29 19:02
(Received via mailing list)
Go read about the file class in ruby.  FileUtils may give you a few
more options, but for this you don't actually need it.

Use the stat method of an open file to get information about when it
was created, modified accessed, etc.

Here, I am getting the data on my file named "HP Laptop" where I've
got the chat log from the 6th time I had to send the damned thing back
to HP."HP Laptop")
=><File::Stat dev=0x802, ino=2680032, mode=0100644, nlink=1, uid=1000,
gid=1000, rdev=0x0, size=123838, blksize=4096, blocks=256, atime=Tue
Apr 28 11:18:19 -0500 2009, mtime=Fri Apr 24 13:49:05 -0500 2009,
ctime=Fri Apr 24 13:49:05 -0500 2009>
=>Fri Apr 24 13:49:05 -0500 2009
=>Fri Apr 24 13:49:05 -0500 2009
=> Tue Apr 28 11:18:19 -0500 2009

You can see I created the file on April 24th, and haven't modified it
since.  You also see it was last accessed on April 28th.

Now go dig into the File class, it has a move command, a copy command,
and all sorts of goodies that will help you do this for yourself, and
learn along the way.

Kyle S. (Guest)
on 2009-04-29 19:03
(Received via mailing list)
Right, one more thing :)
ctime  is create time
mtime is modify time
atime is access time
This topic is locked and can not be replied to.