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 /shared/file_id.cpp | |
parent | 4.0 (diff) | |
download | FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.gz FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.bz2 FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.zip |
4.1
Diffstat (limited to 'shared/file_id.cpp')
-rw-r--r-- | shared/file_id.cpp | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/shared/file_id.cpp b/shared/file_id.cpp deleted file mode 100644 index 198598b4..00000000 --- a/shared/file_id.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// ************************************************************************** -// * 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) * -// ************************************************************************** - -#include "file_id.h" -#include "file_id_internal.h" - -#ifdef FFS_WIN -#include <wx/msw/wrapwin.h> //includes "windows.h" -#include "long_path_prefix.h" -#include "loki/ScopeGuard.h" - -#elif defined FFS_LINUX -#include <sys/stat.h> -#endif - - -std::string util::retrieveFileID(const Zstring& filename) -{ -#ifdef FFS_WIN - //WARNING: CreateFile() is SLOW, while GetFileInformationByHandle() is cheap! - //http://msdn.microsoft.com/en-us/library/aa363788(VS.85).aspx - - //privilege SE_BACKUP_NAME doesn't seem to be required here at all - - const HANDLE hFile = ::CreateFile(zen::applyLongPathPrefix(filename).c_str(), - 0, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - 0, - OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, //FILE_FLAG_BACKUP_SEMANTICS needed to open a directory - NULL); - if (hFile != INVALID_HANDLE_VALUE) - { - LOKI_ON_BLOCK_EXIT2(::CloseHandle(hFile)); - - BY_HANDLE_FILE_INFORMATION fileInfo = {}; - if (::GetFileInformationByHandle(hFile, &fileInfo)) - return extractFileID(fileInfo); - } - -#elif defined FFS_LINUX - struct stat fileInfo = {}; - if (::lstat(filename.c_str(), &fileInfo) == 0) //lstat() does not follow symlinks - return extractFileID(fileInfo); -#endif - - assert(false); - return std::string(); -} - - -bool util::sameFileSpecified(const Zstring& file1, const Zstring& file2) -{ - if (EqualFilename()(file1, file2)) //quick check - return true; - - const std::string id1 = retrieveFileID(file1); - const std::string id2 = retrieveFileID(file2); - - if (id1.empty() || id2.empty()) - return false; - - return id1 == id2; -} |