Ticket #9583: boost_interprocess_file_lock_wchar.patch
File boost_interprocess_file_lock_wchar.patch, 3.6 KB (added by , 9 years ago) |
---|
-
detail/os_file_functions.hpp
124 124 (name, (unsigned int)mode, winapi::open_existing, attr, 0); 125 125 } 126 126 127 inline file_handle_t open_existing_file 128 (const wchar_t *name, mode_t mode, bool temporary = false) 129 { 130 unsigned long attr = temporary ? winapi::file_attribute_temporary : 0; 131 return winapi::create_file 132 (name, (unsigned int)mode, winapi::open_existing, attr, 0); 133 } 134 127 135 inline bool delete_file(const char *name) 128 136 { return winapi::unlink_file(name); } 129 137 -
detail/win32_api.hpp
914 914 extern "C" __declspec(dllimport) void * __stdcall MapViewOfFileEx (void *, unsigned long, unsigned long, unsigned long, std::size_t, void*); 915 915 extern "C" __declspec(dllimport) void * __stdcall OpenFileMappingA (unsigned long, int, const char *); 916 916 extern "C" __declspec(dllimport) void * __stdcall CreateFileA (const char *, unsigned long, unsigned long, struct interprocess_security_attributes*, unsigned long, unsigned long, void *); 917 extern "C" __declspec(dllimport) void * __stdcall CreateFileW (const wchar_t *, unsigned long, unsigned long, struct interprocess_security_attributes*, unsigned long, unsigned long, void *); 917 918 extern "C" __declspec(dllimport) void __stdcall GetSystemInfo (struct system_info *); 918 919 extern "C" __declspec(dllimport) int __stdcall FlushViewOfFile (void *, std::size_t); 919 920 extern "C" __declspec(dllimport) int __stdcall VirtualUnlock (void *, std::size_t); … … 1193 1194 return invalid_handle_value; 1194 1195 } 1195 1196 1197 inline void *create_file(const wchar_t *name, unsigned long access, unsigned long creation_flags, unsigned long attributes, interprocess_security_attributes *psec) 1198 { 1199 for (unsigned int attempt(0); attempt < error_sharing_violation_tries; ++attempt) { 1200 void * const handle = CreateFileW(name, access, 1201 file_share_read | file_share_write | file_share_delete, 1202 psec, creation_flags, attributes, 0); 1203 bool const invalid(invalid_handle_value == handle); 1204 if (!invalid) { 1205 return handle; 1206 } 1207 if (error_sharing_violation != get_last_error()) { 1208 return handle; 1209 } 1210 sleep(error_sharing_violation_sleep_ms); 1211 } 1212 return invalid_handle_value; 1213 } 1214 1196 1215 inline void get_system_info(system_info *info) 1197 1216 { GetSystemInfo(info); } 1198 1217 -
sync/file_lock.hpp
53 53 //!Opens a file lock. Throws interprocess_exception if the file does not 54 54 //!exist or there are no operating system resources. 55 55 file_lock(const char *name); 56 file_lock(const wchar_t *name); 56 57 57 58 //!Moves the ownership of "moved"'s file mapping object to *this. 58 59 //!After the call, "moved" does not represent any file mapping object. … … 211 212 } 212 213 } 213 214 215 inline file_lock::file_lock(const wchar_t *name) 216 { 217 m_file_hnd = ipcdetail::open_existing_file(name, read_write); 218 219 if (m_file_hnd == ipcdetail::invalid_file()) { 220 error_info err(system_error_code()); 221 throw interprocess_exception(err); 222 } 223 } 224 214 225 inline file_lock::~file_lock() 215 226 { 216 227 if(m_file_hnd != ipcdetail::invalid_file()){