Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by Old Wolf
Mon, 14 May 2007 22:20
FlushFileBuffers on iostream
Author: Old Wolf
Date: Mon, 14 May 2007 22:20
Date: Mon, 14 May 2007 22:20
11 lines
1142 bytes
1142 bytes
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.
Re: FlushFileBuffers on iostream
Author: Darko Miletic
Date: Thu, 17 May 2007 15:42
Date: Thu, 17 May 2007 15:42
25 lines
1986 bytes
1986 bytes
On 14 May 2007 15:20:53 -0700, "Old Wolf" <oldwolf@inspire.net.nz> wrote: > >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
Re: FlushFileBuffers on iostream
Author: sebor
Date: Fri, 18 May 2007 04:58
Date: Fri, 18 May 2007 04:58
34 lines
2903 bytes
2903 bytes
On May 17, 9:42 am, Darko Miletic <kik...@fibertel.com.ar> wrote: [...] > 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 > 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. > > 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads