Boost logo

Boost Users :

Subject: Re: [Boost-users] boost filesystem
From: Igor R (boost.lists_at_[hidden])
Date: 2012-01-23 12:14:43


> Hello, I hope someone here will be able to help with this.  Sorry, but the
> background is a little long-winded....
>
> I've just discovered to my dismay that Microsoft's implementation of
> fstream, ifstream and ofstream are fatally flawed.  I'm not sure if these
> characters will display correctly across this mailing list but consider the
> following character set:-
>
>       ΔΗΜΗΤΡΗΣ
>
> which is apparently the Greek name "Dimitris".  In an English locale, the
> following path would only be considered valid (by Windows) in a Unicode
> environment:-
>
> C:/Users/ΔΗΜΗΤΡΗΣ/some_file_name
>
> That's fine - because the user name doesn't contain valid English
> characters.  However in Greece, that same path should qualify as a valid,
> non-Unicode file path and should therefore be openable without needing
> Unicode.  For example, when building with MSVC this works:-
>
> #include <fcntl>
>
>       int file = _open("C:/Users/ΔΗΜΗΤΡΗΣ/some_file_name", _O_RDONLY);
>
> However, this fails to work - even though it uses the same path:-
>
> #include <fstream>
> using std::fsrream;
>
>       fstream file("C:/Users/ΔΗΜΗΤΡΗΣ/some_file_name", fstream::in | fstream::out);

That's very strange. I've just tried the following: changed system
locale to russian (Win7: Region&Language --> Administrative-->change
system locale...), and tried the above c++ code with path in russian
-- it works well. (Note that your source-file should be in the
appropriate code-page!)

> To cut a long story short, I noticed that libboost offers its own
> 'filesystem' implementation.  Does boost::filesystem implement its own
> fstream, ifstream and ofstream?  If so, would they likely suffer from the
> same problem (on Windows).  If not, where can I find some examples of using boost::filesystem?

Here's its documentation:
http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v3/doc/reference.html#File-streams


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net