* [gentoo-user] Set a property on a file and have it remove when the file is modified?
@ 2008-03-01 12:40 Erik
2008-03-01 14:18 ` Florian Philipp
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Erik @ 2008-03-01 12:40 UTC (permalink / raw
To: gentoo-user
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?
--
gentoo-user@lists.gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] Set a property on a file and have it remove when the file is modified?
2008-03-01 12:40 [gentoo-user] Set a property on a file and have it remove when the file is modified? Erik
@ 2008-03-01 14:18 ` Florian Philipp
2008-03-01 15:40 ` Etaoin Shrdlu
2008-03-01 16:38 ` Matthias Guede
2 siblings, 0 replies; 7+ messages in thread
From: Florian Philipp @ 2008-03-01 14:18 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 977 bytes --]
On Sat, 2008-03-01 at 13:40 +0100, Erik wrote:
> 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?
Looks like you are looking for extended attributes:
http://en.wikipedia.org/wiki/Extended_attributes
But I don't think you can make them "disappear" by modifying a file.
Inotify might be a solution for that problem:
http://en.wikipedia.org/wiki/Inotify
Alternatively you could check the file modification times as stored by
default on every FS. You could use "find" for that or "ls --full-time".
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] Set a property on a file and have it remove when the file is modified?
2008-03-01 12:40 [gentoo-user] Set a property on a file and have it remove when the file is modified? Erik
2008-03-01 14:18 ` Florian Philipp
@ 2008-03-01 15:40 ` Etaoin Shrdlu
2008-03-01 16:38 ` Matthias Guede
2 siblings, 0 replies; 7+ messages in thread
From: Etaoin Shrdlu @ 2008-03-01 15:40 UTC (permalink / raw
To: gentoo-user
On Saturday 1 March 2008, Erik wrote:
> 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?
This is just an idea, and take it for what it is.
I seem to remember that on fat filesystems, files used to have
the "archive" attribute (along with the "hidden", "system", "readonly"
attributes), which (back in the DOS/Win9x days) was meant to inform
backup programs that the file was to be archived. The way it worked was
more or less like this: when a file was created or modified, the OS set
the "archive" flag for the file. The backup program, after backing up
the file, cleared the flag.
*If* linux implementations of the fat filesystem handle the "archive"
flag (ie, set it when a file is modified), it should be possible to
exploit this feature to your advantage.
Just have the syntax checker clear the flag for a file upon succesful
check, and have it run only on files with the flag set. When an
application modifies the file, the flag will automatically be set again
for that file (if it wasn't already, of course).
If the above is true, "mattrib" (from the mtools package) can be used to
manipulate fat attributes for a file.
--
gentoo-user@lists.gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] Set a property on a file and have it remove when the file is modified?
2008-03-01 12:40 [gentoo-user] Set a property on a file and have it remove when the file is modified? Erik
2008-03-01 14:18 ` Florian Philipp
2008-03-01 15:40 ` Etaoin Shrdlu
@ 2008-03-01 16:38 ` Matthias Guede
2008-03-01 16:49 ` Erik
2 siblings, 1 reply; 7+ messages in thread
From: Matthias Guede @ 2008-03-01 16:38 UTC (permalink / raw
To: gentoo-user
2008/3/1, Erik <esigra@gmail.com>:
> 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
--
gentoo-user@lists.gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] Set a property on a file and have it remove when the file is modified?
2008-03-01 16:38 ` Matthias Guede
@ 2008-03-01 16:49 ` Erik
2008-03-03 4:25 ` Daniel Iliev
0 siblings, 1 reply; 7+ messages in thread
From: Erik @ 2008-03-01 16:49 UTC (permalink / raw
To: gentoo-user
Matthias Guede skrev:
> 2008/3/1, Erik <esigra@gmail.com>:
>
>> 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.
--
gentoo-user@lists.gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] Set a property on a file and have it remove when the file is modified?
2008-03-01 16:49 ` Erik
@ 2008-03-03 4:25 ` Daniel Iliev
2008-03-03 13:12 ` Erik
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Iliev @ 2008-03-03 4:25 UTC (permalink / raw
To: gentoo-user
On Sat, 01 Mar 2008 17:49:34 +0100
Erik <esigra@gmail.com> wrote:
> Matthias Guede skrev:
> > 2008/3/1, Erik <esigra@gmail.com>:
> >
> >> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] Set a property on a file and have it remove when the file is modified?
2008-03-03 4:25 ` Daniel Iliev
@ 2008-03-03 13:12 ` Erik
0 siblings, 0 replies; 7+ messages in thread
From: Erik @ 2008-03-03 13:12 UTC (permalink / raw
To: gentoo-user
Daniel Iliev skrev:
> 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.
>
Good idea! I implemented it and it reduced the number of cache
files/directories in the tree from 633 to 26. The only drawback is that
if the script is interrupted whilst checking a sequence of files with
equal mtime, it will have to start over with that sequence the next time
it is executed. (Files often get the same mtime if they are edited in an
IDE and then all saved when executing the build command.) But reducing
the number of cache files is worth that minor inconvenience.
In case anyone is curious, the script is here:
http://widelands.svn.sourceforge.net/viewvc/*checkout*/widelands/trunk/utils/spurious_source_code/detect
--
gentoo-user@lists.gentoo.org mailing list
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-03-03 13:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-01 12:40 [gentoo-user] Set a property on a file and have it remove when the file is modified? Erik
2008-03-01 14:18 ` Florian Philipp
2008-03-01 15:40 ` Etaoin Shrdlu
2008-03-01 16:38 ` Matthias Guede
2008-03-01 16:49 ` Erik
2008-03-03 4:25 ` Daniel Iliev
2008-03-03 13:12 ` Erik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox