From 9321c6bdfc559db6cf436d4ea88198983ce59846 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 2 Oct 2015 14:53:55 +0200 Subject: 6.12 --- zen/async_task.h | 2 +- zen/basic_math.h | 18 +++++-- zen/build_info.h | 2 +- zen/deprecate.h | 8 ++-- zen/dir_watcher.cpp | 18 +++---- zen/dir_watcher.h | 2 +- zen/dll.h | 121 ----------------------------------------------- zen/error_log.h | 2 +- zen/file_access.cpp | 70 +++++++-------------------- zen/file_access.h | 2 +- zen/file_error.h | 2 +- zen/file_id_def.h | 6 +-- zen/file_io.cpp | 14 +++--- zen/file_io.h | 16 +++---- zen/file_io_base.h | 2 +- zen/file_traverser.cpp | 22 ++++----- zen/file_traverser.h | 2 +- zen/fixed_list.h | 10 +++- zen/format_unit.cpp | 10 ++-- zen/format_unit.h | 2 +- zen/guid.h | 10 ++-- zen/i18n.h | 10 ++-- zen/int64.h | 4 +- zen/long_path_prefix.h | 2 +- zen/notify_removal.cpp | 2 +- zen/notify_removal.h | 2 +- zen/optional.h | 2 +- zen/perf.h | 6 +-- zen/process_priority.cpp | 8 ++-- zen/process_priority.h | 2 +- zen/recycler.cpp | 20 ++++---- zen/recycler.h | 2 +- zen/scope_guard.h | 2 +- zen/serialize.h | 42 ++++++++-------- zen/shell_execute.h | 10 ++-- zen/stl_tools.h | 6 +-- zen/string_base.h | 20 ++++---- zen/string_tools.h | 2 +- zen/string_traits.h | 10 ++-- zen/symlink_target.h | 18 +++---- zen/sys_error.h | 14 +++--- zen/thread.h | 28 +++++------ zen/tick_count.h | 8 ++-- zen/time.h | 2 +- zen/type_tools.h | 2 +- zen/type_traits.h | 2 +- zen/utf.h | 2 +- zen/warn_static.h | 2 +- zen/win.h | 22 ++++----- zen/win_ver.h | 31 +++++++++++- zen/xml_io.cpp | 2 +- zen/xml_io.h | 2 +- zen/zstring.cpp | 23 +++++---- zen/zstring.h | 18 +++---- 54 files changed, 280 insertions(+), 389 deletions(-) delete mode 100644 zen/dll.h (limited to 'zen') diff --git a/zen/async_task.h b/zen/async_task.h index f9bea890..b8d72fbe 100644 --- a/zen/async_task.h +++ b/zen/async_task.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/basic_math.h b/zen/basic_math.h index 41f42dbe..9a3d195e 100644 --- a/zen/basic_math.h +++ b/zen/basic_math.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -42,7 +42,10 @@ auto nearMatch(const T& val, InputIterator first, InputIterator last) -> typenam template bool isNull(T value); -int round(double d); //little rounding function +int round(double d); //"little rounding function" + +template +N integerDivideRoundUp(N numerator, N denominator); template T power(const T& value); @@ -98,7 +101,7 @@ const double ln2 = 0.693147180559945309417; template inline T abs(T value) { - //static_assert(std::is_signed::value, ""); might not compile for non-built-in arithmetic types; anyway "-value" should emit compiler error or warning for unsigned types + static_assert(std::is_signed::value, ""); if (value < 0) return -value; // operator "?:" caveat: may be different type than "value" else @@ -234,6 +237,15 @@ int round(double d) } +template inline +N integerDivideRoundUp(N numerator, N denominator) +{ + static_assert(std::is_unsigned::value, ""); + assert(denominator > 0); + return (numerator + denominator - 1) / denominator; +} + + namespace { template diff --git a/zen/build_info.h b/zen/build_info.h index 406fef70..4eeb8195 100644 --- a/zen/build_info.h +++ b/zen/build_info.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/deprecate.h b/zen/deprecate.h index 56f8e27c..49d8386b 100644 --- a/zen/deprecate.h +++ b/zen/deprecate.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -9,13 +9,13 @@ //compiler macros: http://predef.sourceforge.net/precomp.html #ifdef __GNUC__ -#define ZEN_DEPRECATE __attribute__ ((deprecated)) + #define ZEN_DEPRECATE __attribute__ ((deprecated)) #elif defined _MSC_VER -#define ZEN_DEPRECATE __declspec(deprecated) + #define ZEN_DEPRECATE __declspec(deprecated) #else -#error add your platform here! + #error add your platform here! #endif #endif //DEPRECATE_HEADER_2348970348 diff --git a/zen/dir_watcher.cpp b/zen/dir_watcher.cpp index 9a685fc5..916f6c69 100644 --- a/zen/dir_watcher.cpp +++ b/zen/dir_watcher.cpp @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -11,18 +11,18 @@ #include "scope_guard.h" #ifdef ZEN_WIN -#include "notify_removal.h" -#include "win.h" //includes "windows.h" -#include "long_path_prefix.h" + #include "notify_removal.h" + #include "win.h" //includes "windows.h" + #include "long_path_prefix.h" #elif defined ZEN_LINUX -#include -#include -#include "file_traverser.h" + #include + #include + #include "file_traverser.h" #elif defined ZEN_MAC -#include -#include "osx_string.h" + #include + #include "osx_string.h" #endif using namespace zen; diff --git a/zen/dir_watcher.h b/zen/dir_watcher.h index 99131470..b5255898 100644 --- a/zen/dir_watcher.h +++ b/zen/dir_watcher.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/dll.h b/zen/dll.h deleted file mode 100644 index f6422fa7..00000000 --- a/zen/dll.h +++ /dev/null @@ -1,121 +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) Zenju (zenju AT gmx DOT de) - All Rights Reserved * -// ************************************************************************** - -#ifndef DLLLOADER_H_4239582598670968 -#define DLLLOADER_H_4239582598670968 - -#include -#ifdef ZEN_WIN -#include -#include "scope_guard.h" -#include "win.h" //includes "windows.h" - -#elif defined ZEN_LINUX || defined ZEN_MAC -#include -#endif - -namespace zen -{ -/* -Manage DLL function and library ownership - - thread safety: like built-in type - - full value semantics - - Usage: - typedef BOOL (WINAPI* FunType_IsWow64Process)(HANDLE hProcess, PBOOL Wow64Process); - const zen::SysDllFun isWow64Process(L"kernel32.dll", "IsWow64Process"); - if (isWow64Process) ... use function ptr ... - - Usage 2: - #define DEF_DLL_FUN(name) DllFun name(dll_ns::getDllName(), dll_ns::funName_##name); - DEF_DLL_FUN(funname1); DEF_DLL_FUN(funname2); DEF_DLL_FUN(funname3); -*/ - -template -class DllFun -{ -public: - DllFun() : fun(nullptr) {} - -#ifdef ZEN_WIN - DllFun(const wchar_t* libraryName, const char* functionName) : - hLibRef(::LoadLibrary(libraryName), ::FreeLibrary), - fun(hLibRef ? reinterpret_cast(::GetProcAddress(static_cast(hLibRef.get()), functionName)) : nullptr) {} -#elif defined ZEN_LINUX || defined ZEN_MAC - DllFun(const char* libraryName, const char* functionName) : - hLibRef(::dlopen(libraryName, RTLD_LAZY), ::dlclose), - fun(hLibRef ? reinterpret_cast(::dlsym(hLibRef.get(), functionName)) : nullptr) {} -#endif - operator Func() const { return fun; } - -private: - std::shared_ptr hLibRef; //we would prefer decltype(*HMODULE()) if only it would work... - Func fun; -}; - - -#ifdef ZEN_WIN -//if the dll is already part of the process space, e.g. "kernel32.dll" or "shell32.dll", we can use a faster variant: -//NOTE: since the lifetime of the referenced library is *not* controlled, this is safe to use only for permanently loaded libraries like these! -template -class SysDllFun -{ -public: - SysDllFun() : fun(nullptr) {} - - SysDllFun(const wchar_t* systemLibrary, const char* functionName) - { - HMODULE mod = ::GetModuleHandle(systemLibrary); - fun = mod ? reinterpret_cast(::GetProcAddress(mod, functionName)) : nullptr; - } - - operator Func() const { return fun; } - -private: - Func fun; -}; - -/* -extract binary resources from .exe/.dll: - --- resource.h -- -#define MY_BINARY_RESOURCE 1337 - --- resource.rc -- -MY_BINARY_RESOURCE RCDATA "filename.dat" -*/ -std::string getResourceStream(const std::wstring& libraryName, size_t resourceId); -#endif - - - - - - - - - - -//--------------- implementation--------------------------------------------------- -#ifdef ZEN_WIN -inline -std::string getResourceStream(const wchar_t* libraryName, size_t resourceId) -{ - if (HMODULE module = ::LoadLibrary(libraryName)) - { - ZEN_ON_SCOPE_EXIT(::FreeLibrary(module)); - - if (HRSRC res = ::FindResource(module, MAKEINTRESOURCE(resourceId), RT_RCDATA)) - if (HGLOBAL resHandle = ::LoadResource(module, res)) - if (const char* stream = static_cast(::LockResource(resHandle))) - return std::string(stream, static_cast(::SizeofResource(module, res))); //size is 0 on error - } - return std::string(); -} -#endif -} - -#endif //DLLLOADER_H_4239582598670968 diff --git a/zen/error_log.h b/zen/error_log.h index de4d3c9e..9814ec23 100644 --- a/zen/error_log.h +++ b/zen/error_log.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/file_access.cpp b/zen/file_access.cpp index c4768dd2..7a77b998 100644 --- a/zen/file_access.cpp +++ b/zen/file_access.cpp @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -16,27 +16,27 @@ #include "file_id_def.h" #ifdef ZEN_WIN -#include -#include "privilege.h" -#include "dll.h" -#include "long_path_prefix.h" -#include "win_ver.h" -#include "IFileOperation/file_op.h" + #include + #include "privilege.h" + #include "dll.h" + #include "long_path_prefix.h" + #include "win_ver.h" + #include "IFileOperation/file_op.h" #elif defined ZEN_LINUX -#include //statfs -#include //AT_SYMLINK_NOFOLLOW, UTIME_OMIT -#ifdef HAVE_SELINUX -#include -#endif + #include //statfs + #include //AT_SYMLINK_NOFOLLOW, UTIME_OMIT + #ifdef HAVE_SELINUX + #include + #endif #elif defined ZEN_MAC -#include //statfs + #include //statfs #endif #if defined ZEN_LINUX || defined ZEN_MAC -#include -#include //lutimes + #include + #include //lutimes #endif using namespace zen; @@ -756,8 +756,6 @@ void setFileTimeRaw(const Zstring& filepath, ZEN_ON_SCOPE_EXIT(::CloseHandle(hFile)); - auto isNullTime = [](const FILETIME& ft) { return ft.dwLowDateTime == 0 && ft.dwHighDateTime == 0; }; - if (!::SetFileTime(hFile, //__in HANDLE hFile, creationTime, //__in_opt const FILETIME *lpCreationTime, nullptr, //__in_opt const FILETIME *lpLastAccessTime, @@ -1438,7 +1436,7 @@ void zen::copySymlink(const Zstring& sourceLink, const Zstring& targetLink, bool if (!createSymbolicLink) throw FileError(replaceCpy(replaceCpy(_("Cannot copy symbolic link %x to %y."), L"%x", L"\n" + fmtFileName(sourceLink)), L"%y", L"\n" + fmtFileName(targetLink)), - replaceCpy(_("Cannot find system function %x."), L"%x", L"\"CreateSymbolicLinkW\"")); + replaceCpy(_("Cannot find system function %x."), L"%x", L"\"CreateSymbolicLinkW\"")); const wchar_t functionName[] = L"CreateSymbolicLinkW"; if (!createSymbolicLink(targetLink.c_str(), //__in LPTSTR lpSymlinkFileName, - seems no long path prefix is required... @@ -1744,7 +1742,7 @@ void copyFileWindowsSparse(const Zstring& sourceFile, LPVOID contextWrite = nullptr; // ZEN_ON_SCOPE_EXIT( - if (contextRead ) ::BackupRead (0, nullptr, 0, nullptr, true, false, &contextRead); //lpContext must be passed [...] all other parameters are ignored. + if (contextRead ) ::BackupRead (0, nullptr, 0, nullptr, true, false, &contextRead); //MSDN: "lpContext must be passed [...] all other parameters are ignored." if (contextWrite) ::BackupWrite(0, nullptr, 0, nullptr, true, false, &contextWrite); ); //stream-copy sourceFile to targetFile @@ -1792,8 +1790,6 @@ void copyFileWindowsSparse(const Zstring& sourceFile, } while (!eof); - //DST hack not required, since both source and target volumes cannot be FAT! - //::BackupRead() silently fails reading encrypted files -> double check! if (!someBytesWritten && get64BitUInt(fileInfoSource.nFileSizeLow, fileInfoSource.nFileSizeHigh) != 0U) //note: there is no guaranteed ordering relation beween bytes transferred and file size! Consider ADS (>) and compressed/sparse files (<)! @@ -1807,38 +1803,6 @@ void copyFileWindowsSparse(const Zstring& sourceFile, throwFileError(replaceCpy(_("Cannot write modification time of %x."), L"%x", fmtFileName(targetFile)), L"SetFileTime", getLastError()); guardTarget.dismiss(); - - /* - //create sparse file for testing: - HANDLE hSparse = ::CreateFile(L"C:\\sparse.file", - GENERIC_READ | GENERIC_WRITE, //read access required for FSCTL_SET_COMPRESSION - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - nullptr, - CREATE_NEW, - FILE_FLAG_SEQUENTIAL_SCAN, - nullptr); - if (hFileTarget == INVALID_HANDLE_VALUE) - throw FileError(L"fail"); - ZEN_ON_SCOPE_EXIT(::CloseHandle(hSparse)); - - DWORD br = 0; - if (!::DeviceIoControl(hSparse, FSCTL_SET_SPARSE, nullptr, 0, nullptr, 0, &br,nullptr)) - throw FileError(L"fail"); - - LARGE_INTEGER liDistanceToMove = {}; - liDistanceToMove.QuadPart = 1024 * 1024 * 1024; //create 5 TB sparse file - liDistanceToMove.QuadPart *= 5 * 1024; //maximum file size on NTFS: 16 TB - 64 kB - if (!::SetFilePointerEx(hSparse, liDistanceToMove, nullptr, FILE_BEGIN)) - throw FileError(L"fail"); - - if (!SetEndOfFile(hSparse)) - throw FileError(L"fail"); - - FILE_ZERO_DATA_INFORMATION zeroInfo = {}; - zeroInfo.BeyondFinalZero.QuadPart = liDistanceToMove.QuadPart; - if (!::DeviceIoControl(hSparse, FSCTL_SET_ZERO_DATA, &zeroInfo, sizeof(zeroInfo), nullptr, 0, &br, nullptr)) - throw FileError(L"fail"); - */ } diff --git a/zen/file_access.h b/zen/file_access.h index 7cac889c..4a36009d 100644 --- a/zen/file_access.h +++ b/zen/file_access.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/file_error.h b/zen/file_error.h index 9276e8c5..4ba05107 100644 --- a/zen/file_error.h +++ b/zen/file_error.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/file_id_def.h b/zen/file_id_def.h index 3b217b3d..a96e978b 100644 --- a/zen/file_id_def.h +++ b/zen/file_id_def.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -10,10 +10,10 @@ #include #ifdef ZEN_WIN -#include "win.h" //includes "windows.h" + #include "win.h" //includes "windows.h" #elif defined ZEN_LINUX || defined ZEN_MAC -#include + #include #endif diff --git a/zen/file_io.cpp b/zen/file_io.cpp index 8f4b6cb2..c56d6ac0 100644 --- a/zen/file_io.cpp +++ b/zen/file_io.cpp @@ -1,20 +1,20 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "file_io.h" #ifdef ZEN_WIN -#include "long_path_prefix.h" -#include "IFileOperation/file_op.h" -#include "win_ver.h" -#include "dll.h" + #include "long_path_prefix.h" + #include "IFileOperation/file_op.h" + #include "win_ver.h" + #include "dll.h" #elif defined ZEN_LINUX || defined ZEN_MAC -#include //open, close -#include //read, write + #include //open, close + #include //read, write #endif using namespace zen; diff --git a/zen/file_io.h b/zen/file_io.h index 7ccef05b..111d7a09 100644 --- a/zen/file_io.h +++ b/zen/file_io.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -11,27 +11,27 @@ #include "file_error.h" #ifdef ZEN_WIN -#include "win.h" //includes "windows.h" + #include "win.h" //includes "windows.h" #elif defined ZEN_LINUX || defined ZEN_MAC -#include -#include + #include + #include #endif namespace zen { #ifdef ZEN_WIN -static const char LINE_BREAK[] = "\r\n"; + static const char LINE_BREAK[] = "\r\n"; #elif defined ZEN_LINUX || defined ZEN_MAC -static const char LINE_BREAK[] = "\n"; //since OS X apple uses newline, too + static const char LINE_BREAK[] = "\n"; //since OS X apple uses newline, too #endif //buffered file IO optimized for sequential read/write accesses + better error reporting + long path support + following symlinks #ifdef ZEN_WIN -typedef HANDLE FileHandle; + typedef HANDLE FileHandle; #elif defined ZEN_LINUX || defined ZEN_MAC -typedef FILE* FileHandle; + typedef FILE* FileHandle; #endif class FileInput : public FileInputBase diff --git a/zen/file_io_base.h b/zen/file_io_base.h index e56ea189..9b6b27ca 100644 --- a/zen/file_io_base.h +++ b/zen/file_io_base.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/file_traverser.cpp b/zen/file_traverser.cpp index 7b423faa..f03cf464 100644 --- a/zen/file_traverser.cpp +++ b/zen/file_traverser.cpp @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -10,20 +10,20 @@ #include "int64.h" #ifdef ZEN_WIN -#include "win_ver.h" -#include "long_path_prefix.h" -#include "file_access.h" -#include "dll.h" -#include "FindFilePlus/find_file_plus.h" + #include "win_ver.h" + #include "long_path_prefix.h" + #include "file_access.h" + #include "dll.h" + #include "FindFilePlus/find_file_plus.h" #elif defined ZEN_MAC -#include "osx_string.h" + #include "osx_string.h" #endif #if defined ZEN_LINUX || defined ZEN_MAC -#include //required by GCC 4.8.1 to find ptrdiff_t -#include -#include + #include //required by GCC 4.8.1 to find ptrdiff_t + #include + #include #endif using namespace zen; @@ -366,7 +366,7 @@ void DirTraverser::traverse(const Zstring& dirpath, TraverseC inline -DirTraverser::DirTraverser(const Zstring& baseDirectory, TraverseCallback& sink) +DirTraverser::DirTraverser(const Zstring& baseDirectory, TraverseCallback& sink) { try //traversing certain folders with restricted permissions requires this privilege! (but copying these files may still fail) { diff --git a/zen/file_traverser.h b/zen/file_traverser.h index c9efbdb1..174503b5 100644 --- a/zen/file_traverser.h +++ b/zen/file_traverser.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/fixed_list.h b/zen/fixed_list.h index 627584df..2a577f13 100644 --- a/zen/fixed_list.h +++ b/zen/fixed_list.h @@ -1,12 +1,13 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FIXED_LIST_01238467085684139453534 #define FIXED_LIST_01238467085684139453534 +#include #include namespace zen @@ -116,6 +117,13 @@ public: size_t size() const { return sz; } + void swap(FixedList& other) + { + std::swap(firstInsert, other.firstInsert); + std::swap(lastInsert , other.lastInsert); + std::swap(sz , other.sz); + } + private: FixedList (const FixedList&) = delete; FixedList& operator=(const FixedList&) = delete; diff --git a/zen/format_unit.cpp b/zen/format_unit.cpp index e251dc3c..5f529f9c 100644 --- a/zen/format_unit.cpp +++ b/zen/format_unit.cpp @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -14,12 +14,12 @@ #include #ifdef ZEN_WIN -#include "win.h" //includes "windows.h" -#include "win_ver.h" + #include "win.h" //includes "windows.h" + #include "win_ver.h" #elif defined ZEN_LINUX || defined ZEN_MAC -#include //thousands separator -#include "utf.h" // + #include //thousands separator + #include "utf.h" // #endif using namespace zen; diff --git a/zen/format_unit.h b/zen/format_unit.h index 9416e3e5..009199f6 100644 --- a/zen/format_unit.h +++ b/zen/format_unit.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/guid.h b/zen/guid.h index 83845e5c..2ebfa132 100644 --- a/zen/guid.h +++ b/zen/guid.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -11,15 +11,15 @@ #include #ifdef __GNUC__ //boost should start cleaning this mess up -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" -#pragma GCC diagnostic ignored "-Wuninitialized" + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wshadow" + #pragma GCC diagnostic ignored "-Wuninitialized" #endif #include #ifdef __GNUC__ -#pragma GCC diagnostic pop + #pragma GCC diagnostic pop #endif diff --git a/zen/i18n.h b/zen/i18n.h index bf284c7f..6c3a37c4 100644 --- a/zen/i18n.h +++ b/zen/i18n.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -15,9 +15,9 @@ //minimal layer enabling text translation - without platform/library dependencies! #ifdef __WXMSW__ //we have wxWidgets -#ifndef WXINTL_NO_GETTEXT_MACRO -#error WXINTL_NO_GETTEXT_MACRO must be defined to deactivate wxWidgets underscore macro -#endif + #ifndef WXINTL_NO_GETTEXT_MACRO + #error WXINTL_NO_GETTEXT_MACRO must be defined to deactivate wxWidgets underscore macro + #endif #endif #define ZEN_TRANS_CONCAT_SUB(X, Y) X ## Y @@ -78,7 +78,7 @@ std::wstring translate(const std::wstring& singular, const std::wstring& plural, return translation; } - return replaceCpy(std::abs(n) == 1 ? singular : plural, L"%x", toGuiString(n)); + return replaceCpy(std::abs(n) == 1 ? singular : plural, L"%x", toGuiString(n)); } template inline diff --git a/zen/int64.h b/zen/int64.h index 671f3372..bc01a4c2 100644 --- a/zen/int64.h +++ b/zen/int64.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -10,7 +10,7 @@ #include #ifdef ZEN_WIN -#include "win.h" + #include "win.h" #endif diff --git a/zen/long_path_prefix.h b/zen/long_path_prefix.h index 824c7084..d2289330 100644 --- a/zen/long_path_prefix.h +++ b/zen/long_path_prefix.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/notify_removal.cpp b/zen/notify_removal.cpp index 639264a6..37f305c9 100644 --- a/zen/notify_removal.cpp +++ b/zen/notify_removal.cpp @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/notify_removal.h b/zen/notify_removal.h index ba560f96..08d75818 100644 --- a/zen/notify_removal.h +++ b/zen/notify_removal.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/optional.h b/zen/optional.h index 15d27f4b..d65820c2 100644 --- a/zen/optional.h +++ b/zen/optional.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/perf.h b/zen/perf.h index 4405537c..17aeabd0 100644 --- a/zen/perf.h +++ b/zen/perf.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -11,9 +11,9 @@ #include "tick_count.h" #ifdef ZEN_WIN -#include + #include #else -#include + #include #endif //############# two macros for quick performance measurements ############### diff --git a/zen/process_priority.cpp b/zen/process_priority.cpp index ee8e7d8b..c5932900 100644 --- a/zen/process_priority.cpp +++ b/zen/process_priority.cpp @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -9,7 +9,7 @@ #include "i18n.h" #ifdef ZEN_WIN -#include "win.h" //includes "windows.h" + #include "win.h" //includes "windows.h" #endif using namespace zen; @@ -32,8 +32,8 @@ PreventStandby::~PreventStandby() #ifndef PROCESS_MODE_BACKGROUND_BEGIN -#define PROCESS_MODE_BACKGROUND_BEGIN 0x00100000 // Windows Server 2003 and Windows XP/2000: This value is not supported! -#define PROCESS_MODE_BACKGROUND_END 0x00200000 // + #define PROCESS_MODE_BACKGROUND_BEGIN 0x00100000 // Windows Server 2003 and Windows XP/2000: This value is not supported! + #define PROCESS_MODE_BACKGROUND_END 0x00200000 // #endif struct ScheduleForBackgroundProcessing::Pimpl {}; diff --git a/zen/process_priority.h b/zen/process_priority.h index a133985f..3e217776 100644 --- a/zen/process_priority.h +++ b/zen/process_priority.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef PREVENTSTANDBY_H_83421759082143245 diff --git a/zen/recycler.cpp b/zen/recycler.cpp index 5b5e44d4..649bbb8e 100644 --- a/zen/recycler.cpp +++ b/zen/recycler.cpp @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -8,19 +8,19 @@ #include "file_access.h" #ifdef ZEN_WIN -#include "thread.h" -#include "dll.h" -#include "win_ver.h" -#include "long_path_prefix.h" -#include "IFileOperation/file_op.h" + #include "thread.h" + #include "dll.h" + #include "win_ver.h" + #include "long_path_prefix.h" + #include "IFileOperation/file_op.h" #elif defined ZEN_LINUX -#include -#include -#include "scope_guard.h" + #include + #include + #include "scope_guard.h" #elif defined ZEN_MAC -#include + #include #endif using namespace zen; diff --git a/zen/recycler.h b/zen/recycler.h index b406408f..d86fbb12 100644 --- a/zen/recycler.h +++ b/zen/recycler.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/scope_guard.h b/zen/scope_guard.h index 761c6aea..706b20dc 100644 --- a/zen/scope_guard.h +++ b/zen/scope_guard.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/serialize.h b/zen/serialize.h index cd427c9c..54baf75a 100644 --- a/zen/serialize.h +++ b/zen/serialize.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -137,35 +137,35 @@ template < class BinInputStream> void readArray (BinInputStream& stre //-----------------------implementation------------------------------- template inline void saveBinStream(const Zstring& filepath, //throw FileError - const BinContainer& cont, - const std::function& onUpdateStatus) //optional + const BinContainer& cont, + const std::function& onUpdateStatus) //optional { static_assert(sizeof(typename BinContainer::value_type) == 1, ""); //expect: bytes (until further) FileOutput fileOut(filepath, zen::FileOutput::ACC_OVERWRITE); //throw FileError if (!cont.empty()) - { - const size_t blockSize = 128 * 1024; - auto bytePtr = &*cont.begin(); - size_t bytesLeft = cont.size(); - - while (bytesLeft > blockSize) - { - fileOut.write(bytePtr, blockSize); //throw FileError - bytePtr += blockSize; - bytesLeft -= blockSize; - if (onUpdateStatus) onUpdateStatus(blockSize); - } - - fileOut.write(bytePtr, bytesLeft); //throw FileError - if (onUpdateStatus) onUpdateStatus(bytesLeft); - } + { + const size_t blockSize = 128 * 1024; + auto bytePtr = &*cont.begin(); + size_t bytesLeft = cont.size(); + + while (bytesLeft > blockSize) + { + fileOut.write(bytePtr, blockSize); //throw FileError + bytePtr += blockSize; + bytesLeft -= blockSize; + if (onUpdateStatus) onUpdateStatus(blockSize); + } + + fileOut.write(bytePtr, bytesLeft); //throw FileError + if (onUpdateStatus) onUpdateStatus(bytesLeft); + } } template inline BinContainer loadBinStream(const Zstring& filepath, //throw FileError - const std::function& onUpdateStatus) //optional + const std::function& onUpdateStatus) //optional { static_assert(sizeof(typename BinContainer::value_type) == 1, ""); //expect: bytes (until further) @@ -181,7 +181,7 @@ BinContainer loadBinStream(const Zstring& filepath, //throw FileError if (bytesRead < blockSize) contOut.resize(contOut.size() - (blockSize - bytesRead)); //caveat: unsigned arithmetics - if (onUpdateStatus) onUpdateStatus(bytesRead); + if (onUpdateStatus) onUpdateStatus(bytesRead); } while (!fileIn.eof()); diff --git a/zen/shell_execute.h b/zen/shell_execute.h index c2ccd837..4eebcca2 100644 --- a/zen/shell_execute.h +++ b/zen/shell_execute.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -10,12 +10,12 @@ #include "file_error.h" #ifdef ZEN_WIN -#include "scope_guard.h" -#include "win.h" //includes "windows.h" + #include "scope_guard.h" + #include "win.h" //includes "windows.h" #elif defined ZEN_LINUX || defined ZEN_MAC -#include "thread.h" -#include //::system() + #include "thread.h" + #include //::system() #endif diff --git a/zen/stl_tools.h b/zen/stl_tools.h index eb94b4a1..a8f2a9b5 100644 --- a/zen/stl_tools.h +++ b/zen/stl_tools.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -164,8 +164,8 @@ bool equal(InputIterator1 first1, InputIterator1 last1, #if defined _MSC_VER && _MSC_VER <= 1600 -//VS2010 performance bug in std::unordered_set<>: http://drdobbs.com/blogs/cpp/232200410 -> should be fixed in VS11 -static_assert(false, ""); + //VS2010 performance bug in std::unordered_set<>: http://drdobbs.com/blogs/cpp/232200410 -> should be fixed in VS11 + static_assert(false, ""); #endif } diff --git a/zen/string_base.h b/zen/string_base.h index 0f9ad479..b1d7102e 100644 --- a/zen/string_base.h +++ b/zen/string_base.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -74,7 +74,7 @@ protected: assert(newCapacity >= minCapacity); Descriptor* const newDescr = static_cast(this->allocate(sizeof(Descriptor) + (newCapacity + 1) * sizeof(Char))); //throw std::bad_alloc - new (newDescr) Descriptor(size, newCapacity); + new (newDescr) Descriptor(size, newCapacity); return reinterpret_cast(newDescr + 1); //alignment note: "newDescr + 1" is Descriptor-aligned, which is larger than alignment for Char-array! => no problem! } @@ -86,14 +86,14 @@ protected: return newData; } - void destroy(Char* ptr) - { + void destroy(Char* ptr) + { if (!ptr) return; //support "destroy(nullptr)" - Descriptor* const d = descr(ptr); - d->~Descriptor(); - this->deallocate(d); - } + Descriptor* const d = descr(ptr); + d->~Descriptor(); + this->deallocate(d); + } //this needs to be checked before writing to "ptr" static bool canWrite(const Char* ptr, size_t minCapacity) { return minCapacity <= descr(ptr)->capacity; } @@ -164,7 +164,7 @@ protected: static bool canWrite(const Char* ptr, size_t minCapacity) //needs to be checked before writing to "ptr" { const Descriptor* const d = descr(ptr); - assert(d->refCount > 0); + assert(d->refCount > 0); return d->refCount == 1 && minCapacity <= d->capacity; } @@ -180,7 +180,7 @@ private: struct Descriptor { Descriptor(size_t len, size_t cap) : - refCount(1), + refCount(1), length (static_cast(len)), capacity(static_cast(cap)) { static_assert(ATOMIC_INT_LOCK_FREE == 2, ""); } //2: "the types are always lock-free" diff --git a/zen/string_tools.h b/zen/string_tools.h index addf2bd5..1b8595c7 100644 --- a/zen/string_tools.h +++ b/zen/string_tools.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/string_traits.h b/zen/string_traits.h index ba97397c..8bc55a6a 100644 --- a/zen/string_traits.h +++ b/zen/string_traits.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -82,10 +82,10 @@ template struct GetCharTypeImpl : ResultType struct GetCharTypeImpl : - ResultType< - typename SelectIf::value, wchar_t, - typename SelectIf::value, char, NullType>::Type - >::Type> + ResultType< + typename SelectIf::value, wchar_t, + typename SelectIf::value, char, NullType>::Type + >::Type> { //typedef typename S::value_type Type; /*DON'T use S::value_type: diff --git a/zen/symlink_target.h b/zen/symlink_target.h index 4106ed02..1a7f45bd 100644 --- a/zen/symlink_target.h +++ b/zen/symlink_target.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -11,22 +11,22 @@ #include "file_error.h" #ifdef ZEN_WIN -#include "win.h" //includes "windows.h" -#include "privilege.h" -#include "long_path_prefix.h" -#include "dll.h" + #include "win.h" //includes "windows.h" + #include "privilege.h" + #include "long_path_prefix.h" + #include "dll.h" #elif defined ZEN_LINUX || defined ZEN_MAC -#include -#include //realpath + #include + #include //realpath #endif namespace zen { #ifdef ZEN_WIN -bool isSymlink(const WIN32_FIND_DATA& data); //*not* a simple FILE_ATTRIBUTE_REPARSE_POINT check! -bool isSymlink(DWORD fileAttributes, DWORD reparseTag); + bool isSymlink(const WIN32_FIND_DATA& data); //*not* a simple FILE_ATTRIBUTE_REPARSE_POINT check! + bool isSymlink(DWORD fileAttributes, DWORD reparseTag); #endif Zstring getResolvedFilePath(const Zstring& linkPath); //throw FileError; Win: requires Vista or later! diff --git a/zen/sys_error.h b/zen/sys_error.h index 9cfc762f..9f7667db 100644 --- a/zen/sys_error.h +++ b/zen/sys_error.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -13,11 +13,11 @@ #include "scope_guard.h" #ifdef ZEN_WIN -#include "win.h" //includes "windows.h" + #include "win.h" //includes "windows.h" #elif defined ZEN_LINUX || defined ZEN_MAC -#include -#include + #include + #include #endif @@ -25,11 +25,11 @@ namespace zen { //evaluate GetLastError()/errno and assemble specific error message #ifdef ZEN_WIN -typedef DWORD ErrorCode; + typedef DWORD ErrorCode; #elif defined ZEN_LINUX || defined ZEN_MAC -typedef int ErrorCode; + typedef int ErrorCode; #else -#error define a platform! + #error define a platform! #endif ErrorCode getLastError(); diff --git a/zen/thread.h b/zen/thread.h index a834f070..cca2561f 100644 --- a/zen/thread.h +++ b/zen/thread.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -12,27 +12,27 @@ //workaround this pathetic boost thread warning mess #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wswitch-enum" -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#pragma GCC diagnostic ignored "-Wredundant-decls" -#pragma GCC diagnostic ignored "-Wshadow" -#ifndef __clang__ //clang defines __GNUC__, but doesn't support this warning -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#endif + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wswitch-enum" + #pragma GCC diagnostic ignored "-Wstrict-aliasing" + #pragma GCC diagnostic ignored "-Wredundant-decls" + #pragma GCC diagnostic ignored "-Wshadow" + #ifndef __clang__ //clang defines __GNUC__, but doesn't support this warning + #pragma GCC diagnostic ignored "-Wunused-local-typedefs" + #endif #endif #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4702 4913) //unreachable code; user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used + #pragma warning(push) + #pragma warning(disable : 4702 4913) //unreachable code; user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used #endif #include #ifdef __GNUC__ -#pragma GCC diagnostic pop + #pragma GCC diagnostic pop #endif #ifdef _MSC_VER -#pragma warning(pop) + #pragma warning(pop) #endif namespace zen @@ -85,7 +85,7 @@ private: //###################### implementation ###################### #ifndef BOOST_HAS_THREADS -#error just some paranoia check... + #error just some paranoia check... #endif template inline diff --git a/zen/tick_count.h b/zen/tick_count.h index 56179b62..bedc66a5 100644 --- a/zen/tick_count.h +++ b/zen/tick_count.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -12,13 +12,13 @@ #include "basic_math.h" #ifdef ZEN_WIN -#include "win.h" //includes "windows.h" + #include "win.h" //includes "windows.h" #elif defined ZEN_LINUX -#include //Posix ::clock_gettime() + #include //Posix ::clock_gettime() #elif defined ZEN_MAC -#include + #include #endif //template inline //T dist(T a, T b) diff --git a/zen/time.h b/zen/time.h index e53e4c6e..4593c48b 100644 --- a/zen/time.h +++ b/zen/time.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/type_tools.h b/zen/type_tools.h index 1f782a2d..95e49769 100644 --- a/zen/type_tools.h +++ b/zen/type_tools.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/type_traits.h b/zen/type_traits.h index 8e85a7b2..082baea9 100644 --- a/zen/type_traits.h +++ b/zen/type_traits.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/utf.h b/zen/utf.h index e742c1e2..42758c35 100644 --- a/zen/utf.h +++ b/zen/utf.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/warn_static.h b/zen/warn_static.h index b9673ed6..1e942031 100644 --- a/zen/warn_static.h +++ b/zen/warn_static.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/win.h b/zen/win.h index 40a157f5..121e6a9c 100644 --- a/zen/win.h +++ b/zen/win.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -9,20 +9,20 @@ //------------------------------------------------------ #ifdef __WXMSW__ //we have wxWidgets -#include //includes "windows.h" -//------------------------------------------------------ + #include //includes "windows.h" + //------------------------------------------------------ #else -//#define WIN32_LEAN_AND_MEAN + //#define WIN32_LEAN_AND_MEAN -#ifndef NOMINMAX -#define NOMINMAX -#endif + #ifndef NOMINMAX + #define NOMINMAX + #endif -#ifndef STRICT -#define STRICT //improve type checking -#endif + #ifndef STRICT + #define STRICT //improve type checking + #endif -#include + #include #endif //------------------------------------------------------ diff --git a/zen/win_ver.h b/zen/win_ver.h index 1d7ce7f0..97b6d7e1 100644 --- a/zen/win_ver.h +++ b/zen/win_ver.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -10,6 +10,8 @@ #include #include #include "win.h" //includes "windows.h" +#include "build_info.h" +#include "dll.h" namespace zen { @@ -33,6 +35,7 @@ const OsVersion osVersionWin7 (6, 1); const OsVersion osVersionWinVista (6, 0); const OsVersion osVersionWinServer2003(5, 2); const OsVersion osVersionWinXp (5, 1); +const OsVersion osVersionWin2000 (5, 0); /* NOTE: there are two basic APIs to check Windows version: (empiric study following) @@ -53,6 +56,8 @@ inline bool winXpOrLater () { using namespace std::rel_ops; return getOsV bool isRealOsVersion(const OsVersion& ver); +bool runningWOW64(); +bool running64BitWindows(); @@ -98,6 +103,30 @@ bool isRealOsVersion(const OsVersion& ver) return rv; } + + +inline +bool runningWOW64() //test if process is running under WOW64: http://msdn.microsoft.com/en-us/library/ms684139(VS.85).aspx +{ + typedef BOOL (WINAPI* IsWow64ProcessFun)(HANDLE hProcess, PBOOL Wow64Process); + + const SysDllFun isWow64Process(L"kernel32.dll", "IsWow64Process"); + if (isWow64Process) + { + BOOL isWow64 = FALSE; + if (isWow64Process(::GetCurrentProcess(), &isWow64)) + return isWow64 != FALSE; + } + return false; +} + + +inline +bool running64BitWindows() //http://blogs.msdn.com/b/oldnewthing/archive/2005/02/01/364563.aspx +{ + static_assert(zen::is32BitBuild || zen::is64BitBuild, ""); + return is64BitBuild || runningWOW64(); //should we bother to make this a compile-time check? +} } #endif //WINDOWS_VERSION_HEADER_238470348254325 diff --git a/zen/xml_io.cpp b/zen/xml_io.cpp index 9ac4b87f..a070b526 100644 --- a/zen/xml_io.cpp +++ b/zen/xml_io.cpp @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/xml_io.h b/zen/xml_io.h index e3e47f59..16e01aff 100644 --- a/zen/xml_io.h +++ b/zen/xml_io.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/zstring.cpp b/zen/zstring.cpp index a2a26f83..d87e7989 100644 --- a/zen/zstring.cpp +++ b/zen/zstring.cpp @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -9,17 +9,16 @@ #include #ifdef ZEN_WIN -#include "dll.h" -#include "win_ver.h" + #include "dll.h" + #include "win_ver.h" #elif defined ZEN_MAC -#include //toupper() + #include //toupper() #endif #ifndef NDEBUG -#include -#include -#include "thread.h" + #include + #include #endif using namespace zen; @@ -40,14 +39,14 @@ public: void insert(const void* ptr, size_t size) { - boost::lock_guard dummy(lockActStrings); + std::lock_guard dummy(lockActStrings); if (!activeStrings.emplace(ptr, size).second) reportProblem("Serious Error: New memory points into occupied space: " + rawMemToString(ptr, size)); } void remove(const void* ptr) { - boost::lock_guard dummy(lockActStrings); + std::lock_guard dummy(lockActStrings); if (activeStrings.erase(ptr) != 1) reportProblem("Serious Error: No memory available for deallocation at this location!"); } @@ -96,7 +95,7 @@ private: throw std::logic_error("Memory leak! " + message); } - boost::mutex lockActStrings; + std::mutex lockActStrings; std::unordered_map activeStrings; }; @@ -168,8 +167,8 @@ int cmpFileName(const Zstring& lhs, const Zstring& rhs) //do NOT use "CompareString"; this function is NOT accurate (even with LOCALE_INVARIANT and SORT_STRINGSORT): for example "weiß" == "weiss"!!! //the only reliable way to compare filepaths (with XP) is to call "CharUpper" or "LCMapString": - const size_t sizeLhs = lhs.size(); - const size_t sizeRhs = rhs.size(); + const size_t sizeLhs = lhs.size(); + const size_t sizeRhs = rhs.size(); const auto minSize = std::min(sizeLhs, sizeRhs); diff --git a/zen/zstring.h b/zen/zstring.h index 94144386..0610a27f 100644 --- a/zen/zstring.h +++ b/zen/zstring.h @@ -1,6 +1,6 @@ // ************************************************************************** // * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * // * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** @@ -10,7 +10,7 @@ #include "string_base.h" #ifdef ZEN_LINUX -#include //strcmp + #include //strcmp #endif @@ -49,14 +49,14 @@ public: //############################## helper functions ############################################# #ifdef ZEN_WIN //Windows encodes Unicode as UTF-16 wchar_t -typedef wchar_t Zchar; -#define Zstr(x) L ## x -const Zchar FILE_NAME_SEPARATOR = L'\\'; + typedef wchar_t Zchar; + #define Zstr(x) L ## x + const Zchar FILE_NAME_SEPARATOR = L'\\'; #elif defined ZEN_LINUX || defined ZEN_MAC //Linux uses UTF-8 -typedef char Zchar; -#define Zstr(x) x -const Zchar FILE_NAME_SEPARATOR = '/'; + typedef char Zchar; + #define Zstr(x) x + const Zchar FILE_NAME_SEPARATOR = '/'; #endif //"The reason for all the fuss above" - Loki/SmartPtr @@ -79,7 +79,7 @@ struct EqualFilename //case-insensitive on Windows, case-sensitive on Linux }; #if defined ZEN_WIN || defined ZEN_MAC -Zstring makeUpperCopy(const Zstring& str); + Zstring makeUpperCopy(const Zstring& str); #endif inline -- cgit