How do i create a list of modified files in xml

hi

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”. so basically if
i put this file in any folder it should first parse the earlier xml
which was generated by the same ruby file and comparing the files stored
xml for any modification and changing the attribute for them in their
corresponding node

1 sample xml node:

content/Accessibility_document.pdf . . .

regards
miths

On Tue, Nov 29, 2011 at 15:50, Mithun P. [email protected]
wrote:

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…

-Dave

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs