diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:16 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:16 +0200 |
commit | bd6336c629841c6db3a6ca53a936d629d34db53b (patch) | |
tree | 3721ef997864108df175ce677a8a7d4342a6f1d2 /zen/file_id_internal.h | |
parent | 4.0 (diff) | |
download | FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.gz FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.bz2 FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.zip |
4.1
Diffstat (limited to 'zen/file_id_internal.h')
-rw-r--r-- | zen/file_id_internal.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/zen/file_id_internal.h b/zen/file_id_internal.h new file mode 100644 index 00000000..492d8432 --- /dev/null +++ b/zen/file_id_internal.h @@ -0,0 +1,48 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef FILE_ID_INTERNAL_HEADER_013287632486321493 +#define FILE_ID_INTERNAL_HEADER_013287632486321493 + +#include <string> + +#ifdef FFS_WIN +#include "win.h" //includes "windows.h" + +#elif defined FFS_LINUX +#include <sys/stat.h> +#endif + +namespace +{ +template <class T> inline +std::string numberToBytes(T number) +{ + const char* rawBegin = reinterpret_cast<const char*>(&number); + return std::string(rawBegin, rawBegin + sizeof(number)); +} + +#ifdef FFS_WIN +inline +std::string extractFileID(const BY_HANDLE_FILE_INFORMATION& fileInfo) +{ + return numberToBytes(fileInfo.dwVolumeSerialNumber) + + numberToBytes(fileInfo.nFileIndexHigh) + + numberToBytes(fileInfo.nFileIndexLow); +} +#elif defined FFS_LINUX +inline +std::string extractFileID(const struct stat& fileInfo) +{ + return numberToBytes(fileInfo.st_dev) + + numberToBytes(fileInfo.st_ino); +} +#endif + +} + + +#endif //FILE_ID_INTERNAL_HEADER_013287632486321493 |