diff --git a/mars/comm/mmap_util.cc b/mars/comm/mmap_util.cc index 7478fadf8..12c0e0111 100644 --- a/mars/comm/mmap_util.cc +++ b/mars/comm/mmap_util.cc @@ -42,8 +42,8 @@ bool OpenMmapFile(const char* _filepath, unsigned int _size, boost::iostreams::m return false; } - boost::iostreams::mapped_file_params param; - param.path = _filepath; + boost::iostreams::basic_mapped_file_params param; + param.path = boost::filesystem::path(_filepath); param.flags = boost::iostreams::mapped_file_base::readwrite; bool file_exist = boost::filesystem::exists(_filepath); @@ -54,7 +54,7 @@ bool OpenMmapFile(const char* _filepath, unsigned int _size, boost::iostreams::m _mmmap_file.open(param); bool is_open = IsMmapFileOpenSucc(_mmmap_file); - +#ifndef _WIN32 if (!file_exist && is_open) { //Extending a file with ftruncate, thus creating a big hole, and then filling the hole by mod-ifying a shared mmap() can lead to SIGBUS when no space left @@ -62,7 +62,7 @@ bool OpenMmapFile(const char* _filepath, unsigned int _size, boost::iostreams::m FILE* file = fopen(_filepath, "rb+"); if (NULL == file) { _mmmap_file.close(); - remove(_filepath); + boost::filesystem::remove(_filepath); return false; } @@ -72,14 +72,14 @@ bool OpenMmapFile(const char* _filepath, unsigned int _size, boost::iostreams::m if (_size != fwrite(zero_data, sizeof(char), _size, file)) { _mmmap_file.close(); fclose(file); - remove(_filepath); + boost::filesystem::remove(_filepath); delete[] zero_data; return false; } fclose(file); delete[] zero_data; } - +#endif return is_open; }