Reputation: 55
Assume a file is copied or moved to a directory by some other program. I want to get the time that this file was copied/moved to this folder. That is, I want the time that the file first appears in this directory.
Note that this file might exist before it was moved/copied or it might not.
This is not any of the time information that can be obtained by File::stat. Thanks.
Upvotes: 1
Views: 165
Reputation: 98398
If nothing else has happened in that directory, this will be the modification time of the directory.
Upvotes: 0
Reputation: 1
While it may not be the best way to do it,
but for the copying case, if you make a file handle $fh,
You can keep checking for file existence using -e $fh
As soon as you find that file exists, record that moments time.
You may find more interesting -X $fileHandle
stuff here.
Upvotes: 0
Reputation: 70732
You may find File::ChangeNotify
helpful which tracks file and directory changes. I would suggest looking at incron, which can track various events and changes of files in filesystems.
Upvotes: 1
Reputation: 86774
My guess is you want the time the file was closed after being first written. This may or may not be available, and will be OS-specific. Most OSes track file creation, last modification, and last read (or some subset of those). If none of those work for you you're out of luck unless you control the creation and writing of the file in your application code, in which case you can use whatever you like.
Upvotes: 0