You are not logged in.

#1 2009-11-26 12:52:38

saurav
Member
Registered: 2009-09-19
Posts: 5

File creation date

Hi,

How can we get the date (and optionally the time) on which a particular file or directory was created? If there's no user command for this, is there any programming language function? I got the last access, attribute change, and content modification dates, but not the creation date.

Thanks

Offline

#2 2009-11-26 13:21:09

quarkup
Member
From: Portugal
Registered: 2008-09-07
Posts: 497
Website

Re: File creation date

why don't you just use the 'ls' binary ?
use the flag '-l'

ls -l

it will tell you more info.
check the manpages for even more details on 'ls'


you could execute that binary in your executable then parse/analyse it's output.
or maybe use filesystem libs or something which im not familliar with..


If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.

Offline

#3 2009-11-26 13:22:34

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: File creation date

The stat command should be able to tell you that

$ man stat

Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#4 2009-11-26 14:08:53

foutrelis
Developer
From: Athens, Greece
Registered: 2008-07-28
Posts: 705
Website

Re: File creation date

I'm somewhat certain that the file creation time is not recorded. You might be able to infer it from the timestamps you mentioned (there is also a pretty good explanation of those here):

- If the file hasn't been modified since shortly after its creation, look at mtime.
- If you mount the partition with noatime, look at atime.

Same applies to directories, with slightly different semantics.

Last edited by foutrelis (2009-11-26 14:10:53)

Offline

#5 2009-11-27 06:55:43

saurav
Member
Registered: 2009-09-19
Posts: 5

Re: File creation date

Thanks for the replies. Unfortunately, neither ls nor stat give the creation time and I found the reason on Wikipedia and in a post by Theodore Tso referenced therein. I use ext4. However, while it does record creation time (ext3 does not), it is not yet possible to get to this in userspace because the necessary system calls and data structures (such as stat(2)) have not been updated.

Offline

Board footer

Powered by FluxBB