From 2bad9029cbc40da3ea13dd60702b3e0bf33c81a2 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 6 Feb 2013 19:15:21 -0800 Subject: [PATCH] Set ?data in a way that works with spaces in the path on Windows --- aegisub/libaegisub/windows/path_win.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/aegisub/libaegisub/windows/path_win.cpp b/aegisub/libaegisub/windows/path_win.cpp index f5f5e5a3b..a71231d55 100644 --- a/aegisub/libaegisub/windows/path_win.cpp +++ b/aegisub/libaegisub/windows/path_win.cpp @@ -44,11 +44,10 @@ void Path::FillPlatformSpecificPaths() { SetToken("?user", WinGetFolderPath(CSIDL_APPDATA)/"Aegisub"); SetToken("?local", WinGetFolderPath(CSIDL_LOCAL_APPDATA)/"Aegisub"); - /// @todo error checking - int argc; - LPWSTR *argv = CommandLineToArgvW(L"", &argc); - SetToken("?data", argv[0]); - LocalFree(argv); + std::wstring filename(MAX_PATH + 1, L'\0'); + while (static_cast(filename.size()) == GetModuleFileNameW(nullptr, &filename[0], filename.size())) + filename.resize(filename.size() * 2); + SetToken("?data", filename); SetToken("?dictionary", Decode("?data/dictionaries")); //SetToken("?docs", Decode("?data/docs"));