Domanda

Let's clarify this once and for all. I tried to Google this but it seems this information can't be found in one place.

When a file is created or removed, the holding directory mtime changes on Windows and Linux both. ctime also changes on Linux bot not on Windows because there ctime is create time.

If a file is reopened and written to, the holding directory does not change. However, both on Windows and Linux the file mtime changes, and on Linux the ctime changes too, on Windows the ctime is create time.

Is this correct? What caveats are there? Are there exceptions over, say Windows network shares? Or Samba?

Edit: those who have voted to close this as off-topic, please leave a comment on which site do you think this is on topic. There are tons of mtime/ctime questions on Stackoverflow and just because I didn't include PHP snippets that rely on this knowledge it doesn't mean there are none :/

È stato utile?

Soluzione

Think of it this way:

A directory is a file that holds pointers (or 'links') to files.

As of that:

  • Changing the content of a file will not affect the directory
    (unless the file is first deleted and then created again with the same name, as mentioned by Gabor Garami above)

  • Adding, Deleting or Renaming files will change the content of the directory-file
    which will cause its ctime/mtime to change as you have described, depending on the OS

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top