L
Lilith
I've been working on a program in VC++. The basic operation of the
system I'm working with is that I create a file in on directory, the
system picks it up and generates a report in another directory, which
I then read in and to strip out the information I need. The file I'm
reading is not named with any correlation to the file name I wrote out
so I have to monitor for when a new file appears and check it to make
sure it's the one resulting from my query.
My tactic is to do a findfirst/findnext on all of the existing files
in the directory so I don't have to read through all of them later to
verify that they're either the one I want or not. I then write out my
request and go into a loop waiting for a new file to appear with
either a findfirst or findnext depending on whether or not the
directory may have been empty to begin with.
The crux of my problem is that when the file first shows up it's
likely to have a zero length to it so I need to wait until it's
completely written out and the size shows to be non-zero. Somewhere
in trying to get this all to work I think I'm mangling the file handle
value or at least its effect on the file find mechanism. I can avoid
this if I can get the file length without having to resort to using
the file handle and finddata_t.
So, is there a way to find the length of a file without resorting to
using findfirst/findnext to get information into a finddata_t
structure? I'm using fstream as opposed to FILE or CFile.
TIA,
Lilith
system I'm working with is that I create a file in on directory, the
system picks it up and generates a report in another directory, which
I then read in and to strip out the information I need. The file I'm
reading is not named with any correlation to the file name I wrote out
so I have to monitor for when a new file appears and check it to make
sure it's the one resulting from my query.
My tactic is to do a findfirst/findnext on all of the existing files
in the directory so I don't have to read through all of them later to
verify that they're either the one I want or not. I then write out my
request and go into a loop waiting for a new file to appear with
either a findfirst or findnext depending on whether or not the
directory may have been empty to begin with.
The crux of my problem is that when the file first shows up it's
likely to have a zero length to it so I need to wait until it's
completely written out and the size shows to be non-zero. Somewhere
in trying to get this all to work I think I'm mangling the file handle
value or at least its effect on the file find mechanism. I can avoid
this if I can get the file length without having to resort to using
the file handle and finddata_t.
So, is there a way to find the length of a file without resorting to
using findfirst/findnext to get information into a finddata_t
structure? I'm using fstream as opposed to FILE or CFile.
TIA,
Lilith