in reply to Re^2: How to get the File creation date
in thread How to get the File creation date

Different file systems have different ways of dealing with "creation time". Normal Unix file systems do not have a concept of creation vs modification time at all. You can only get "last modified" time. Windows NTFS does have the concept of: creation time, last accessed time, and last modification time. see (sic) ...

If I am reading your statement correctly, you are saying that the ctime, mtime, and atime do not exist under the historical unix file system inode. Is this correct?

So: some file systems track "creation time". Unix file systems are not one of them. Normally the "last modified" time is sufficient. And that's a good thing as that is all Perl allows you to get to with the standard built-in functions. But as a "nit" here, I point out that some filesystems do track creation time.

I can concur with that. Reference: "the ctime test may actually return the creation time". I would, however, ask what creation time signifies. What happens when a file is restored? Does the attribute follow on a copy? How about when the method of saving a file is "save new, rename old, rename new, remove old"?

I think that in the context we are discussing (OP's question), these concepts are for the most part equivalent.

Update:

Cleaned up my thoughts and wording

--MidLifeXis

  • Comment on Re^3: How to get the File creation date

Replies are listed 'Best First'.
Re^4: How to get the File creation date
by Marshall (Canon) on Aug 19, 2010 at 16:20 UTC
    The "modification time" and "last accessed time" work the same on Unix and Windows and these two times are normally sufficient for doing whatever is needed. I would suggest staying away from ctime because it is a bit different between Windows and Unix.

    I would, however, ask what creation time signifies. What happens when a file is restored? Does the attribute follow on a copy? How about when the method of saving a file is "save new, rename old, rename new, remove old"?

    Creation time would be the time when this file first "came into being". Basically that means it is a constant generated at file creation. It could be that there is some ancient Windows file that is many years old but which gets changed and accessed a lot! If you copy a file (or restore it), the creation time follows it. If you go through the sequence you asked about, file "new" will get a creation time of "right now" because it is literally a "brand new file". The more recent version of file "old" will wind up with that creation time of file "new" instead of whatever date the original file "old" had.

    The name in the directory is just a way for a human readable set of bits (the name) to be associated with some set of data bits on the disk. That look up in the directory is what happens when you do an "open file". Once you have opened a file, the name is irrelevant, the file handle is essentially a pointer to a structure that describes the file...how big it is, what physical disk block it starts on, and other attributes like modification time, etc. All that stuff exists independent of the "name".

    I hoped this helped rather than further confusing things.

      I am thinking that we both know what we (and each other) are talking about, but are just taking different approaches to explaining it :-). Heh.

      --MidLifeXis

        I agree with you! And I did like your explanation of Unix ctime and how that relates to an inode. I think we also agree that the criteria for file deletion should be: "has anybody been using this file recently?". That is a different question than when was this file created to begin with? In short, I think the OP is asking the wrong question, an XY problem.