summaryrefslogtreecommitdiff
path: root/lib/db_file.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/db_file.h')
-rw-r--r--lib/db_file.h59
1 files changed, 39 insertions, 20 deletions
diff --git a/lib/db_file.h b/lib/db_file.h
index 181a433e..b352ba5d 100644
--- a/lib/db_file.h
+++ b/lib/db_file.h
@@ -4,8 +4,8 @@
// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *
// **************************************************************************
-#ifndef DBFILE_H_INCLUDED
-#define DBFILE_H_INCLUDED
+#ifndef DBFILE_H_834275398588021574
+#define DBFILE_H_834275398588021574
#include <zen/file_error.h>
#include "../file_hierarchy.h"
@@ -20,31 +20,50 @@ enum InSyncType
IN_SYNC_ATTRIBUTES_EQUAL, //only "looks" like they're equal
};
+struct InSyncDescrFile //subset of FileDescriptor
+{
+ InSyncDescrFile(const Int64& lastWriteTimeRawIn,
+ const FileId& idIn) :
+ lastWriteTimeRaw(lastWriteTimeRawIn),
+ fileId(idIn) {}
+
+ Int64 lastWriteTimeRaw;
+ FileId fileId; // == file id: optional! (however, always set on Linux, and *generally* available on Windows)
+};
+
+struct InSyncDescrLink
+{
+ explicit InSyncDescrLink(const Int64& lastWriteTimeRawIn) : lastWriteTimeRaw(lastWriteTimeRawIn) {}
+ Int64 lastWriteTimeRaw;
+};
+
+
//artificial hierarchy of last synchronous state:
struct InSyncFile
{
- InSyncFile(const FileDescriptor& l, const FileDescriptor& r, InSyncType type) : left(l), right(r), inSyncType(type) {}
- FileDescriptor left;
- FileDescriptor right;
+ InSyncFile(const InSyncDescrFile& l, const InSyncDescrFile& r, InSyncType type, const UInt64& fileSizeIn) : left(l), right(r), inSyncType(type), fileSize(fileSizeIn) {}
+ InSyncDescrFile left;
+ InSyncDescrFile right;
InSyncType inSyncType;
+ UInt64 fileSize; //file size must be identical on both sides!
};
struct InSyncSymlink
{
- InSyncSymlink(const LinkDescriptor& l, const LinkDescriptor& r, InSyncType type) : left(l), right(r), inSyncType(type) {}
- LinkDescriptor left;
- LinkDescriptor right;
+ InSyncSymlink(const InSyncDescrLink& l, const InSyncDescrLink& r, InSyncType type) : left(l), right(r), inSyncType(type) {}
+ InSyncDescrLink left;
+ InSyncDescrLink right;
InSyncType inSyncType;
};
struct InSyncDir
{
- //for directories we have a logical problem: we cannot have "not existent" as an indicator for "no last synchronous state" since this precludes
- //child elements that may be in sync!
+ //for directories we have a logical problem: we cannot have "not existent" as an indicator for
+ //"no last synchronous state" since this precludes child elements that may be in sync!
enum InSyncStatus
{
- STATUS_IN_SYNC,
- STATUS_STRAW_MAN //there is no last synchronous state, but used as container only
+ DIR_STATUS_IN_SYNC,
+ DIR_STATUS_STRAW_MAN //there is no last synchronous state, but used as container only
};
InSyncDir(InSyncStatus statusIn) : status(statusIn) {}
@@ -61,18 +80,18 @@ struct InSyncDir
LinkList symlinks; //non-followed symlinks
//convenience
- InSyncDir& addDir(const Zstring& shortName, InSyncStatus statusIn)
+ InSyncDir& addDir(const Zstring& shortName, InSyncStatus st)
{
//use C++11 emplace when available
- return dirs.insert(std::make_pair(shortName, InSyncDir(statusIn))).first->second;
+ return dirs.insert(std::make_pair(shortName, InSyncDir(st))).first->second;
}
- void addFile(const Zstring& shortName, const FileDescriptor& dataL, const FileDescriptor& dataR, InSyncType type)
+ void addFile(const Zstring& shortName, const InSyncDescrFile& dataL, const InSyncDescrFile& dataR, InSyncType type, const UInt64& fileSize)
{
- files.insert(std::make_pair(shortName, InSyncFile(dataL, dataR, type)));
+ files.insert(std::make_pair(shortName, InSyncFile(dataL, dataR, type, fileSize)));
}
- void addSymlink(const Zstring& shortName, const LinkDescriptor& dataL, const LinkDescriptor& dataR, InSyncType type)
+ void addSymlink(const Zstring& shortName, const InSyncDescrLink& dataL, const InSyncDescrLink& dataR, InSyncType type)
{
symlinks.insert(std::make_pair(shortName, InSyncSymlink(dataL, dataR, type)));
}
@@ -81,9 +100,9 @@ struct InSyncDir
DEFINE_NEW_FILE_ERROR(FileErrorDatabaseNotExisting);
-std::shared_ptr<InSyncDir> loadLastSynchronousState(const BaseDirMapping& baseMapping); //throw FileError, FileErrorDatabaseNotExisting -> return value always bound!
+std::shared_ptr<InSyncDir> loadLastSynchronousState(const BaseDirPair& baseDirObj); //throw FileError, FileErrorDatabaseNotExisting -> return value always bound!
-void saveLastSynchronousState(const BaseDirMapping& baseMapping); //throw FileError
+void saveLastSynchronousState(const BaseDirPair& baseDirObj); //throw FileError
}
-#endif //DBFILE_H_INCLUDED
+#endif //DBFILE_H_834275398588021574
bgstack15