Gentoo Archives: gentoo-user

From: Daniel Iliev <daniel.iliev@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Set a property on a file and have it remove when the file is modified?
Date: Mon, 03 Mar 2008 04:25:58
Message-Id: 20080303062551.28c2f6d7@ilievnet.com
In Reply to: Re: [gentoo-user] Set a property on a file and have it remove when the file is modified? by Erik
1 On Sat, 01 Mar 2008 17:49:34 +0100
2 Erik <esigra@×××××.com> wrote:
3
4 > Matthias Guede skrev:
5 > > 2008/3/1, Erik <esigra@×××××.com>:
6 > >
7 > >> Is it possible to set a property on a file and have it remove
8 > >> automatically when the file is modified?
9 > >>
10 > >> Suppose that we have a style checker that checks a lot of source
11 > >> code files. Once it examined a file and found it to be clean, it
12 > >> should set a property on the file ("style-clean"). Whenever the
13 > >> style checker is executed it skips files with this property.
14 > >> Whenever the file is modified, the filesystem removes the property.
15 > >>
16 > >> Is this possible? Which filesystems does it work on?
17 > >>
18 > >
19 > > One solution would be using 'make'. With rules like the following
20 > > only modified files will
21 > > be proceeded:
22 > >
23 > > timestamp: myFile
24 > > doSomthingWidth myFile
25 > > touch timestamp
26 > >
27 >
28 > We have thought about that, but we would like to avoid having a
29 > parallel file hierarchy of timestamp files for our source tree.
30 > Therefore something like the archive attribute (suggested by Etanoi
31 > Shrdlu) would be better.
32
33
34 Actually, if there are no other concerns, you'd have to keep only one
35 file for reference. Then you could compare the modification times of all
36 other files with this reference file.
37
38 #!/bin/bash
39 # initial/full scan
40
41 touch timestamp.chk
42 find hierarchy | while read some_file
43 do
44 [[ stylecheck("$some_file") -eq 0 ]] || touch "$some.file"
45 done
46
47 #EOF
48
49
50 After this every time you run stylecheck(), you'd have to check only
51 the files having newer time stamp than the one of "timestamp.chk".
52
53 #!/bin/bash
54 # incremental scan
55
56 find hierarchy -newer timestamp.chk > modified.list
57 touch timestamp.chk
58
59 while read some_file
60 do
61 [[ stylecheck("$some_file") -eq 0 ]] || touch "$some.file"
62 done < modified.list
63 unlink modified.list
64
65 #EOF
66
67
68
69 --
70 Best regards,
71 Daniel
72 --
73 gentoo-user@l.g.o mailing list

Replies