In article < XXXX@XXXXX.COM >,
None of those are part of standard C; those are all operating
system extensions.
This is sounding more and more like an assignment rather than a
real-life program.
Okay.
So if there are duplicated prefixes, you store the prefix once per file?
That's less space efficient than it could be, but does make it easier
to insert or delete new nodes.
It seems to me that you don't need to build a new ntree and do a
comparison. Provided you use a consistant ordering (e.g., depth-first,
sorted order), you should be able to start at the beginning and trace
the existing ntree through for each file: if you are processing a
file that is not part of the current n-tree then it is a new file,
and if the next file does not correspond to the next node threaded
along the leaves, then any nodes that were skipped in the process
were removed (or renamed.) It shouldn't be difficult for you to
add threading between the leaves.
As I indicated earlier, standard C doesn't know anything about
directories -- and all it knows about files is that if you
pass a complete null-terminated string to fopen() then some
file somewhere will be opened (or the open will fail.) Standard C
doesn't know anything about what those filename strings -mean-.
Thus, of course there is no signal or any other method in standard C
of detecting that a file has been removed: the existance of such
a function would require knowing something about filesystems, which
standard C does not.
There might be a mechanism in your operating system to notice such
things, but any such facility would be OS-specific, and you would
need to inquire about it in a newsgroup that deals with your
(unnamed) operating system. (I wasn't able to deduce which OS you
are writing this for; you mentioned inotify() which appears to be
Linux-specific, and you mentioned ext3 filesystems, which appear
to be Linux-specific, but you also mentioned NTFS filesystems,
which are proprietary to Microsoft Windows.
What is the object of the assignment? To explore efficient use
of tree structures, or to explore how one would implement OS
facilities if those facilities were not already provided?
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson