Skip to content

file_mapping should be able to take a boost::filesystem or std::filesystem Path object in constructor #266

@jlmxyz

Description

@jlmxyz

Version of Boost

1.88

Actual and Expected Behavior

namespace bi = boost::interprocess;
namespace fs = boost::filesystem;
if (fs::is_regular_file (x.path ())
                   && x.path ().extension () == ".json")
            {
              cout << "processing " << x.path () << std::endl;
              // create memory mapped object
              bi::file_mapping lJsonFile (x.path (), bi::read_only);   //error, passing a path instead of const char*
              std::size_t lFileSize = x.path ().size ();
              bi::mapped_region lFileMapp(lJsonFile, bi::read_only);
            }

a workaround can be done with

bi::file_mapping lJsonFile (x.path ().c_str(), bi::read_only);

however filesystems names can not be "translated" as c string : today filesystems are mostly unicode, if utf_8 filesystem are c_str compatible, it's not the case when utf_16, utf_32.... at least the path should be a std::u8string_view that will cause utf convertion

char* file name are now quite confusing, std::filesystem/boost::filesystem solve/clarify the issue of unicode path as u8string(_view) u16string(_view) and u32string(_view) does clarify code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions