Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > How do I get the creation date of a file?

Reply
Thread Tools

How do I get the creation date of a file?

 
 
ara.t.howard@noaa.gov
Guest
Posts: n/a
 
      08-16-2006
On Thu, 17 Aug 2006, Chad Perrin wrote:

> That is, effectively, creation time (for a particular definition of file
> creation). It returns the time at which the file's listing in the
> information for the enclosing directory changed, which basically means when
> it was created within that directory. Same difference. I do think the
> letter C stands for "change" in this case, though, not only in Ruby docs,
> but in POSIX standards as well.


man 2 stat

...
The field st_ctime is changed by writing or by setting inode informa-
tion (i.e., owner, group, link count, mode, etc.).
...


it's change time and this isn't even really close to creation time for __any__
definition since operations like chmod, chowner, chgrp or linking to the file
all effect this timestamp. for example

harp:~ > touch foobar

harp:~ > stat foobar
File: `foobar'
Size: 4096 Blocks: 8 IO Block: 4096 Directory
Device: 306h/774d Inode: 278848 Links: 2
Access: (0775/drwxrwxr-x) Uid: ( 447/ ahoward) Gid: ( 447/ ahoward)
Access: 2006-08-16 15:49:58.000000000 -0600
Modify: 2006-08-16 15:49:58.000000000 -0600
Change: 2006-08-16 15:49:58.000000000 -0600



harp:~ > ln -s foobar barfoo

harp:~ > stat foobar
File: `foobar'
Size: 4096 Blocks: 8 IO Block: 4096 Directory
Device: 306h/774d Inode: 278848 Links: 2
Access: (0775/drwxrwxr-x) Uid: ( 447/ ahoward) Gid: ( 447/ ahoward)
Access: 2006-08-16 15:49:58.000000000 -0600
Modify: 2006-08-16 15:50:20.000000000 -0600
Change: 2006-08-16 15:50:20.000000000 -0600


i can't even begin to tell you how many legacy perl scripts i've found with
this logic error in them - it's a really hard one to track down.

in any case it's a simple thing to read about so i'm not sure why it causes so
much confusion... there simply is no concept of file creation time in unix.

btw. my dirwatch directory event code works around this to a large degree for
certain situations.

regards.

-a
--
to foster inner awareness, introspection, and reasoning is more efficient than
meditation and prayer.
- h.h. the 14th dali lama

 
Reply With Quote
 
 
 
 
Justin Collins
Guest
Posts: n/a
 
      08-16-2006


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> On Thu, 17 Aug 2006, Chad Perrin wrote:
>
>> That is, effectively, creation time (for a particular definition of file
>> creation). It returns the time at which the file's listing in the
>> information for the enclosing directory changed, which basically
>> means when
>> it was created within that directory. Same difference. I do think the
>> letter C stands for "change" in this case, though, not only in Ruby
>> docs,
>> but in POSIX standards as well.

>
> man 2 stat
>
> ...
> The field st_ctime is changed by writing or by setting inode
> informa-
> tion (i.e., owner, group, link count, mode, etc.).
> ...
>
>
> it's change time and this isn't even really close to creation time for
> __any__
> definition since operations like chmod, chowner, chgrp or linking to
> the file
> all effect this timestamp. for example
> <snip>


Not to mention, on my Linux machine, just opening up a file and saving
it changes all the times (access, modify, and change) to the same time.
I'm sure that varies by OS, though.

-Justin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to (batch) set EXIF date taken and IPTC creation date and creation time for photos with filenames YYMMDDHHMMSS#.jpg? guercheLE@gmail.com Digital Photography 1 10-04-2005 07:15 PM
copy EXIF date to IPTC creation date Israel Hsu Digital Photography 0 08-04-2005 08:04 AM
javascript to get the creation date and time of the file sent and display it in the html page ? Fabrizio Javascript 2 10-05-2004 08:52 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM



Advertisments