On Tue, Nov 29, 2011 at 15:50, Mithun P. [email protected]
for any directory, i need to create a list of files in it and store in a
xml and mark the ones which have modified as “changed”.
There are a number of possible approaches.
If you just need to check whether the file has been written since
the program was last run, just look at the file’s directory entry and
compare that to some timestamp of when the program was last run.
If you need to detect only actual changes, so that rewriting it with
the same content doesn’t count, but you don’t need to show what the
changes are, you can keep a list of hashes of the files.
If you need to detect and show changes, you can keep copies of the
files, and compare the files against the copies.
If you need to detect changes, but don’t count things that really
shouldn’t count in XML but might change, such as reordering child
nodes, do like above but convert both to a canonical representation,
like sorting all children in some predetermined way.
There are lots of other ways. Just think about it in light of what
your needs are, and continually ask youself “could I make this
simpler” until the answer is no…