diff options
Diffstat (limited to 'zen')
67 files changed, 201 insertions, 377 deletions
diff --git a/zen/FindFilePlus/dll_main.cpp b/zen/FindFilePlus/dll_main.cpp index 02755010..a7637be4 100644 --- a/zen/FindFilePlus/dll_main.cpp +++ b/zen/FindFilePlus/dll_main.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/FindFilePlus/find_file_plus.cpp b/zen/FindFilePlus/find_file_plus.cpp index a6e82617..9b146008 100644 --- a/zen/FindFilePlus/find_file_plus.cpp +++ b/zen/FindFilePlus/find_file_plus.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "find_file_plus.h" diff --git a/zen/FindFilePlus/find_file_plus.h b/zen/FindFilePlus/find_file_plus.h index 49b18733..a2f61cdc 100644 --- a/zen/FindFilePlus/find_file_plus.h +++ b/zen/FindFilePlus/find_file_plus.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FIND_FIRST_FILE_PLUS_HEADER_087483434 diff --git a/zen/FindFilePlus/init_dll_binding.h b/zen/FindFilePlus/init_dll_binding.h index 5f2c9fa9..993a3790 100644 --- a/zen/FindFilePlus/init_dll_binding.h +++ b/zen/FindFilePlus/init_dll_binding.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef INIT_DLL_BINDING_HEADER_ß018356031467832145 diff --git a/zen/FindFilePlus/load_dll.cpp b/zen/FindFilePlus/load_dll.cpp index 9e8dbf17..5f72e31b 100644 --- a/zen/FindFilePlus/load_dll.cpp +++ b/zen/FindFilePlus/load_dll.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "load_dll.h" diff --git a/zen/FindFilePlus/load_dll.h b/zen/FindFilePlus/load_dll.h index 2dde5d70..ce414733 100644 --- a/zen/FindFilePlus/load_dll.h +++ b/zen/FindFilePlus/load_dll.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef LOAD_DLL_HEADER_0312463214872163832174 diff --git a/zen/IFileOperation/FileOperation_Vista.vcxproj b/zen/IFileOperation/FileOperation_Vista.vcxproj index a387dcb5..4bd5b509 100644 --- a/zen/IFileOperation/FileOperation_Vista.vcxproj +++ b/zen/IFileOperation/FileOperation_Vista.vcxproj @@ -144,7 +144,7 @@ </ProfileGuidedDatabase> <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> <TargetMachine>MachineX64</TargetMachine> - <AdditionalLibraryDirectories>C:\Program Files\C++\Boost\stage64\lib</AdditionalLibraryDirectories> + <AdditionalLibraryDirectories>C:\Program Files\C++\Boost\stage_x64\lib</AdditionalLibraryDirectories> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> @@ -215,7 +215,7 @@ </ProfileGuidedDatabase> <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> <TargetMachine>MachineX64</TargetMachine> - <AdditionalLibraryDirectories>C:\Program Files\C++\Boost\stage64\lib</AdditionalLibraryDirectories> + <AdditionalLibraryDirectories>C:\Program Files\C++\Boost\stage_x64\lib</AdditionalLibraryDirectories> </Link> </ItemDefinitionGroup> <ItemGroup> diff --git a/zen/IFileOperation/dll_main.cpp b/zen/IFileOperation/dll_main.cpp index 46c65311..95d14910 100644 --- a/zen/IFileOperation/dll_main.cpp +++ b/zen/IFileOperation/dll_main.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** diff --git a/zen/IFileOperation/file_op.cpp b/zen/IFileOperation/file_op.cpp index b7bc9f9c..3861c5c0 100644 --- a/zen/IFileOperation/file_op.cpp +++ b/zen/IFileOperation/file_op.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "file_op.h" diff --git a/zen/IFileOperation/file_op.h b/zen/IFileOperation/file_op.h index fb157301..c9df1e1e 100644 --- a/zen/IFileOperation/file_op.h +++ b/zen/IFileOperation/file_op.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef RECYCLER_DLL_H diff --git a/zen/assert_static.h b/zen/assert_static.h index d61dd1e3..0f2a150a 100644 --- a/zen/assert_static.h +++ b/zen/assert_static.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef ASSERTSTATIC_H_INCLUDED diff --git a/zen/base64.h b/zen/base64.h index 273f6c00..fd4e3611 100644 --- a/zen/base64.h +++ b/zen/base64.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef BASE64_HEADER_08473021856321840873021487213453214 #define BASE64_HEADER_08473021856321840873021487213453214 diff --git a/zen/basic_math.h b/zen/basic_math.h index 6678b91e..2c0381bf 100644 --- a/zen/basic_math.h +++ b/zen/basic_math.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef BASIC_MATH_HEADER_34726398432 diff --git a/zen/build_info.h b/zen/build_info.h index 6857a855..822a78d1 100644 --- a/zen/build_info.h +++ b/zen/build_info.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef BUILDINFO_H_INCLUDED diff --git a/zen/com_error.h b/zen/com_error.h index d891fa13..f5463d68 100644 --- a/zen/com_error.h +++ b/zen/com_error.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef COM_ERROR_HEADER diff --git a/zen/com_ptr.h b/zen/com_ptr.h index 98963cd1..9328d645 100644 --- a/zen/com_ptr.h +++ b/zen/com_ptr.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef SMART_COM_PTR_H diff --git a/zen/com_util.h b/zen/com_util.h index fe02eadd..ac733566 100644 --- a/zen/com_util.h +++ b/zen/com_util.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef COM_UTILITY_HEADER diff --git a/zen/debug_log.h b/zen/debug_log.h index d65f5e36..04c42a91 100644 --- a/zen/debug_log.h +++ b/zen/debug_log.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef DEBUG_LOG_HEADER_017324601673246392184621895740256342 diff --git a/zen/debug_new.cpp b/zen/debug_new.cpp index 6cc0e2da..f8273163 100644 --- a/zen/debug_new.cpp +++ b/zen/debug_new.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "debug_new.h" @@ -15,12 +15,13 @@ namespace { LONG WINAPI writeDumpOnException(EXCEPTION_POINTERS* pExceptionInfo) { - HANDLE hFile = ::CreateFile(L"exception.dmp", GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); + HANDLE hFile = ::CreateFile(L"exception.dmp", GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile != INVALID_HANDLE_VALUE) { MINIDUMP_EXCEPTION_INFORMATION exInfo = {}; exInfo.ThreadId = ::GetCurrentThreadId(); exInfo.ExceptionPointers = pExceptionInfo; + exInfo.ClientPointers = FALSE; MINIDUMP_EXCEPTION_INFORMATION* exceptParam = pExceptionInfo ? &exInfo : nullptr; @@ -45,5 +46,10 @@ struct Dummy { Dummy() { ::SetUnhandledExceptionFilter(writeDumpOnException); }} void mem_check::writeMinidump() { - writeDumpOnException(nullptr); + //force exception to catch the state of this thread and hopefully get a valid call stack + __try + { + ::RaiseException(EXCEPTION_BREAKPOINT, 0, 0, nullptr); + } + __except (writeDumpOnException(GetExceptionInformation()), EXCEPTION_CONTINUE_EXECUTION) {} } diff --git a/zen/debug_new.h b/zen/debug_new.h index 8d616360..ed732a87 100644 --- a/zen/debug_new.h +++ b/zen/debug_new.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef DEBUGNEW_H_INCLUDED @@ -15,17 +15,25 @@ #error currently for use with MSC only #endif -/*overwrite "operator new" to get more detailed error messages on bad_alloc, detect memory leaks and write memory dumps -Usage: -- Include everywhere before any other file: $(ProjectDir)\shared\debug_new.h +/* +Better std::bad_alloc +--------------------- +overwrite "operator new" to automatically write mini dump and get info about bytes requested -For Minidumps: -------------- +1. Compile "debug_new.cpp" +2. C/C++ -> Advanced: Forced Include File: zen/debug_new.h + +Minidumps http://msdn.microsoft.com/en-us/library/windows/desktop/ee416349(v=vs.85).aspx +--------- 1. Compile "debug_new.cpp" 2. Compile "release" build with: - - debugging symbols - - optimization deactivated - - do not suppress frame pointer(/Oy-) - avoid call stack mess up + - C/C++ -> General: Debug Information Format: "Program Database" (/Zi). + - C/C++ -> Optimization: Omit Frame Pointers: No (/Oy-) - avoid call stack mess up! + - Linker -> Debugging: Generate Debug Info: Yes (/DEBUG) + - Linker -> Optimization: References: Yes (/OPT:REF). + - Linker -> Optimization: Enable COMDAT Folding: Yes (/OPT:ICF). +Optional: + - C/C++ -> Optimization: Disabled (/Od) */ namespace mem_check diff --git a/zen/deprecate.h b/zen/deprecate.h index 33130710..cd7c1e08 100644 --- a/zen/deprecate.h +++ b/zen/deprecate.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef DEPRECATE_HEADER_2348970348 diff --git a/zen/dir_watcher.cpp b/zen/dir_watcher.cpp index 29a2a3cf..a76c0cc3 100644 --- a/zen/dir_watcher.cpp +++ b/zen/dir_watcher.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "dir_watcher.h" @@ -14,7 +14,7 @@ #include "notify_removal.h" #include "win.h" //includes "windows.h" #include "long_path_prefix.h" -#include "privilege.h" +//#include "privilege.h" #elif defined FFS_LINUX #include <sys/inotify.h> @@ -191,8 +191,9 @@ public: //async I/O is a resource that needs to be guarded since it will write to local variable "buffer"! zen::ScopeGuard guardAio = zen::makeGuard([&] { - //http://msdn.microsoft.com/en-us/library/aa363789(v=vs.85).aspx - if (::CancelIo(hDir) != FALSE) //cancel all async I/O related to this handle and thread + //Canceling Pending I/O Operations: http://msdn.microsoft.com/en-us/library/aa363789(v=vs.85).aspx + //if (::CancelIoEx(hDir, &overlapped) /*!= FALSE*/ || ::GetLastError() != ERROR_NOT_FOUND) -> Vista only + if (::CancelIo(hDir) /*!= FALSE*/ || ::GetLastError() != ERROR_NOT_FOUND) { DWORD bytesWritten = 0; ::GetOverlappedResult(hDir, &overlapped, &bytesWritten, true); //wait until cancellation is complete @@ -361,7 +362,7 @@ public: dirs_.push_back(fullName); return otherMe_; } - virtual HandleError onError(const std::wstring& errorText) { throw FileError(errorText); } + virtual HandleError onError(const std::wstring& msg) { throw FileError(msg); } private: const std::shared_ptr<TraverseCallback>& otherMe_; //lifetime management, two options: 1. use std::weak_ptr 2. ref to shared_ptr diff --git a/zen/dir_watcher.h b/zen/dir_watcher.h index 67f2bce0..52a08226 100644 --- a/zen/dir_watcher.h +++ b/zen/dir_watcher.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef DIR_WATCHER_348577025748023458 @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef DLLLOADER_H_INCLUDED diff --git a/zen/error_log.h b/zen/error_log.h index bbb36f00..c591e470 100644 --- a/zen/error_log.h +++ b/zen/error_log.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef ERRORLOGGING_H_INCLUDED diff --git a/zen/file_error.h b/zen/file_error.h index 622d6a47..e5ff6515 100644 --- a/zen/file_error.h +++ b/zen/file_error.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILEERROR_H_INCLUDED @@ -32,6 +32,7 @@ DEFINE_NEW_FILE_ERROR(ErrorNotExisting); DEFINE_NEW_FILE_ERROR(ErrorTargetExisting); DEFINE_NEW_FILE_ERROR(ErrorTargetPathMissing); DEFINE_NEW_FILE_ERROR(ErrorFileLocked); +DEFINE_NEW_FILE_ERROR(ErrorDifferentVolume); diff --git a/zen/file_handling.cpp b/zen/file_handling.cpp index e176f3a6..732c90f4 100644 --- a/zen/file_handling.cpp +++ b/zen/file_handling.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "file_handling.h" @@ -91,7 +91,7 @@ bool zen::symlinkExists(const Zstring& linkname) } -bool zen::somethingExists(const Zstring& objname) //throw() check whether any object with this name exists +bool zen::somethingExists(const Zstring& objname) { #ifdef FFS_WIN const DWORD rv = ::GetFileAttributes(applyLongPathPrefix(objname).c_str()); @@ -349,8 +349,6 @@ bool zen::removeFile(const Zstring& filename) //throw FileError namespace { -DEFINE_NEW_FILE_ERROR(ErrorDifferentVolume); - /* Usage overview: (avoid circular pattern!) renameFile() --> renameFile_sub() @@ -567,214 +565,6 @@ void zen::renameFile(const Zstring& oldName, const Zstring& newName) //throw Fil } -class CopyCallbackImpl : public zen::CallbackCopyFile //callback functionality -{ -public: - CopyCallbackImpl(const Zstring& sourceFile, - const Zstring& targetFile, - CallbackMoveFile* callback) : sourceFile_(sourceFile), - targetFile_(targetFile), - moveCallback(callback) {} - - virtual void deleteTargetFile(const Zstring& targetFile) { assert(!fileExists(targetFile)); } - - virtual void updateCopyStatus(Int64 bytesDelta) - { - if (moveCallback) - moveCallback->updateStatus(bytesDelta); - } - -private: - CopyCallbackImpl(const CopyCallbackImpl&); - CopyCallbackImpl& operator=(const CopyCallbackImpl&); - - const Zstring sourceFile_; - const Zstring targetFile_; - CallbackMoveFile* moveCallback; //optional -}; - - -void zen::moveFile(const Zstring& sourceFile, const Zstring& targetFile, CallbackMoveFile* callback) //throw FileError -{ - if (callback) callback->onBeforeFileMove(sourceFile, targetFile); //call back once *after* work was done - - //first try to move the file directly without copying - try - { - renameFile(sourceFile, targetFile); //throw FileError, ErrorDifferentVolume, ErrorTargetExisting - //great, we get away cheaply! - if (callback) callback->objectProcessed(); - return; - } - //if moving failed treat as error (except when it tried to move to a different volume: in this case we will copy the file) - catch (const ErrorDifferentVolume&) {} - catch (const ErrorTargetExisting&) {} - - //create target - if (!fileExists(targetFile)) //check even if ErrorTargetExisting: me may have clashed with a directory of the same name!!! - { - //file is on a different volume: let's copy it - if (symlinkExists(sourceFile)) - copySymlink(sourceFile, targetFile, false); //throw FileError; don't copy filesystem permissions - else - { - CopyCallbackImpl copyCallback(sourceFile, targetFile, callback); - copyFile(sourceFile, targetFile, false, true, ©Callback); //throw FileError - permissions "false", transactional copy "true" - } - } - - //delete source - removeFile(sourceFile); //throw FileError - - //note: newly copied file is NOT deleted in case of exception: currently this function is called in context of user-defined deletion dir, where this behavior is fine - if (callback) callback->objectProcessed(); -} - -namespace -{ -class TraverseOneLevel : public zen::TraverseCallback -{ -public: - typedef std::pair<Zstring, Zstring> ShortLongNames; - typedef std::vector<ShortLongNames> NameList; - - TraverseOneLevel(NameList& files, NameList& dirs) : - files_(files), - dirs_(dirs) {} - - virtual void onFile(const Zchar* shortName, const Zstring& fullName, const FileInfo& details) - { - files_.push_back(std::make_pair(shortName, fullName)); - } - - virtual HandleLink onSymlink(const Zchar* shortName, const Zstring& fullName, const SymlinkInfo& details) - { - if (details.dirLink) - dirs_.push_back(std::make_pair(shortName, fullName)); - else - files_.push_back(std::make_pair(shortName, fullName)); - return LINK_SKIP; - } - - virtual std::shared_ptr<TraverseCallback> onDir(const Zchar* shortName, const Zstring& fullName) - { - dirs_.push_back(std::make_pair(shortName, fullName)); - return nullptr; //DON'T traverse into subdirs; moveDirectory works recursively! - } - - virtual HandleError onError(const std::wstring& errorText) { throw FileError(errorText); } - -private: - TraverseOneLevel(const TraverseOneLevel&); - TraverseOneLevel& operator=(const TraverseOneLevel&); - - NameList& files_; - NameList& dirs_; -}; - - -struct RemoveCallbackImpl : public CallbackRemoveDir -{ - RemoveCallbackImpl(CallbackMoveFile* moveCallback) : moveCallback_(moveCallback) {} - - virtual void notifyFileDeletion(const Zstring& filename) { if (moveCallback_) moveCallback_->updateStatus(0); } - virtual void notifyDirDeletion (const Zstring& dirname ) { if (moveCallback_) moveCallback_->updateStatus(0); } - -private: - RemoveCallbackImpl(const RemoveCallbackImpl&); - RemoveCallbackImpl& operator=(const RemoveCallbackImpl&); - - CallbackMoveFile* moveCallback_; //optional -}; -} - - -void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, CallbackMoveFile* callback) //throw FileError -{ - //note: we cannot support "throw exception if target already exists": If we did, we would have to do a full cleanup - //removing all newly created directories in case of an exception so that subsequent tries would not fail with "target already existing". - //However an exception may also happen during final deletion of source folder, in which case cleanup effectively leads to data loss! - - if (callback) callback->onBeforeDirMove(sourceDir, targetDir); //call back once *after* work was done - - //first try to move the directory directly without copying - try - { - renameFile(sourceDir, targetDir); //throw FileError, ErrorDifferentVolume, ErrorTargetExisting - //great, we get away cheaply! - if (callback) callback->objectProcessed(); - return; - } - //if moving failed treat as error (except when it tried to move to a different volume: in this case we will copy the directory) - catch (const ErrorDifferentVolume&) {} - catch (const ErrorTargetExisting& ) {} - - //create target - if (symlinkExists(sourceDir)) - { - if (!symlinkExists(targetDir)) - copySymlink(sourceDir, targetDir, false); //throw FileError -> don't copy permissions - } - else - { - try - { - makeNewDirectory(targetDir, sourceDir, false); //FileError, ErrorTargetExisting - } - catch (const ErrorTargetExisting&) - { - if (!dirExists(targetDir)) - throw; //clashed with a file or symlink of the same name!!! - } - - //move files/folders recursively - TraverseOneLevel::NameList fileList; //list of names: 1. short 2.long - TraverseOneLevel::NameList dirList; // - - //traverse source directory one level - TraverseOneLevel traverseCallback(fileList, dirList); - traverseFolder(sourceDir, traverseCallback); //traverse one level - - const Zstring targetDirPf = appendSeparator(targetDir); - - //move files - for (TraverseOneLevel::NameList::const_iterator i = fileList.begin(); i != fileList.end(); ++i) - moveFile(i->second, targetDirPf + i->first, callback); //throw FileError - - //move directories - for (TraverseOneLevel::NameList::const_iterator i = dirList.begin(); i != dirList.end(); ++i) - ::moveDirectoryImpl(i->second, targetDirPf + i->first, callback); - } - - //delete source - RemoveCallbackImpl removeCallback(callback); - removeDirectory(sourceDir, &removeCallback); //throw FileError - - if (callback) callback->objectProcessed(); -} - - -void zen::moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, CallbackMoveFile* callback) //throw FileError -{ -#ifdef FFS_WIN - const Zstring& sourceDirFormatted = sourceDir; - const Zstring& targetDirFormatted = targetDir; - -#elif defined FFS_LINUX - const Zstring sourceDirFormatted = //remove trailing slash - sourceDir.size() > 1 && endsWith(sourceDir, FILE_NAME_SEPARATOR) ? //exception: allow '/' - beforeLast(sourceDir, FILE_NAME_SEPARATOR) : - sourceDir; - const Zstring targetDirFormatted = //remove trailing slash - targetDir.size() > 1 && endsWith(targetDir, FILE_NAME_SEPARATOR) ? //exception: allow '/' - beforeLast(targetDir, FILE_NAME_SEPARATOR) : - targetDir; -#endif - - ::moveDirectoryImpl(sourceDirFormatted, targetDirFormatted, callback); -} - - class FilesDirsOnlyTraverser : public zen::TraverseCallback { public: @@ -799,7 +589,7 @@ public: m_dirs.push_back(fullName); return nullptr; //DON'T traverse into subdirs; removeDirectory works recursively! } - virtual HandleError onError(const std::wstring& errorText) { throw FileError(errorText); } + virtual HandleError onError(const std::wstring& msg) { throw FileError(msg); } private: FilesDirsOnlyTraverser(const FilesDirsOnlyTraverser&); @@ -1213,20 +1003,6 @@ void copySecurityContext(const Zstring& source, const Zstring& target, ProcSymli void copyObjectPermissions(const Zstring& source, const Zstring& target, ProcSymlink procSl) //throw FileError { #ifdef FFS_WIN - //setting privileges requires admin rights! - - //enable privilege: required to read/write SACL information (only) - activatePrivilege(SE_SECURITY_NAME); //throw FileError - //Note: trying to copy SACL (SACL_SECURITY_INFORMATION) may return ERROR_PRIVILEGE_NOT_HELD (1314) on Samba shares. This is not due to missing privileges! - //However, this is okay, since copying NTFS permissions doesn't make sense in this case anyway - - //enable privilege: required to copy owner information - activatePrivilege(SE_RESTORE_NAME); //throw FileError - - //the following privilege may be required according to http://msdn.microsoft.com/en-us/library/aa364399(VS.85).aspx (although not needed nor active in my tests) - activatePrivilege(SE_BACKUP_NAME); //throw FileError - - //in contrast to ::SetSecurityInfo(), ::SetFileSecurity() seems to honor the "inherit DACL/SACL" flags //CAVEAT: if a file system does not support ACLs, GetFileSecurity() will return successfully with a *valid* security descriptor containing *no* ACL entries! @@ -1234,6 +1010,26 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, ProcSym const Zstring sourceResolved = procSl == SYMLINK_FOLLOW && symlinkExists(source) ? getSymlinkTargetPath(source) : source; const Zstring targetResolved = procSl == SYMLINK_FOLLOW && symlinkExists(target) ? getSymlinkTargetPath(target) : target; + //setting privileges requires admin rights! + try + { + //enable privilege: required to read/write SACL information (only) + activatePrivilege(SE_SECURITY_NAME); //throw FileError + //Note: trying to copy SACL (SACL_SECURITY_INFORMATION) may return ERROR_PRIVILEGE_NOT_HELD (1314) on Samba shares. This is not due to missing privileges! + //However, this is okay, since copying NTFS permissions doesn't make sense in this case anyway + + //enable privilege: required to copy owner information + activatePrivilege(SE_RESTORE_NAME); //throw FileError + + //the following privilege may be required according to http://msdn.microsoft.com/en-us/library/aa364399(VS.85).aspx (although not needed nor active in my tests) + activatePrivilege(SE_BACKUP_NAME); //throw FileError + } + catch (const FileError& e)//add some more context description (e.g. user is not an admin) + { + throw FileError(replaceCpy(_("Cannot read permissions of %x."), L"%x", fmtFileName(sourceResolved)) + L"\n\n" + e.toString()); + } + + std::vector<char> buffer(10000); //example of actually required buffer size: 192 bytes for (;;) { @@ -1571,7 +1367,8 @@ void zen::makeDirectory(const Zstring& directory) } catch (const FileError& e) { - assert(dynamic_cast<const ErrorTargetExisting*>(&e)); (void)e; + assert(dynamic_cast<const ErrorTargetExisting*>(&e)); + (void)e; //could there be situations where a directory/network path exists, but creation fails with //error different than "ErrorTargetExisting"?? => better catch all "FileError" and check existence again if (dirExists(directory)) //technically a file system race-condition! @@ -2127,7 +1924,7 @@ DWORD CALLBACK copyCallbackInternal(LARGE_INTEGER totalFileSize, //some odd check for some possible(?) error condition if (totalBytesTransferred.QuadPart < 0) //let's see if someone answers the call... ::MessageBox(nullptr, L"You've just discovered a bug in WIN32 API function \"CopyFileEx\"! \n\n\ - Please write a mail to the author of FreeFileSync at zhnmju123@gmx.de and simply state that\n\ + Please write a mail to the author of FreeFileSync at zenju@gmx.de and simply state that\n\ \"totalBytesTransferred.HighPart can be below zero\"!\n\n\ This will then be handled in future versions of FreeFileSync.\n\nThanks -ZenJu", nullptr, 0); diff --git a/zen/file_handling.h b/zen/file_handling.h index d1dcca22..12fbb31c 100644 --- a/zen/file_handling.h +++ b/zen/file_handling.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILE_HANDLING_H_INCLUDED @@ -15,7 +15,6 @@ namespace zen { struct CallbackRemoveDir; -struct CallbackMoveFile; struct CallbackCopyFile; @@ -51,14 +50,8 @@ UInt64 getFreeDiskSpace(const Zstring& path); //throw FileError bool removeFile(const Zstring& filename); //throw FileError; return "true" if file was actually deleted void removeDirectory(const Zstring& directory, CallbackRemoveDir* callback = nullptr); //throw FileError - //rename file or directory: no copying!!! -void renameFile(const Zstring& oldName, const Zstring& newName); //throw FileError - -//move source to target across volumes; prerequisite: all super-directories of target exist -//if target already contains some files/dirs they are seen as remnants of a previous incomplete move - see comment in moveDirectoryImpl -void moveFile (const Zstring& sourceFile, const Zstring& targetFile, CallbackMoveFile* callback); //throw FileError -void moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, CallbackMoveFile* callback); //throw FileError +void renameFile(const Zstring& oldName, const Zstring& newName); //throw FileError, ErrorDifferentVolume, ErrorTargetExisting bool supportsPermissions(const Zstring& dirname); //throw FileError, derefernces symlinks @@ -97,7 +90,7 @@ struct CallbackRemoveDir }; -struct CallbackCopyFile //callback functionality +struct CallbackCopyFile { virtual ~CallbackCopyFile() {} @@ -110,19 +103,6 @@ struct CallbackCopyFile //callback functionality //Windows: first exception is swallowed, updateCopyStatus() is then called again where it should throw again and exception will propagate as expected virtual void updateCopyStatus(Int64 bytesDelta) = 0; //accummulated delta != file size! consider ADS, sparse, compressed files }; - - -struct CallbackMoveFile //callback functionality -{ - virtual ~CallbackMoveFile() {} //see CallbackCopyFile for limitations when trowing exceptions! - - virtual void onBeforeFileMove(const Zstring& fileFrom, const Zstring& fileTo) = 0; //one call before each (planned) move - virtual void onBeforeDirMove (const Zstring& dirFrom, const Zstring& dirTo ) = 0; // - virtual void objectProcessed() = 0; //one call after each completed move (count objects total) - - //called frequently if move has to revert to copy + delete: - virtual void updateStatus(Int64 bytesDelta) = 0; -}; } #endif //FILE_HANDLING_H_INCLUDED diff --git a/zen/file_id.cpp b/zen/file_id.cpp index 40efa373..6730252e 100644 --- a/zen/file_id.cpp +++ b/zen/file_id.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "file_id.h" diff --git a/zen/file_id.h b/zen/file_id.h index 1170c2a2..ba11483d 100644 --- a/zen/file_id.h +++ b/zen/file_id.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILEID_H_INCLUDED diff --git a/zen/file_id_def.h b/zen/file_id_def.h index c51a0ecc..cb80dc19 100644 --- a/zen/file_id_def.h +++ b/zen/file_id_def.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILE_ID_INTERNAL_HEADER_013287632486321493 @@ -21,7 +21,10 @@ namespace zen { #ifdef FFS_WIN -typedef std::pair<DWORD, ULONGLONG> FileId; //(volume serial number, file ID) +typedef DWORD DeviceId; +typedef ULONGLONG FileIndex; + +typedef std::pair<DeviceId, FileIndex> FileId; inline FileId extractFileID(const BY_HANDLE_FILE_INFORMATION& fileInfo) @@ -49,7 +52,10 @@ assert_static(sizeof(FileId().second) == sizeof(ULARGE_INTEGER)); #elif defined FFS_LINUX namespace impl { typedef struct ::stat StatDummy; } //sigh... -typedef std::pair<decltype(impl::StatDummy::st_dev), decltype(impl::StatDummy::st_ino)> FileId; //(device id, inode) +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) diff --git a/zen/file_io.cpp b/zen/file_io.cpp index f935de7a..279b3a72 100644 --- a/zen/file_io.cpp +++ b/zen/file_io.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "file_io.h" diff --git a/zen/file_io.h b/zen/file_io.h index b134e47a..f37554f3 100644 --- a/zen/file_io.h +++ b/zen/file_io.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILEIO_H_INCLUDED diff --git a/zen/file_traverser.cpp b/zen/file_traverser.cpp index 986e0ad8..37b83ce6 100644 --- a/zen/file_traverser.cpp +++ b/zen/file_traverser.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "file_traverser.h" @@ -195,7 +195,7 @@ struct Win32Traverser hnd.searchHandle = ::FindFirstFile(applyLongPathPrefix(directoryPf + L'*').c_str(), &hnd.data); //no noticable performance difference compared to FindFirstFileEx with FindExInfoBasic, FIND_FIRST_EX_CASE_SENSITIVE and/or FIND_FIRST_EX_LARGE_FETCH if (hnd.searchHandle == INVALID_HANDLE_VALUE) - throw FileError(replaceCpy(_("Cannot read directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted()); + throw FileError(replaceCpy(_("Cannot open directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted()); //::GetLastError() == ERROR_FILE_NOT_FOUND -> *usually* NOT okay: //directory may not exist *or* it is completely empty: not all directories contain "., .." entries, e.g. a drive's root directory @@ -220,7 +220,7 @@ struct Win32Traverser if (::GetLastError() == ERROR_NO_MORE_FILES) //not an error situation return false; //else we have a problem... report it: - throw FileError(replaceCpy(_("Cannot read directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted()); + throw FileError(replaceCpy(_("Cannot enumerate directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted()); } return true; } @@ -256,7 +256,7 @@ struct FilePlusTraverser { hnd.searchHandle = ::openDir(applyLongPathPrefix(directory).c_str()); if (hnd.searchHandle == nullptr) - throw FileError(replaceCpy(_("Cannot read directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted() + L" (+)"); + throw FileError(replaceCpy(_("Cannot open directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted() + L" (+)"); } static void destroy(DirHandle hnd) { ::closeDir(hnd.searchHandle); } //throw() @@ -281,7 +281,7 @@ struct FilePlusTraverser } //else we have a problem... report it: - throw FileError(replaceCpy(_("Cannot read directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted(lastError) + L" (+)"); + throw FileError(replaceCpy(_("Cannot enumerate directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted(lastError) + L" (+)"); } return true; @@ -336,7 +336,7 @@ private: tryReportingError([&] { if (level == 100) //notify endless recursion - throw FileError(replaceCpy(_("Cannot read directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + _("Detected endless directory recursion.")); + throw FileError(replaceCpy(_("Cannot open directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + _("Detected endless directory recursion.")); }, sink); typename Trav::DirHandle searchHandle; @@ -382,29 +382,26 @@ private: switch (sink.onSymlink(shortName, fullName, linkInfo)) { case TraverseCallback::LINK_FOLLOW: - { - //try to resolve symlink (and report error on failure!!!) - TraverseCallback::FileInfo targetInfo; - const bool validLink = tryReportingError([&] + if (Trav::isDirectory(findData)) { - if (!getTargetInfoFromSymlink(fullName, targetInfo)) - throw FileError(replaceCpy(_("Cannot resolve symbolic link %x."), L"%x", fmtFileName(fullName)) + L"\n\n" + getLastErrorFormatted()); - }, sink); - - if (validLink) + if (const std::shared_ptr<TraverseCallback>& rv = sink.onDir(shortName, fullName)) + traverse<Trav>(fullName, *rv, level + 1); + } + else //a file { - if (Trav::isDirectory(findData)) + TraverseCallback::FileInfo targetInfo; + const bool validLink = tryReportingError([&] //try to resolve symlink (and report error on failure!!!) { - if (const std::shared_ptr<TraverseCallback>& rv = sink.onDir(shortName, fullName)) - traverse<Trav>(fullName, *rv, level + 1); - } - else //a file + if (!getTargetInfoFromSymlink(fullName, targetInfo)) + throw FileError(replaceCpy(_("Cannot resolve symbolic link %x."), L"%x", fmtFileName(fullName)) + L"\n\n" + getLastErrorFormatted()); + }, sink); + + if (validLink) sink.onFile(shortName, fullName, targetInfo); + else //broken symlink + sink.onFile(shortName, fullName, TraverseCallback::FileInfo()); } - else //report broken symlink as file! - sink.onFile(shortName, fullName, TraverseCallback::FileInfo()); - } - break; + break; case TraverseCallback::LINK_SKIP: break; @@ -525,7 +522,7 @@ private: tryReportingError([&] { if (level == 100) //notify endless recursion - throw FileError(replaceCpy(_("Cannot read directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + _("Detected endless directory recursion.")); + throw FileError(replaceCpy(_("Cannot open directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + _("Detected endless directory recursion.")); }, sink); @@ -534,7 +531,7 @@ private: { dirObj = ::opendir(directory.c_str()); //directory must NOT end with path separator, except "/" if (!dirObj) - throw FileError(replaceCpy(_("Cannot read directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted()); + throw FileError(replaceCpy(_("Cannot open directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted()); }, sink)) return; //ignored error ZEN_ON_SCOPE_EXIT(::closedir(dirObj)); //never close nullptr handles! -> crash @@ -545,7 +542,7 @@ private: tryReportingError([&] { if (::readdir_r(dirObj, reinterpret_cast< ::dirent*>(&buffer[0]), &dirEntry) != 0) - throw FileError(replaceCpy(_("Cannot read directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted()); + throw FileError(replaceCpy(_("Cannot enumerate directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted()); }, sink); if (!dirEntry) //no more items or ignored error return; diff --git a/zen/file_traverser.h b/zen/file_traverser.h index c29d987d..3fc9b57c 100644 --- a/zen/file_traverser.h +++ b/zen/file_traverser.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILETRAVERSER_H_INCLUDED @@ -26,6 +26,7 @@ struct TraverseCallback UInt64 fileSize; //unit: bytes! Int64 lastWriteTimeRaw; //number of seconds since Jan. 1st 1970 UTC FileId id; //optional: may be initial! + //bool isFollowedSymlink; }; struct SymlinkInfo @@ -52,7 +53,7 @@ struct TraverseCallback /**/ onDir (const Zchar* shortName, const Zstring& fullName) = 0; virtual void onFile (const Zchar* shortName, const Zstring& fullName, const FileInfo& details) = 0; virtual HandleLink onSymlink(const Zchar* shortName, const Zstring& fullName, const SymlinkInfo& details) = 0; - virtual HandleError onError (const std::wstring& errorText) = 0; + virtual HandleError onError (const std::wstring& msg) = 0; }; diff --git a/zen/fixed_list.h b/zen/fixed_list.h index 60d7e0e7..6d083f8b 100644 --- a/zen/fixed_list.h +++ b/zen/fixed_list.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FIXED_LIST_01238467085684139453534 @@ -20,12 +20,13 @@ class FixedList { Node() : next(nullptr), val() {} //no variadic templates on VC2010... :( - template <class A> Node(A&& a) : next(nullptr), val(std::forward<A>(a)) {} - template <class A, class B> Node(A&& a, B&& b) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b)) {} - template <class A, class B, class C> Node(A&& a, B&& b, C&& c) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c)) {} - template <class A, class B, class C, class D> Node(A&& a, B&& b, C&& c, D&& d) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d)) {} - template <class A, class B, class C, class D, class E> Node(A&& a, B&& b, C&& c, D&& d, E&& e) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e)) {} - template <class A, class B, class C, class D, class E, class F> Node(A&& a, B&& b, C&& c, D&& d, E&& e, F&& f) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e), std::forward<F>(f)) {} + template <class A> Node(A&& a) : next(nullptr), val(std::forward<A>(a)) {} + template <class A, class B> Node(A&& a, B&& b) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b)) {} + template <class A, class B, class C> Node(A&& a, B&& b, C&& c) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c)) {} + template <class A, class B, class C, class D> Node(A&& a, B&& b, C&& c, D&& d) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d)) {} + template <class A, class B, class C, class D, class E> Node(A&& a, B&& b, C&& c, D&& d, E&& e) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e)) {} + template <class A, class B, class C, class D, class E, class F> Node(A&& a, B&& b, C&& c, D&& d, E&& e, F&& f) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e), std::forward<F>(f)) {} + template <class A, class B, class C, class D, class E, class F, class G> Node(A&& a, B&& b, C&& c, D&& d, E&& e, F&& f, G&& g) : next(nullptr), val(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e), std::forward<F>(f), std::forward<G>(g)) {} Node* next; //singly linked list is sufficient T val; @@ -75,12 +76,13 @@ public: const_reference& back() const { return lastInsert->val; } void emplace_back() { pushNode(new Node); } - template <class A> void emplace_back(A&& a) { pushNode(new Node(std::forward<A>(a))); } - template <class A, class B> void emplace_back(A&& a, B&& b) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b))); } - template <class A, class B, class C> void emplace_back(A&& a, B&& b, C&& c) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c))); } - template <class A, class B, class C, class D> void emplace_back(A&& a, B&& b, C&& c, D&& d) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d))); } - template <class A, class B, class C, class D, class E> void emplace_back(A&& a, B&& b, C&& c, D&& d, E&& e) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e))); } - template <class A, class B, class C, class D, class E, class F> void emplace_back(A&& a, B&& b, C&& c, D&& d, E&& e, F&& f) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e), std::forward<F>(f))); } + template <class A> void emplace_back(A&& a) { pushNode(new Node(std::forward<A>(a))); } + template <class A, class B> void emplace_back(A&& a, B&& b) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b))); } + template <class A, class B, class C> void emplace_back(A&& a, B&& b, C&& c) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c))); } + template <class A, class B, class C, class D> void emplace_back(A&& a, B&& b, C&& c, D&& d) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d))); } + template <class A, class B, class C, class D, class E> void emplace_back(A&& a, B&& b, C&& c, D&& d, E&& e) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e))); } + template <class A, class B, class C, class D, class E, class F> void emplace_back(A&& a, B&& b, C&& c, D&& d, E&& e, F&& f) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e), std::forward<F>(f))); } + template <class A, class B, class C, class D, class E, class F, class G> void emplace_back(A&& a, B&& b, C&& c, D&& d, E&& e, F&& f, G&& g) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e), std::forward<F>(f), std::forward<G>(g))); } template <class Predicate> void remove_if(Predicate pred) @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef GUID_H_INCLUDED @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef I18_N_HEADER_3843489325045 diff --git a/zen/int64.h b/zen/int64.h index ea51b23b..17c34b9f 100644 --- a/zen/int64.h +++ b/zen/int64.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FFS_LARGE_64_BIT_INTEGER_H_INCLUDED diff --git a/zen/last_error.h b/zen/last_error.h index 76850f6a..e5665989 100644 --- a/zen/last_error.h +++ b/zen/last_error.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef SYSTEMFUNCTIONS_H_INCLUDED diff --git a/zen/long_path_prefix.h b/zen/long_path_prefix.h index 1476e87d..cd81b8b2 100644 --- a/zen/long_path_prefix.h +++ b/zen/long_path_prefix.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef LONGPATHPREFIX_H_INCLUDED diff --git a/zen/notify_removal.cpp b/zen/notify_removal.cpp index 35ffc4e1..e2940036 100644 --- a/zen/notify_removal.cpp +++ b/zen/notify_removal.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "notify_removal.h" diff --git a/zen/notify_removal.h b/zen/notify_removal.h index 613d5357..91e462bd 100644 --- a/zen/notify_removal.h +++ b/zen/notify_removal.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef NOTIFY_H_INCLUDED diff --git a/zen/optional.h b/zen/optional.h index 34e3d21d..4003824b 100644 --- a/zen/optional.h +++ b/zen/optional.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef OPTIONAL_H_2857428578342203589 @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef DEBUG_PERF_HEADER diff --git a/zen/privilege.h b/zen/privilege.h index b940279a..9e5f12e8 100644 --- a/zen/privilege.h +++ b/zen/privilege.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef PRIVILEGE_H_INCLUDED diff --git a/zen/read_txt.h b/zen/read_txt.h index d0e3f4dc..402403d8 100644 --- a/zen/read_txt.h +++ b/zen/read_txt.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef PARSE_TXT_H_INCLUDED diff --git a/zen/recycler.cpp b/zen/recycler.cpp index 3de795a5..3fd86c33 100644 --- a/zen/recycler.cpp +++ b/zen/recycler.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "recycler.h" diff --git a/zen/recycler.h b/zen/recycler.h index 955dfbee..8a9ab13b 100644 --- a/zen/recycler.h +++ b/zen/recycler.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef RECYCLER_H_INCLUDED diff --git a/zen/scope_guard.h b/zen/scope_guard.h index 86d22c91..f25b7dc3 100644 --- a/zen/scope_guard.h +++ b/zen/scope_guard.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef ZEN_SCOPEGUARD_8971632487321434 diff --git a/zen/serialize.h b/zen/serialize.h index ff9695b1..cc694bb5 100644 --- a/zen/serialize.h +++ b/zen/serialize.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef SERIALIZE_H_INCLUDED diff --git a/zen/stl_tools.h b/zen/stl_tools.h index ace6ebaa..8f1ee704 100644 --- a/zen/stl_tools.h +++ b/zen/stl_tools.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef STL_TOOLS_HEADER_84567184321434 diff --git a/zen/string_base.h b/zen/string_base.h index e2e9f19a..834aff05 100644 --- a/zen/string_base.h +++ b/zen/string_base.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef Z_BASE_H_INCLUDED diff --git a/zen/string_tools.h b/zen/string_tools.h index 80232086..87d5d4d0 100644 --- a/zen/string_tools.h +++ b/zen/string_tools.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef STRING_TOOLS_HEADER_213458973046 diff --git a/zen/string_traits.h b/zen/string_traits.h index eea9ae02..38ae9116 100644 --- a/zen/string_traits.h +++ b/zen/string_traits.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef STRING_TRAITS_HEADER_813274321443234 diff --git a/zen/symlink_target.h b/zen/symlink_target.h index 6d44d845..d1576990 100644 --- a/zen/symlink_target.h +++ b/zen/symlink_target.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef SYMLINK_WIN_H_INCLUDED diff --git a/zen/thread.h b/zen/thread.h index 1fda016d..cffed5ed 100644 --- a/zen/thread.h +++ b/zen/thread.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef BOOST_THREAD_WRAP_H diff --git a/zen/tick_count.h b/zen/tick_count.h index 30b0295d..5c7daa00 100644 --- a/zen/tick_count.h +++ b/zen/tick_count.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef ZEN_TICK_COUNT_HEADER_3807326 @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef ZEN_TIME_HEADER_845709281432434 @@ -164,6 +164,9 @@ struct GetFormat<FormatIsoDateTimeTag> //%Y-%m-%d %H:%M:%S - e.g. 2001-08-23 14: }; +//strftime() craziness on invalid input: +// VS 2010: CRASH unless "_invalid_parameter_handler" is set: http://msdn.microsoft.com/en-us/library/ksazx244.aspx +// GCC: returns 0, apparently no crash. Still, considering some clib maintainer's comments, we should expect the worst! inline size_t strftimeWrap(char* buffer, size_t bufferSize, const char* format, const struct std::tm* timeptr) { @@ -178,6 +181,24 @@ size_t strftimeWrap(wchar_t* buffer, size_t bufferSize, const wchar_t* format, c } +inline +bool isValid(const struct std::tm& t) +{ + auto inRange = [](int value, int minVal, int maxVal) { return minVal <= value && value <= maxVal; }; + + //http://www.cplusplus.com/reference/clibrary/ctime/tm/ + return inRange(t.tm_sec , 0, 61) && + inRange(t.tm_min , 0, 59) && + inRange(t.tm_hour, 0, 23) && + inRange(t.tm_mday, 1, 31) && + inRange(t.tm_mon , 0, 11) && + //tm_year + inRange(t.tm_wday, 0, 6) && + inRange(t.tm_yday, 0, 365); + //tm_isdst +}; + + struct UserDefinedFormatTag {}; struct PredefinedFormatTag {}; @@ -185,11 +206,13 @@ template <class String, class String2> inline String formatTime(const String2& format, const TimeComp& comp, UserDefinedFormatTag) //format as specified by "std::strftime", returns empty string on failure { typedef typename GetCharType<String>::Type CharType; - struct std::tm ctc = toClibTimeComponents(comp); std::mktime(&ctc); // unfortunately std::strftime() needs all elements of "struct tm" filled, e.g. tm_wday, tm_yday //note: although std::mktime() explicitly expects "local time", calculating weekday and day of year *should* be time-zone and DST independent + if (!isValid(ctc)) //strftime() might kill the app otherwise, std::mktime does *not* help here at all! + return String(); + CharType buffer[256]; const size_t charsWritten = strftimeWrap(buffer, 256, strBegin(format), &ctc); return String(buffer, charsWritten); @@ -209,11 +232,13 @@ TimeComp localTime(time_t utc) { #ifdef _MSC_VER struct tm lt = {}; - /*errno_t rv = */ - ::localtime_s(<, &utc); //more secure? + errno_t rv = ::localtime_s(<, &utc); //more secure? + if (rv != 0) + return TimeComp(); return implementation::toZenTimeComponents(lt); #else - return implementation::toZenTimeComponents(*std::localtime(&utc)); + struct tm* lt = std::localtime(&utc); //returns nullptr for invalid time_t on Visual 2010!!! (testvalue "-1") + return lt ? implementation::toZenTimeComponents(*lt) : TimeComp(); #endif } diff --git a/zen/type_tools.h b/zen/type_tools.h index b221954c..7bf75ae0 100644 --- a/zen/type_tools.h +++ b/zen/type_tools.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef TYPE_TOOLS_HEADER_45237590734254545 diff --git a/zen/type_traits.h b/zen/type_traits.h index 0b15eef1..4945da19 100644 --- a/zen/type_traits.h +++ b/zen/type_traits.h @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef TYPE_TRAITS_HEADER_3425628658765467 @@ -2,7 +2,7 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef STRING_UTF8_HEADER_01832479146991573473545 diff --git a/zen/warn_static.h b/zen/warn_static.h index a71308bb..6beefee7 100644 --- a/zen/warn_static.h +++ b/zen/warn_static.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef WARN_STATIC_HEADER_08724567834560832745 @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef YAWFWH_YET_ANOTHER_WRAPPER_FOR_WINDOWS_H diff --git a/zen/win_ver.h b/zen/win_ver.h index 3a6f23c1..0c18a822 100644 --- a/zen/win_ver.h +++ b/zen/win_ver.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef WINDOWS_VERSION_HEADER_238470348254325 diff --git a/zen/zstring.cpp b/zen/zstring.cpp index 182bad91..96566638 100644 --- a/zen/zstring.cpp +++ b/zen/zstring.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "zstring.h" diff --git a/zen/zstring.h b/zen/zstring.h index 94d5b1a4..ff38f966 100644 --- a/zen/zstring.h +++ b/zen/zstring.h @@ -1,7 +1,7 @@ // ************************************************************************** // * 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 (zhnmju123 AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef ZSTRING_H_INCLUDED |