elgiei said:
my server already works with
pthread, socket, signal for timer
None of those are part of standard C; those are all operating
system extensions.
and many feature offered by includes,
for external call i mean for example all the "exec" 's
family,whithin you can use any binary file on your /bin directory
(or .exe file).
This is sounding more and more like an assignment rather than a
real-life program.
my ntree has
a lot of node, the same number of files and directories.
a node is composed by n pointer one for each son
Okay.
so if my hard disk is composed only by :
/home/elgiei
/home/elgiei/file2.jpg
/home/elgiei/Desktop
/home/elgiei/Desktop/file1.jpg
my ntree is :
------/home/elgiei------------------------
--------- /--------\---------------------------
file2.jpg--------/home/elgiei/Desktop
-----------------------|-----------------------
------------------file1.jpg-------------------
(remove "-" with space)
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.
after 60secs i rebuild a new ntree and i do a diff (ntreeNEW,ntreeOLD)
and i check the differences..
but it's not a smart solution for large data.
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.
is there a signal Handler for catch file removed ?
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.
anyone has a better idea????
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?