Help on copy file

N

Newb Newb

Hi..
is it possible to copy a file which is newer than the existing one.
how can i check that?
Any Ideas.

Thanks
 
K

Kyle Schmitt

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.

file=File.open("HP Laptop")
file.stat
=><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>
file.stat.ctime
=>Fri Apr 24 13:49:05 -0500 2009
file.stat.mtime
=>Fri Apr 24 13:49:05 -0500 2009
file.stat.atime
=> 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
 
K

Kyle Schmitt

Right, one more thing :)
ctime is create time
mtime is modify time
atime is access time
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,170
Latest member
Andrew1609
Top