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 2 4274
Lilith wrote: 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.
There is no way to do this in standard C++, you'll have to ask in a
Windows newsgroup (there may be a platform specific way, but we can't
discuss it here).
HTH,
--ag
--
Artie Gold -- Austin, Texas http://it-matters.blogspot.com (new post 12/5) http://www.cafepress.com/goldsays
On Fri, 10 Jun 2005 12:58:02 -0500, Artie Gold
<ar*******@austin.rr.com> wrote: Lilith wrote: 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.
There is no way to do this in standard C++, you'll have to ask in a Windows newsgroup (there may be a platform specific way, but we can't discuss it here).
My luck!! :-))
Thanks,
Lilith
HTH, --ag This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sean W. Quinn |
last post by:
Hey folks,
I have a question regarding file handling, and the preservation of class
structure. I have a class (and I will post snippets of code later in the
post) with both primitive data...
|
by: SK |
last post by:
Hey folks,
I am searching for a string (say "ABC") backwards in a file.
First I seek to the end.
Then I try to make a check like -
do {
file.clear ();
file.get(c);
file.seekg(-2,...
|
by: pembed2003 |
last post by:
Hi all,
Given something like:
std::ofstream out_file("path");
how do I extract the file descriptor from out_file? Is it possible?
What I want is to extract the file descriptor and then pass...
|
by: kelvSYC |
last post by:
With std::fopen, will it return a null pointer if the file does not
exist? If so, how do I make it so that it will attempt to create a
file if it doesn't exist? Would moving to fstreams/filebufs...
|
by: David Warner |
last post by:
Greetings!
I am working on a C app that needs to read print files generated by lp
that contain HP LaserJet PCL codes. If the PCL contains binary data to
define a bit map to be printed on the...
|
by: hazmaz |
last post by:
I am writing a program will have a function where it opens a text file,
and fills a list box line by line from the text file. It works fine,
except for when I tried to load a dictionary which is ~...
|
by: Dic4000 |
last post by:
ÏÂÃæ³ÌÐò½¨Á¢²»ÁËÎļþ,²»ÖªµÀÄÄÀï³ö´íÁË?
Ö»Ï붨ÒåÒ»¸öfstreamÀàÐÍÀ´Íê³ÉÊäÈëÊä³öµÄ¹¤×÷.
#include<iostream>
#include<conio.h>
#include<fstream>
using namespace std;
|
by: Thomas Kowalski |
last post by:
Hi,
currently I am reading a huge (about 10-100 MB) text-file line by line
using
fstreams and getline. I wonder whether there is a faster way to read a
file line by line (with std::string line)....
|
by: rory |
last post by:
I can't seem to append a string to the end of a binary file. I'm using
the following code:
fstream outFile("test.exe", ios::in | ios::out | ios::binary |
ios::ate | ios::app)...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |