 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Old Wolf Guest
|
Posted: Tue May 15, 2007 3:20 am Post subject: FlushFileBuffers on iostream |
|
|
Is it possible to obtain a Windows HANDLE for a file
that I've opened as a C++ fstream, so that I can call
FlushFileBuffers on it?
I'm not sure whether fstream::sync (or stdio fflush)
calls this function; I think those functions just
flush data from the C or C++ library buffering, to
the operating system. The FlushFileBuffers causes
the operating system to ensure the data has been
sent to the disk. |
|
| Back to top |
|
 |
Darko Miletic Guest
|
Posted: Thu May 17, 2007 8:42 pm Post subject: Re: FlushFileBuffers on iostream |
|
|
On 14 May 2007 15:20:53 -0700, "Old Wolf" <oldwolf (AT) inspire (DOT) net.nz>
wrote:
| Quote: |
Is it possible to obtain a Windows HANDLE for a file
that I've opened as a C++ fstream, so that I can call
FlushFileBuffers on it?
|
No. There is no standard way AFAIK to do that.
Standard says that all I/O functions (opening, closing, reading and
writing) are forwarded to the std::basic_filebuf class. Common
implementation of this class uses C file streams for all operations.
That is the case with Dinkumware, RW and stlport.
The only thing you can do is to implement your custom version of file
stream which would generaly mean you will need to create your version
of basic_filebuf class and new version of fstream class that uses that
new version of basic_filebuf for I/O.
In that implementation you will have to use CreateFile/CloseHandle and
other respective windows API functions.
As a starting point take a look at this article:
http://incubator.apache.org/stdcxx/doc/stdlibug/39-2.html |
|
| Back to top |
|
 |
sebor@roguewave.com Guest
|
Posted: Fri May 18, 2007 8:10 am Post subject: Re: FlushFileBuffers on iostream |
|
|
On May 17, 9:42 am, Darko Miletic <kik...@fibertel.com.ar> wrote:
[...]
| Quote: | No. There is no standard way AFAIK to do that.
|
That's correct. For now at least. There is some effort to add support
for this in the next C++ standard, along the lines of the Classic
Iostream
functions fd(), attach(), and detach(). These extensions have already
been implemented in the Apache C++ Standard Library. See
http://incubator.apache.org/stdcxx/doc/stdlibref/basic-filebuf.html#idx51
| Quote: | Standard says that all I/O functions (opening, closing, reading and
writing) are forwarded to the std::basic_filebuf class. Common
implementation of this class uses C file streams for all operations.
That is the case with Dinkumware, RW and stlport.
|
The latest Rogue Wave implementation of the C++ Standard Library
(as well as Apache stdcxx that was derived from it) is based on the
native file I/O (i.e., POSIX read/write or the Windows API), although
the library can be configured to use stdio instead as an option. On
most operating systems these "native" calls are faster.
| Quote: |
The only thing you can do is to implement your custom version of file
stream which would generaly mean you will need to create your version
of basic_filebuf class and new version of fstream class that uses that
new version of basic_filebuf for I/O.
In that implementation you will have to use CreateFile/CloseHandle and
other respective windows API functions.
As a starting point take a look at this article:
http://incubator.apache.org/stdcxx/doc/stdlibug/39-2.html |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|