
----- Original Message -----
From: Alf P. Steinbach <alf.p.steinbach+usenet@gmail.com>
First, apologies if I'm posting to the wrong group/list; if so then please redirect me.
IMHO access to files is a crucial part of Boost.Filesystem. However, with Boost 1.47, and using g++ 4.4.1 in Windows 7, boost::filesystem::ifstream etc. fail to open or create files with non-ANSI characters. It works fine with Visual C++; it FAILS with g++ 4.4.1, which is the one bundled with the Code::Blocks IDE.
The failure probably has nothing to do with the g++ version: it's due to g++ not offering the Visual C++ wchar_t oriented extensions to the standard iostreams (Boost.Filesystem uses these Visual C++ extensions).
I stumbled onto this while I was writing about using Unicode in C++ programming in Windows.
Why just not to implement boost::filesystem::fstream over _wfopen and custom streambuf implementation? It is relatively simple. I have implemented such thing under booster namespace as part of cppcms project http://cppcms.svn.sourceforge.net/viewvc/cppcms/framework/trunk/booster/boos... http://cppcms.svn.sourceforge.net/viewvc/cppcms/framework/trunk/booster/lib/... http://cppcms.svn.sourceforge.net/viewvc/cppcms/framework/trunk/booster/booster/nowide/fstream.h?revision=1967&view=markup
I wrote up a technical solution in section 5, starting on page 16, of that work-in-progress document, available on Google Docs at:
Essentially, the fix I ended up with, full source code given in the above doc, uses Windows short file names if (1) there is no wide character support and if furthermore (2) the filename can't be perfectly translated to ANSI. The C++ implementation's support for wide chars is automatically detected using C++98-compatible code.
I do not know what to do with this.
That is what very good about stream buffers... You can implement anything you need. Using short file names is no go for two reasons: 1. It works only when file exists (can't create new file) 2. It is quite deprecated
But considering that Boost.Filesystem is slated for later inclusion in the C++ standard library (or at least into TR2), I think it would be nice if it is able to give access to all accessible files in Windows, also with g++,
This is a problem that can be fixed easily in Boost.Filesystem.
so that we don't end up with a file handling part of the standard library that can't handle files in general;
This is a "bug" in Windows operating system... but this is other story.
hence this posting and plea for advice -- what more should I do, if anything?
Write a patch that implements stream buffer over stdio and _wfopen?
Cheers,
- Alf
Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/>