summaryrefslogtreecommitdiff
path: root/structures.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:00:17 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:00:17 +0200
commitfd0853d2623dd278b08288331ed42e3be59252fb (patch)
treea7645daeaef8bdbed064faf4eb88e72cee58726c /structures.cpp
parent2.1 (diff)
downloadFreeFileSync-fd0853d2623dd278b08288331ed42e3be59252fb.tar.gz
FreeFileSync-fd0853d2623dd278b08288331ed42e3be59252fb.tar.bz2
FreeFileSync-fd0853d2623dd278b08288331ed42e3be59252fb.zip
2.2
Diffstat (limited to 'structures.cpp')
-rw-r--r--structures.cpp154
1 files changed, 47 insertions, 107 deletions
diff --git a/structures.cpp b/structures.cpp
index 6744a263..90dd0747 100644
--- a/structures.cpp
+++ b/structures.cpp
@@ -1,116 +1,56 @@
#include "structures.h"
-#include "library/fileHandling.h"
+#include "shared/fileHandling.h"
#include <wx/intl.h>
-#include <wx/stdpaths.h>
-#include <wx/filename.h>
+#include "shared/globalFunctions.h"
-using namespace FreeFileSync;
-
-#ifdef FFS_WIN
-const wxChar FreeFileSync::FILE_NAME_SEPARATOR = '\\';
-#elif defined FFS_LINUX
-const wxChar FreeFileSync::FILE_NAME_SEPARATOR = '/';
-#else
-assert(false);
-#endif
-
-//these two global variables are language-dependent => cannot be set constant! See CustomLocale
-const wxChar* FreeFileSync::DECIMAL_POINT = wxEmptyString;
-const wxChar* FreeFileSync::THOUSANDS_SEPARATOR = wxEmptyString;
+FreeFileSync::MainConfiguration::MainConfiguration() :
+ compareVar(CMP_BY_TIME_SIZE),
+ filterIsActive(false), //do not filter by default
+ includeFilter(wxT("*")), //include all files/folders
+ excludeFilter(wxEmptyString), //exclude nothing
+ handleDeletion(FreeFileSync::recycleBinExists() ? MOVE_TO_RECYCLE_BIN : DELETE_PERMANENTLY) {} //enable if OS supports it; else user will have to activate first and then get an error message
-wxString assembleFileForUserData(const wxString fileName)
+wxString FreeFileSync::getVariantName(CompareVariant var)
{
- static const bool isPortableVersion = !wxFileExists(wxT("uninstall.exe")); //this check is a bit lame...
-
- if (isPortableVersion) //use same directory as executable
- return getInstallationDir() + FILE_NAME_SEPARATOR + fileName;
- else //usen OS' standard paths
+ switch (var)
{
- wxString userDirectory = wxStandardPathsBase::Get().GetUserDataDir();
-
- if (!userDirectory.EndsWith(wxString(FreeFileSync::FILE_NAME_SEPARATOR)))
- userDirectory += FreeFileSync::FILE_NAME_SEPARATOR;
-
- if (!wxDirExists(userDirectory))
- try
- {
- FreeFileSync::createDirectory(userDirectory.c_str(), wxEmptyString, false);
- }
- catch (FreeFileSync::FileError&)
- {}
-
- return userDirectory + fileName;
+ case CMP_BY_CONTENT:
+ return _("File content");
+ case CMP_BY_TIME_SIZE:
+ return _("File size and date");
}
-}
-
-
-//save user configuration in OS' standard application folders
-const wxString& FreeFileSync::getLastConfigFile()
-{
- static wxString instance = assembleFileForUserData(wxT("LastRun.ffs_gui"));
- return instance;
-}
-
-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;
+ assert(false);
+ return wxEmptyString;
}
-const wxString& FreeFileSync::getInstallationDir()
-{
- static wxString instance = wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath();
- return instance;
-}
-
-
-MainConfiguration::MainConfiguration() :
- compareVar(CMP_BY_TIME_SIZE),
- filterIsActive(false), //do not filter by default
- includeFilter(wxT("*")), //include all files/folders
- excludeFilter(wxEmptyString), //exclude nothing
- useRecycleBin(FreeFileSync::recycleBinExists()) {} //enable if OS supports it; else user will have to activate first and then get an error message
+using FreeFileSync::SyncConfiguration;
SyncConfiguration::Variant SyncConfiguration::getVariant()
{
- if ( exLeftSideOnly == SYNC_DIR_RIGHT &&
- exRightSideOnly == SYNC_DIR_RIGHT &&
- leftNewer == SYNC_DIR_RIGHT &&
- rightNewer == SYNC_DIR_RIGHT &&
- different == SYNC_DIR_RIGHT)
+ if ( exLeftSideOnly == SYNC_DIR_CFG_RIGHT &&
+ exRightSideOnly == SYNC_DIR_CFG_RIGHT &&
+ leftNewer == SYNC_DIR_CFG_RIGHT &&
+ rightNewer == SYNC_DIR_CFG_RIGHT &&
+ different == SYNC_DIR_CFG_RIGHT)
return MIRROR; //one way ->
- else if (exLeftSideOnly == SYNC_DIR_RIGHT &&
- exRightSideOnly == SYNC_DIR_NONE &&
- leftNewer == SYNC_DIR_RIGHT &&
- rightNewer == SYNC_DIR_NONE &&
- different == SYNC_DIR_NONE)
+ else if (exLeftSideOnly == SYNC_DIR_CFG_RIGHT &&
+ exRightSideOnly == SYNC_DIR_CFG_NONE &&
+ leftNewer == SYNC_DIR_CFG_RIGHT &&
+ rightNewer == SYNC_DIR_CFG_NONE &&
+ different == SYNC_DIR_CFG_NONE)
return UPDATE; //Update ->
- else if (exLeftSideOnly == SYNC_DIR_RIGHT &&
- exRightSideOnly == SYNC_DIR_LEFT &&
- leftNewer == SYNC_DIR_RIGHT &&
- rightNewer == SYNC_DIR_LEFT &&
- different == SYNC_DIR_NONE)
+ else if (exLeftSideOnly == SYNC_DIR_CFG_RIGHT &&
+ exRightSideOnly == SYNC_DIR_CFG_LEFT &&
+ leftNewer == SYNC_DIR_CFG_RIGHT &&
+ rightNewer == SYNC_DIR_CFG_LEFT &&
+ different == SYNC_DIR_CFG_NONE)
return TWOWAY; //two way <->
else
return CUSTOM; //other
@@ -140,25 +80,25 @@ void SyncConfiguration::setVariant(const Variant var)
switch (var)
{
case MIRROR:
- exLeftSideOnly = SYNC_DIR_RIGHT;
- exRightSideOnly = SYNC_DIR_RIGHT;
- leftNewer = SYNC_DIR_RIGHT;
- rightNewer = SYNC_DIR_RIGHT;
- different = SYNC_DIR_RIGHT;
+ exLeftSideOnly = SYNC_DIR_CFG_RIGHT;
+ exRightSideOnly = SYNC_DIR_CFG_RIGHT;
+ leftNewer = SYNC_DIR_CFG_RIGHT;
+ rightNewer = SYNC_DIR_CFG_RIGHT;
+ different = SYNC_DIR_CFG_RIGHT;
break;
case UPDATE:
- exLeftSideOnly = SYNC_DIR_RIGHT;
- exRightSideOnly = SYNC_DIR_NONE;
- leftNewer = SYNC_DIR_RIGHT;
- rightNewer = SYNC_DIR_NONE;
- different = SYNC_DIR_NONE;
+ exLeftSideOnly = SYNC_DIR_CFG_RIGHT;
+ exRightSideOnly = SYNC_DIR_CFG_NONE;
+ leftNewer = SYNC_DIR_CFG_RIGHT;
+ rightNewer = SYNC_DIR_CFG_NONE;
+ different = SYNC_DIR_CFG_NONE;
break;
case TWOWAY:
- exLeftSideOnly = SYNC_DIR_RIGHT;
- exRightSideOnly = SYNC_DIR_LEFT;
- leftNewer = SYNC_DIR_RIGHT;
- rightNewer = SYNC_DIR_LEFT;
- different = SYNC_DIR_NONE;
+ exLeftSideOnly = SYNC_DIR_CFG_RIGHT;
+ exRightSideOnly = SYNC_DIR_CFG_LEFT;
+ leftNewer = SYNC_DIR_CFG_RIGHT;
+ rightNewer = SYNC_DIR_CFG_LEFT;
+ different = SYNC_DIR_CFG_NONE;
break;
case CUSTOM:
assert(false);
bgstack15