diff --git a/aegisub/build/libaegisub_vs2008/libaegisub_vs2008.vcproj b/aegisub/build/libaegisub_vs2008/libaegisub_vs2008.vcproj
index 157950752..56a9dd481 100644
--- a/aegisub/build/libaegisub_vs2008/libaegisub_vs2008.vcproj
+++ b/aegisub/build/libaegisub_vs2008/libaegisub_vs2008.vcproj
@@ -291,10 +291,6 @@
RelativePath="..\..\libaegisub\common\log.cpp"
>
-
-
@@ -315,6 +311,10 @@
RelativePath="..\..\libaegisub\common\path.cpp"
>
+
+
@@ -341,10 +341,6 @@
RelativePath="..\..\libaegisub\windows\io.cpp"
>
-
-
@@ -401,6 +397,10 @@
/>
+
+
diff --git a/aegisub/libaegisub/common/path.cpp b/aegisub/libaegisub/common/path.cpp
index 5f65ea95a..800e8f11b 100644
--- a/aegisub/libaegisub/common/path.cpp
+++ b/aegisub/libaegisub/common/path.cpp
@@ -42,7 +42,7 @@ Path::~Path() {
}
-const std::string Path::Get(const char *name) {
+std::string Path::Get(const char *name) {
std::string path;
try {
path = std::string(opt->Get(name)->GetString());
diff --git a/aegisub/libaegisub/include/libaegisub/path.h b/aegisub/libaegisub/include/libaegisub/path.h
index 362c940a2..bcc932f18 100644
--- a/aegisub/libaegisub/include/libaegisub/path.h
+++ b/aegisub/libaegisub/include/libaegisub/path.h
@@ -48,7 +48,7 @@ public:
/// @brief Get a path, this is automatically decoded.
/// @param name Path to get
/// @return Full path name in UTF-8
- const std::string Get(const char *name);
+ std::string Get(const char *name);
/// @brief Set a path, this will be automaticalled encoded if a cookie matches.
/// @param[in] name Path name to save to.
@@ -70,14 +70,14 @@ public:
/// Windows: Documents folder
/// OS X: ~/Documents
/// Unix: ~ or Documents folder if set in the environment
- const std::string Default();
+ std::string Default();
/// @brief Decode a path
/// @param path Decode a path in-place.
void Decode(std::string &path);
/// Configuration directory
- static const std::string Config();
+ static std::string Config();
private:
/// Location of path config file.
@@ -102,13 +102,13 @@ private:
/// @brief Locale files
/// @return Locale location
/// This is directly assessibly as the Locale directory will never change on any platform.
- const std::string Locale();
+ std::string Locale();
protected:
- const std::string Data(); ///< Shared resources
- const std::string Doc(); ///< Documents
- const std::string User(); ///< User config directory
- const std::string Temp(); ///< Temporary storage
+ std::string Data(); ///< Shared resources
+ std::string Doc(); ///< Documents
+ std::string User(); ///< User config directory
+ std::string Temp(); ///< Temporary storage
};
} // namespace agi
diff --git a/aegisub/libaegisub/unix/path.cpp b/aegisub/libaegisub/unix/path.cpp
index 8b1a0b2e0..27d9113f5 100644
--- a/aegisub/libaegisub/unix/path.cpp
+++ b/aegisub/libaegisub/unix/path.cpp
@@ -35,42 +35,41 @@
namespace agi {
-const std::string home() {
+std::string home() {
char *ehome;
ehome = getenv("HOME");
if (ehome == NULL) {
printf("The HOME environment variable must be set\n");
exit(1);
}
- std::string home(ehome);
- return home;
+ return ehome;
}
-const std::string Path::Data() {
+std::string Path::Data() {
return P_DATA;
}
-const std::string Path::Doc() {
+std::string Path::Doc() {
return P_DOC;
}
-const std::string Path::User() {
+std::string Path::User() {
return home();
}
-const std::string Path::Locale() {
+std::string Path::Locale() {
return P_LOCALE;
}
-const std::string Path::Config() {
+std::string Path::Config() {
std::string tmp(home());
tmp.append("/.aegisub-");
tmp.append(AEGISUB_VERSION_DATA);
return tmp.append("/");
}
-const std::string Path::Temp() {
+std::string Path::Temp() {
return "/tmp/";
}
diff --git a/aegisub/libaegisub/windows/path.cpp b/aegisub/libaegisub/windows/path_win.cpp
similarity index 70%
rename from aegisub/libaegisub/windows/path.cpp
rename to aegisub/libaegisub/windows/path_win.cpp
index df9c81677..3a9f79163 100644
--- a/aegisub/libaegisub/windows/path.cpp
+++ b/aegisub/libaegisub/windows/path_win.cpp
@@ -18,14 +18,12 @@
/// @brief Common paths.
/// @ingroup libaegisub
-
-#include "config.h"
-
#ifndef LAGI_PRE
#include
#endif
#include
+
#include
#include
@@ -34,7 +32,7 @@ namespace {
#include
#include
-const std::string WinGetFolderPath(int folder) {
+std::string WinGetFolderPath(int folder) {
wchar_t path[MAX_PATH+1] = {0};
HRESULT res = SHGetFolderPathW(
0, // hwndOwner
@@ -44,16 +42,14 @@ const std::string WinGetFolderPath(int folder) {
path // pszPath
);
if (FAILED(res))
- throw new agi::PathErrorInternal("SHGetFolderPath() failed"); //< @fixme error message?
- else
- return agi::charset::ConvertW(std::wstring(path));
+ throw agi::PathErrorInternal("SHGetFolderPath() failed"); //< @fixme error message?
+
+ return agi::charset::ConvertW(path);
}
std::string get_install_path() {
static std::string install_path;
- static bool install_path_valid = false;
-
- if (install_path_valid == false) {
+ if (install_path.empty()) {
// Excerpt from :
// lpCmdLine [in]
// If this parameter is an empty string the function returns
@@ -69,53 +65,46 @@ std::string get_install_path() {
if (res > 0 && GetLastError() == 0) {
*fn = '\0'; // fn points to filename part of path, set an end marker there
install_path = agi::charset::ConvertW(std::wstring(path));
- install_path_valid = true;
} else {
- throw new agi::PathErrorInternal(agi::util::ErrorString(GetLastError()));
+ throw agi::PathErrorInternal(agi::util::ErrorString(GetLastError()));
}
}
return install_path;
}
-};
+}
namespace agi {
-const std::string Path::Data() {
+std::string Path::Data() {
return get_install_path();
}
-const std::string Path::Doc() {
- std::string path = Data();
- path.append("docs\\");
- return path;
+std::string Path::Doc() {
+ return Data() + "docs\\";
}
-const std::string Path::User() {
+std::string Path::User() {
return WinGetFolderPath(CSIDL_PERSONAL);
}
-const std::string Path::Locale() {
- std::string path = Data();
- path.append("locale\\");
- return path;
+std::string Path::Locale() {
+ return Data() + "locale\\";
}
-const std::string Path::Config() {
- std::string path = WinGetFolderPath(CSIDL_APPDATA);
- path.append("Aegisub3");
+std::string Path::Config() {
+ return WinGetFolderPath(CSIDL_APPDATA) + "Aegisub3";
/// @fixme should get version number in a more dynamic manner
- return path;
}
-const std::string Path::Temp() {
+std::string Path::Temp() {
wchar_t path[MAX_PATH+1] = {0};
if (GetTempPath(MAX_PATH, path) == 0)
- throw new PathErrorInternal(util::ErrorString(GetLastError()));
+ throw PathErrorInternal(util::ErrorString(GetLastError()));
else
- return charset::ConvertW(std::wstring(path));
+ return charset::ConvertW(path);
}
} // namespace agi