
HELP - How to check file size in DOS
(posted and mailed)
Quote:
> Does anybody may give me a little help to build a piece of code that
> need to run in background and has to check if in a directory the total
> file size of some file is stable or is increasing.
> I need to do this because i have to move automatically data from a
> directory where some files arrive via FTP, so this directory cab be
ever
> free. Checking this size, i know if data is still arriving or if the
FTP
> transfer has finished.
Besides being OFFTOPIC and not relating particularly to C,
this is a poor idea. Network congestion, transients, or
host loading may cause the size of the output file to
temporarily stop growing even though it is not complete.
A failed transfer will also stop growing but the output
may be invalid and you don't want to process it.
One better method is for the sender to directly trigger processing
on the target system with something like REXEC. If this is not
available, another common approach is for the sender to create
an additional marker file only after successfully storing (all of)
the data file; then a process on the server polls for these markers
and when found processes the related or specified data file.
Or the sender stores to one filename (maybe whatever.NOTYET)
and only when complete renames it to a name which the server
daemon is looking for.
But in any case determining file size, or the list of files in a
directory (if directories even exist) is implementation dependent,
and should be discussed on a group for the desired system.
If you know in advance the expected/possible filenames,
you can just try at intervals to fopen() each possible file.
If the fopen() succeeds, the file must exist; but if it fails,
it doesn't guarantee the file doesn't exist, there could be
other causes of error. And the "wait a while" part is also
implementation dependent. See section 19 of the FAQ,
in the usual places or /www.eskimo.com/~scs/C-faq/top.html
--
- David.Thompson 1 now at worldnet.att.net