diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:00:17 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:00:17 +0200 |
commit | fd0853d2623dd278b08288331ed42e3be59252fb (patch) | |
tree | a7645daeaef8bdbed064faf4eb88e72cee58726c /shared/standardPaths.cpp | |
parent | 2.1 (diff) | |
download | FreeFileSync-fd0853d2623dd278b08288331ed42e3be59252fb.tar.gz FreeFileSync-fd0853d2623dd278b08288331ed42e3be59252fb.tar.bz2 FreeFileSync-fd0853d2623dd278b08288331ed42e3be59252fb.zip |
2.2
Diffstat (limited to 'shared/standardPaths.cpp')
-rw-r--r-- | shared/standardPaths.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/shared/standardPaths.cpp b/shared/standardPaths.cpp new file mode 100644 index 00000000..0c333598 --- /dev/null +++ b/shared/standardPaths.cpp @@ -0,0 +1,60 @@ +#include "standardPaths.h" +#include <wx/stdpaths.h> +#include "globalFunctions.h" +#include <wx/filename.h> + + +wxString assembleFileForUserData(const wxString fileName) +{ + static const bool isPortableVersion = !wxFileExists(FreeFileSync::getInstallationDir() + globalFunctions::FILE_NAME_SEPARATOR + wxT("uninstall.exe")); //this check is a bit lame... + + if (isPortableVersion) //use same directory as executable + return FreeFileSync::getInstallationDir() + globalFunctions::FILE_NAME_SEPARATOR + fileName; + else //usen OS' standard paths + { + wxString userDirectory = wxStandardPathsBase::Get().GetUserDataDir(); + + if (!userDirectory.EndsWith(wxString(globalFunctions::FILE_NAME_SEPARATOR))) + userDirectory += globalFunctions::FILE_NAME_SEPARATOR; + + if (!wxDirExists(userDirectory)) + ::wxMkdir(userDirectory); //only top directory needs to be created: no recursion necessary + + return userDirectory + fileName; + } +} + + +const wxString& FreeFileSync::getGlobalConfigFile() +{ + static wxString instance = assembleFileForUserData(wxT("GlobalSettings.xml")); + return instance; +} + + +const wxString& FreeFileSync::getDefaultLogDirectory() +{ + static wxString instance = assembleFileForUserData(wxT("Logs")); + return instance; +} + + +const wxString& FreeFileSync::getLastErrorTxtFile() +{ + static wxString instance = assembleFileForUserData(wxT("LastError.txt")); + return instance; +} + + +const wxString& FreeFileSync::getInstallationDir() +{ + static wxString instance = wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath(); + return instance; +} + + +const wxString& FreeFileSync::getConfigDir() +{ + static wxString instance = assembleFileForUserData(wxEmptyString); + return instance; +} |