[Mingw-w64-public] Windows/MinGW extension: opening std::fstream with a wstring/wchar_t*

Sam Morris sam@robots.org.uk
Mon Jun 27 20:22:00 GMT 2011


> 2011/6/26 Sam Morris <sam@robots.org.uk>:
> > FYI, I think you can do this without modifying the fstream like this:
> >
> > __gnu_cxx::stdio_filebuf b (_wopen (L"filename", _O_RDONLY));
> > std::istream i (&b);
> >
> > The stdio_filebuf will close the file when it's done.
> >
> > stdio_filebuf can also be constructed given a FILE* argument, which lets
> > you open the file with _wfopen; however in this case it won't close the
> > FILE* when it is destroyed.
> 
> Let me start by saying I mean no offence ;-) __gnu_cxx hacks is
> exactly what I'm trying to avoid. I think my idea has true added value
> due to it also being in "the other big STL" for the Windows platform
> (If it is liked here, I see no reason not to also propose it to LLVM's
> libc++).

Oh, yes, definitely. I would love to see fstream extended to take a
wchar_t path on Windows as then I can move away from relying on the
__gnu_cxx::stdio_filebuf class. :)

> Ruben

-- 
Sam Morris <https://robots.org.uk/>
3412 EA18 1277 354B 991B  C869 B219 7FDB 5EA0 1078
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20110627/ccd63ef3/attachment.sig>


More information about the Libstdc++ mailing list