Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Last "real" modification date of file

Reply
Thread Tools

Last "real" modification date of file

 
 
Bart Van der Donck
Guest
Posts: n/a
 
      06-18-2008
Hello,

I am on FreeBSD.

my @stat = stat "file.txt";
print "Last modified: ";
print time()-$stat[9]." seconds ago";

Is there a way to find out when file.txt was last changed ?
I'm facing a situation when a file could legally be (re-)written with
the same content. Don't ask me how I got there

Thanks for any hints,

--
Bart
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      06-18-2008
Bart Van der Donck <(E-Mail Removed)> wrote:
>I am on FreeBSD.
>
>Is there a way to find out when file.txt was last changed ?
>I'm facing a situation when a file could legally be (re-)written with
>the same content. Don't ask me how I got there


That depends upon if the file system (not the OS!) supports such a
value.
And for legal matters also if there are any means to set that value
manually.

jue
 
Reply With Quote
 
 
 
 
Tony Curtis
Guest
Posts: n/a
 
      06-18-2008
Bart Van der Donck wrote:
> Hello,
>
> I am on FreeBSD.
>
> my @stat = stat "file.txt";
> print "Last modified: ";
> print time()-$stat[9]." seconds ago";
>
> Is there a way to find out when file.txt was last changed ?
> I'm facing a situation when a file could legally be (re-)written with
> the same content. Don't ask me how I got there


Ah, you actually want to see if the *contents* of the file have changed.
Completely different thing (the file is a container for its content;
stat() just reports on the container). You'll need some kind of
meta-information, e.g. md5 hash, to match against.

hth
t
 
Reply With Quote
 
Bart Van der Donck
Guest
Posts: n/a
 
      06-18-2008
Glenn Jackman wrote:

> At 2008-06-18 10:03AM, "Bart Van der Donck" wrote:
>
>> *Hello,

>
>> *I am on FreeBSD.

>
>> * *my @stat = stat "file.txt";
>> * *print "Last modified: ";
>> * *print time()-$stat[9]." seconds ago";

>
>> *Is there a way to find out when file.txt was last changed ?
>> *I'm facing a situation when a file could legally be (re-)written with
>> *the same content. Don't ask me how I got there

>
> You'd need to have a CRC or cksum value for the "old" and "new" file to
> check for changed content if the timestamp has changed.


Yes, it seems like there is no other choice than influencing the write
process itself. Backup file, write new content, compare two versions,
store some isModified-flag, delete backup-file.

Thanks to all for your insights.

--
Bart
 
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
File Modification Date Vance M. Allen Perl Misc 6 09-15-2005 06:28 AM
log4j doesn't set file modification date correctly Andy Fish Java 0 07-20-2004 10:20 AM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Action Based on File's Last Modification Time: Is One Approach Better? James E Keenan Perl Misc 1 10-14-2003 02:24 AM
Get the date of last modification of a file Manuel Bastioni Python 6 09-09-2003 06:07 PM



Advertisments