Harry Putnam wrote:

> david <[EMAIL PROTECTED]> writes:
> 
>>
>> you could take a look at the stat function provided by Perl to see if the
>> directory's last modified time or inode change time changed:
> 
> This is not what the OP asked.  But I wondered if one can determine
> if a file has been writen to or changed inside a directory by looking
> at a stat on the directory.

if i am not dreaming, OP asks for whether there is new files adding to the 
directory, not that if a file change inside a directory. yes, both mtime 
and inctime reflect that and stat report that as well if new files are 
added or delete. no, stat won't report that if a file only changes. that 
has very little to do with the parent directory.

> 
> File changes don't seem to be reflected in mtime, unless a new file
> is added or one taken away.  Ditto for atime and ctime.

correct. OP doesn't care about file change (again, if i am not dreaming). 
only additon and deletion from the directory.

> 
> So is stat not able to determine if a file has been written to by
> looking at the parent dir?

not sure what you mean but:

#--
#-- stat report mtime and inctime change in /tmp for the first touch but not 
#-- the second because it only touches it.
#--
rm -f /tmp/file
touch /tmp/file
touch /tmp/file

the various posters' comment on hooking is your best bet if your OS supports 
it. otherwise a combination of cache/compare/mtime is needed because:

touch /tmp/file
rm -f /tmp/file
touch /tmp/file
rm -f /tmp/file

fakes the cache/compare method by not seeing the file as they come-and-go. 
the tricky part is you have to do the checking really fast to make the 
algr. reliable. otherwise, the race condition thingy is going to get you.

david

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to