On Sat, 01 Mar 2008 17:49:34 +0100
Erik <[EMAIL PROTECTED]> wrote:

> Matthias Guede skrev:
> > 2008/3/1, Erik <[EMAIL PROTECTED]>:
> >   
> >> Is it possible to set a property on a file and have it remove
> >>  automatically when the file is modified?
> >>
> >>  Suppose that we have a style checker that checks a lot of source
> >> code files. Once it examined a file and found it to be clean, it
> >> should set a property on the file ("style-clean"). Whenever the
> >> style checker is executed it skips files with this property.
> >> Whenever the file is modified, the filesystem removes the property.
> >>
> >>  Is this possible? Which filesystems does it work on?
> >>     
> >
> > One solution would be using 'make'.  With rules like the following
> > only modified files will
> > be proceeded:
> >
> > timestamp: myFile
> >           doSomthingWidth myFile
> >           touch timestamp
> >   
> 
> We have thought about that, but we would like to avoid having a
> parallel file hierarchy of timestamp files for our source tree.
> Therefore something like the archive attribute (suggested by Etanoi
> Shrdlu) would be better.


Actually, if there are no other concerns, you'd have to keep only one
file for reference. Then you could compare the modification times of all
other files with this reference file.

#!/bin/bash
# initial/full scan

touch timestamp.chk
find hierarchy | while read some_file
do
        [[ stylecheck("$some_file") -eq 0 ]] || touch "$some.file"
done

#EOF


After this every time you run stylecheck(), you'd have to check only
the files having newer time stamp than the one of "timestamp.chk".

#!/bin/bash
# incremental scan

find hierarchy -newer timestamp.chk > modified.list
touch timestamp.chk

while read some_file
do
        [[ stylecheck("$some_file") -eq 0 ]] || touch "$some.file"
done < modified.list
unlink modified.list

#EOF



-- 
Best regards,
Daniel
-- 
gentoo-user@lists.gentoo.org mailing list

Reply via email to