Is it possible to get the underlying file HANDLE from a std::ofstream (Visual C++ 2005)?
This is the opposite of this question:
Can I use CreateFile, but force the handle into a std::ofstream?
The reason I want to so this is to modify attributes of the file (e.g. creation time) without having to open the file with CreateFile.
The C++ standard does not provide any means for specifying or retrieving the raw file descriptors of an ofstream
, so I don't believe this is possible. What is possible, though, would be to build a custom streambuf
class that implements stream buffering to and from a HANDLE
, then to define a custom ostream
type that uses that buffer. I'm not sure if that's really what you're looking for, but it is a viable option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With