Make Windows path.cpp actually build. Still not really tested.
Originally committed to SVN as r5332.
This commit is contained in:
parent
acbe4bbb34
commit
bc002d749c
1 changed files with 9 additions and 8 deletions
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <libaegisub/path.h>
|
#include <libaegisub/path.h>
|
||||||
#include <libaegisub/charset_conv_win.h>
|
#include <libaegisub/charset_conv_win.h>
|
||||||
|
#include <libaegisub/util_win.h>
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -43,7 +44,7 @@ const std::string WinGetFolderPath(int folder) {
|
||||||
path // pszPath
|
path // pszPath
|
||||||
);
|
);
|
||||||
if (FAILED(res))
|
if (FAILED(res))
|
||||||
throw new agi::PathErrorInternal; //< @fixme error message?
|
throw new agi::PathErrorInternal("SHGetFolderPath() failed"); //< @fixme error message?
|
||||||
else
|
else
|
||||||
return agi::charset::ConvertW(std::wstring(path));
|
return agi::charset::ConvertW(std::wstring(path));
|
||||||
}
|
}
|
||||||
|
@ -62,15 +63,15 @@ std::string get_install_path() {
|
||||||
|
|
||||||
wchar_t path[MAX_PATH+1] = {0};
|
wchar_t path[MAX_PATH+1] = {0};
|
||||||
wchar_t *fn;
|
wchar_t *fn;
|
||||||
DWORD res = GetFullPathNameW(argv, MAX_PATH, path, &fn);
|
DWORD res = GetFullPathNameW(argv[0], MAX_PATH, path, &fn);
|
||||||
LocalFree(argv);
|
LocalFree(argv);
|
||||||
|
|
||||||
if (res > 0 && GetLastError() == 0) {
|
if (res > 0 && GetLastError() == 0) {
|
||||||
*fn = "\0"; // fn points to filename part of path, set an end marker there
|
*fn = '\0'; // fn points to filename part of path, set an end marker there
|
||||||
install_path = agi::charset::ConvertW(std::wstring(path));
|
install_path = agi::charset::ConvertW(std::wstring(path));
|
||||||
install_path_valid = true;
|
install_path_valid = true;
|
||||||
} else {
|
} else {
|
||||||
throw new agi::PathErrorInternal;
|
throw new agi::PathErrorInternal(agi::util::ErrorString(GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ std::string get_install_path() {
|
||||||
namespace agi {
|
namespace agi {
|
||||||
|
|
||||||
const std::string Path::Data() {
|
const std::string Path::Data() {
|
||||||
return get_install_path;
|
return get_install_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string Path::Doc() {
|
const std::string Path::Doc() {
|
||||||
|
@ -104,15 +105,15 @@ const std::string Path::Locale() {
|
||||||
|
|
||||||
const std::string Path::Config() {
|
const std::string Path::Config() {
|
||||||
std::string path = WinGetFolderPath(CSIDL_APPDATA);
|
std::string path = WinGetFolderPath(CSIDL_APPDATA);
|
||||||
path.append("Aegisub-");
|
path.append("Aegisub3");
|
||||||
path.append(AEGISUB_VERSION_DATA);
|
/// @fixme should get version number in a more dynamic manner
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string Path::Temp() {
|
const std::string Path::Temp() {
|
||||||
wchar_t path[MAX_PATH+1] = {0};
|
wchar_t path[MAX_PATH+1] = {0};
|
||||||
if (GetTempPath(MAX_PATH, path) == 0)
|
if (GetTempPath(MAX_PATH, path) == 0)
|
||||||
throw new PathErrorInternal;
|
throw new PathErrorInternal(util::ErrorString(GetLastError()));
|
||||||
else
|
else
|
||||||
return charset::ConvertW(std::wstring(path));
|
return charset::ConvertW(std::wstring(path));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue