summaryrefslogtreecommitdiff
path: root/base/SharedMemory_win32.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'base/SharedMemory_win32.cpp')
-rw-r--r--base/SharedMemory_win32.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/base/SharedMemory_win32.cpp b/base/SharedMemory_win32.cpp
index 6b253f10..b6214ddd 100644
--- a/base/SharedMemory_win32.cpp
+++ b/base/SharedMemory_win32.cpp
@@ -13,6 +13,7 @@
// limitations under the License.
#include "base/SharedMemory.h"
+#include <shlwapi.h>
#include <cassert>
#include <string>
@@ -25,9 +26,15 @@ namespace base {
SharedMemory::SharedMemory(const std::string& name, size_t size) : mSize(size) {
const std::string kFileUri = "file://";
if (name.find(kFileUri, 0) == 0) {
+ // Convert URI to path using win32 api.
+ const Win32UnicodeString srcUri(name);
+ WCHAR path[MAX_PATH];
+ DWORD cPath = MAX_PATH;
+ auto HR = PathCreateFromUrlW(srcUri.c_str(), path, &cPath, NULL);
+ assert(HR == S_OK);
+ const Win32UnicodeString destPath(path);
+ mName = PathUtils::recompose(PathUtils::decompose(destPath.toString()));
mShareType = ShareType::FILE_BACKED;
- auto path = name.substr(kFileUri.size());
- mName = PathUtils::recompose(PathUtils::decompose(path));
} else {
mShareType = ShareType::SHARED_MEMORY;
mName = "SHM_" + name;