Opened 12 years ago
Closed 11 years ago
#4485 closed Patches (fixed)
boost.filesysten v3 breaks boost:::iostream::mapped_file
Reported by: | Owned by: | Daniel James | |
---|---|---|---|
Milestone: | To Be Determined | Component: | iostreams |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | filesystem v3 iostream mapped_file | Cc: |
Description
boost:::iostream::mapped_file has been design so that when passing file path to the constructor or open(), it only accepts 3 types: std::string, boost::filesystem::path, boost::filesystem::wpath.
due to the late update to boost::filesystem v3, boost::filesystem::path is no longer templated, and wpath is gone. and as Windows uses UTF16, when a path is converted from utf16 to a certain ANSI/OEM code page(CP), causes information loss, for example, "Apress ©" in unicode would be converted to "Apress ?" in CP936, where code point 0x00a9(©) is lost, though it's a legal character in file name.
it amounts to that support for std::wstring in boost:::iostream::mapped_file is gone.
a patch is needed to remove the dependence on boost.filesystem v2, and revert to the support of std::wstring, which can be get from path.wstring() in boost::filesystem v3.
Attachments (2)
Change History (8)
comment:1 by , 12 years ago
Component: | None → iostreams |
---|---|
Owner: | set to |
by , 12 years ago
Attachment: | filesystem_v3_path_adapter.hpp added |
---|
comment:2 by , 12 years ago
The previously attached filesystem_v3_path_adapter.hpp file allows boost filesystem V3 path to be used with file_descriptor* and mapped_file* classes. I've tested this on Windows MSVC8 & Mac XCode 3.1.2/gcc 4.0.1 with utf8 paths. On windows it makes the wide CreateFileW interface accessible for opening unicode path'd files. Example usage:
#include <boost/iostreams/device/mapped_file.hpp> #include <boost/iostreams/filesystem_v3_path_adapter.hpp>
...
boost::filesystem::path p(...);
namespace io = boost::iostreams;
io::mapped_file_source mf_src(io::filesystem_v3_path_adapter(p));
...
comment:3 by , 11 years ago
Another way for adding Filesystem v3 support is to make boost::iostreams::detail::path be constructable from boost::filesystem3::path
See the attachment for the patch.
comment:4 by , 11 years ago
(In [72382]) Iostreams: Support filesystem3 paths. Refs #4485.
Based on Zhuo Qiang's patch with added tests and support
for operator=
.
I also used codecvt_type
to detect filesystem3::path
instead of string_type
. Using string_type
made
filesystem2::path
ambiguous because it has both
string_type
and external_string_type
members.
The member types are a bit arbitrary, but a more precise distinction would probably also be more expensive.
comment:5 by , 11 years ago
Keywords: | filesystem added; filesysten removed |
---|---|
Milestone: | Boost 1.44.0 → To Be Determined |
Owner: | changed from | to
Status: | new → assigned |
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
workaround to adapt filesystem vs path for use with file_descriptor and mapped_file