Cosmetics in standard_paths.cpp
Originally committed to SVN as r6233.
This commit is contained in:
parent
01646d7cf4
commit
43d4e785fb
2 changed files with 22 additions and 47 deletions
|
@ -34,9 +34,6 @@
|
||||||
/// @ingroup utility
|
/// @ingroup utility
|
||||||
///
|
///
|
||||||
|
|
||||||
|
|
||||||
///////////
|
|
||||||
// Headers
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
|
@ -46,19 +43,11 @@
|
||||||
|
|
||||||
#include "standard_paths.h"
|
#include "standard_paths.h"
|
||||||
|
|
||||||
|
|
||||||
/// @brief Get instance
|
|
||||||
/// @return
|
|
||||||
///
|
|
||||||
StandardPaths &StandardPaths::GetInstance() {
|
StandardPaths &StandardPaths::GetInstance() {
|
||||||
static StandardPaths instance;
|
static StandardPaths instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Constructor
|
|
||||||
///
|
|
||||||
StandardPaths::StandardPaths() {
|
StandardPaths::StandardPaths() {
|
||||||
wxStandardPathsBase &paths = wxStandardPaths::Get();
|
wxStandardPathsBase &paths = wxStandardPaths::Get();
|
||||||
|
|
||||||
|
@ -82,24 +71,19 @@ StandardPaths::StandardPaths() {
|
||||||
wxString tempDir = paths.GetTempDir();
|
wxString tempDir = paths.GetTempDir();
|
||||||
|
|
||||||
// Set paths
|
// Set paths
|
||||||
DoSetPathValue("?data",dataDir);
|
DoSetPathValue("?data", dataDir);
|
||||||
DoSetPathValue("?user",userDir);
|
DoSetPathValue("?user", userDir);
|
||||||
DoSetPathValue("?temp",tempDir);
|
DoSetPathValue("?temp", tempDir);
|
||||||
|
|
||||||
// Create paths if they don't exist
|
// Create paths if they don't exist
|
||||||
wxFileName folder(userDir + "/");
|
wxFileName folder(userDir + "/");
|
||||||
if (!folder.DirExists()) folder.Mkdir(0777,wxPATH_MKDIR_FULL);
|
if (!folder.DirExists()) folder.Mkdir(0777,wxPATH_MKDIR_FULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Decode path
|
|
||||||
/// @param path
|
|
||||||
/// @return
|
|
||||||
///
|
|
||||||
wxString StandardPaths::DoDecodePath(wxString path) {
|
wxString StandardPaths::DoDecodePath(wxString path) {
|
||||||
// Decode
|
if (!path || path[0] != '?')
|
||||||
if (path[0] == '?') {
|
return path;
|
||||||
|
|
||||||
// Split ?part from rest
|
// Split ?part from rest
|
||||||
path.Replace("\\","/");
|
path.Replace("\\","/");
|
||||||
int pos = path.Find("/");
|
int pos = path.Find("/");
|
||||||
|
@ -119,16 +103,8 @@ wxString StandardPaths::DoDecodePath(wxString path) {
|
||||||
final.Replace("/","\\");
|
final.Replace("/","\\");
|
||||||
#endif
|
#endif
|
||||||
return final;
|
return final;
|
||||||
}
|
|
||||||
|
|
||||||
// Nothing to decode
|
|
||||||
else return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Set value of a ? path
|
|
||||||
/// @param path
|
|
||||||
/// @param value
|
|
||||||
///
|
|
||||||
void StandardPaths::DoSetPathValue(const wxString &path, const wxString &value) {
|
void StandardPaths::DoSetPathValue(const wxString &path, const wxString &value) {
|
||||||
paths[path] = value;
|
paths[path] = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@ class StandardPaths {
|
||||||
void DoSetPathValue(const wxString &path, const wxString &value);
|
void DoSetPathValue(const wxString &path, const wxString &value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static wxString DecodePath(const wxString &path) { return GetInstance().DoDecodePath(path); }
|
static wxString DecodePath(const wxString &path) { return GetInstance().DoDecodePath(path); }
|
||||||
static void SetPathValue(const wxString &path, const wxString &value) { GetInstance().DoSetPathValue(path,value); }
|
static void SetPathValue(const wxString &path, const wxString &value) { GetInstance().DoSetPathValue(path,value); }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue