Boost logo

Boost :

Subject: [boost] Making Boost.Filesystem work with GENERAL filenames with g++ in Windows (a solution)
From: Alf P. Steinbach (alf.p.steinbach+usenet_at_[hidden])
Date: 2011-10-25 09:41:55

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.

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.

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++, so that we don't end up with a file handling part of the
standard library that can't handle files in general; hence this posting
and plea for advice -- what more should I do, if anything?


- Alf

Boost list run by bdawes at, gregod at, cpdaniel at, john at