diff options
author | Daniel Wilhelm <daniel@wili.li> | 2016-05-24 22:10:57 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2016-05-24 22:10:57 +0200 |
commit | 9043b32bb1835628c5a1d8be4a271c848443c629 (patch) | |
tree | 98ccb4936562731d9cae02a486441dfd446e8a4e /zen/file_id_def.h | |
parent | 8.0 (diff) | |
download | FreeFileSync-9043b32bb1835628c5a1d8be4a271c848443c629.tar.gz FreeFileSync-9043b32bb1835628c5a1d8be4a271c848443c629.tar.bz2 FreeFileSync-9043b32bb1835628c5a1d8be4a271c848443c629.zip |
8.1
Diffstat (limited to 'zen/file_id_def.h')
-rw-r--r-- | zen/file_id_def.h | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/zen/file_id_def.h b/zen/file_id_def.h index 24e45795..2880121c 100644 --- a/zen/file_id_def.h +++ b/zen/file_id_def.h @@ -20,12 +20,28 @@ namespace zen { #ifdef ZEN_WIN -typedef DWORD DeviceId; -typedef ULONGLONG FileIndex; +using VolumeId = DWORD; +using FileIndex = ULONGLONG; -typedef std::pair<DeviceId, FileIndex> FileId; //optional! (however, always set on Linux, and *generally* available on Windows) +#elif defined ZEN_LINUX || defined ZEN_MAC +namespace impl { typedef struct ::stat StatDummy; } //sigh... + +using VolumeId = decltype(impl::StatDummy::st_dev); +using FileIndex = decltype(impl::StatDummy::st_ino); +#endif + + +struct FileId //always available on Linux, and *generally* available on Windows) +{ + FileId() {} + FileId(VolumeId volId, FileIndex fIdx) : volumeId(volId), fileIndex(fIdx) {} + VolumeId volumeId = 0; + FileIndex fileIndex = 0; +}; +inline bool operator==(const FileId& lhs, const FileId& rhs) { return lhs.volumeId == rhs.volumeId && lhs.fileIndex == rhs.fileIndex; } +#ifdef ZEN_WIN inline FileId extractFileId(const BY_HANDLE_FILE_INFORMATION& fileInfo) { @@ -44,19 +60,11 @@ FileId extractFileId(DWORD volumeSerialNumber, ULONGLONG fileIndex) FileId(volumeSerialNumber, fileIndex) : FileId(); } -static_assert(sizeof(FileId().first ) == sizeof(BY_HANDLE_FILE_INFORMATION().dwVolumeSerialNumber), ""); -static_assert(sizeof(FileId().second) == sizeof(BY_HANDLE_FILE_INFORMATION().nFileIndexHigh) + sizeof(BY_HANDLE_FILE_INFORMATION().nFileIndexLow), ""); -static_assert(sizeof(FileId().second) == sizeof(ULARGE_INTEGER), ""); - +static_assert(sizeof(FileId().volumeId ) == sizeof(BY_HANDLE_FILE_INFORMATION().dwVolumeSerialNumber), ""); +static_assert(sizeof(FileId().fileIndex) == sizeof(BY_HANDLE_FILE_INFORMATION().nFileIndexHigh) + sizeof(BY_HANDLE_FILE_INFORMATION().nFileIndexLow), ""); +static_assert(sizeof(FileId().fileIndex) == sizeof(ULARGE_INTEGER), ""); #elif defined ZEN_LINUX || defined ZEN_MAC -namespace impl { typedef struct ::stat StatDummy; } //sigh... - -typedef decltype(impl::StatDummy::st_dev) DeviceId; -typedef decltype(impl::StatDummy::st_ino) FileIndex; - -typedef std::pair<DeviceId, FileIndex> FileId; - inline FileId extractFileId(const struct ::stat& fileInfo) { |