From d6301fca6b78db52d0d98f8e0799aba175ad2e59 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:21:41 +0200 Subject: 5.8 --- zen/FindFilePlus/dll_main.cpp | 2 +- zen/FindFilePlus/find_file_plus.cpp | 13 +- zen/FindFilePlus/find_file_plus.h | 3 +- zen/FindFilePlus/init_dll_binding.h | 2 +- zen/FindFilePlus/load_dll.cpp | 2 +- zen/FindFilePlus/load_dll.h | 2 +- zen/IFileOperation/dll_main.cpp | 2 +- zen/IFileOperation/file_op.cpp | 2 +- zen/IFileOperation/file_op.h | 20 ++- zen/assert_static.h | 5 +- zen/base64.h | 55 +++--- zen/basic_math.h | 6 +- zen/build_info.h | 2 +- zen/com_error.h | 2 +- zen/com_ptr.h | 2 +- zen/com_util.h | 2 +- zen/debug_log.h | 2 +- zen/debug_new.cpp | 2 +- zen/debug_new.h | 2 +- zen/deprecate.h | 2 +- zen/dir_watcher.cpp | 2 +- zen/dir_watcher.h | 2 +- zen/dll.h | 20 ++- zen/error_log.h | 2 +- zen/file_error.h | 2 +- zen/file_handling.cpp | 74 ++++++-- zen/file_handling.h | 2 +- zen/file_id.cpp | 2 +- zen/file_id.h | 2 +- zen/file_id_def.h | 2 +- zen/file_io.cpp | 2 +- zen/file_io.h | 2 +- zen/file_traverser.cpp | 2 +- zen/file_traverser.h | 2 +- zen/fixed_list.h | 2 +- zen/format_unit.cpp | 342 ++++++++++++++++++++++++++++++++++++ zen/format_unit.h | 59 +++++++ zen/guid.h | 2 +- zen/i18n.h | 2 +- zen/int64.h | 2 +- zen/last_error.h | 2 +- zen/long_path_prefix.h | 2 +- zen/notify_removal.cpp | 2 +- zen/notify_removal.h | 2 +- zen/optional.h | 2 +- zen/perf.h | 2 +- zen/privilege.h | 2 +- zen/read_txt.h | 2 +- zen/recycler.cpp | 2 +- zen/recycler.h | 2 +- zen/scope_guard.h | 5 +- zen/serialize.h | 2 +- zen/stl_tools.h | 5 +- zen/string_base.h | 2 +- zen/string_tools.h | 5 +- zen/string_traits.h | 5 +- zen/symlink_target.h | 2 +- zen/thread.h | 6 +- zen/tick_count.h | 5 +- zen/time.h | 37 ++-- zen/type_tools.h | 5 +- zen/type_traits.h | 5 +- zen/utf.h | 5 +- zen/warn_static.h | 2 +- zen/win.h | 2 +- zen/win_ver.h | 7 +- zen/zstring.cpp | 2 +- zen/zstring.h | 2 +- 68 files changed, 628 insertions(+), 153 deletions(-) create mode 100644 zen/format_unit.cpp create mode 100644 zen/format_unit.h (limited to 'zen') diff --git a/zen/FindFilePlus/dll_main.cpp b/zen/FindFilePlus/dll_main.cpp index a7637be4..ab3b25a3 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 (zenju 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 9b146008..5fc1a538 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "find_file_plus.h" @@ -9,8 +9,8 @@ //#include //these two don't play nice with each other #include "load_dll.h" #include - -#include +#include +//#include using namespace dll; using namespace findplus; @@ -357,13 +357,18 @@ FindHandle findplus::openDir(const wchar_t* dirname) { try { - return new FileSearcher(dirname); //throw NtFileError + return new FileSearcher(dirname); //throw NtFileError, std::bad_alloc } catch (const NtFileError& e) { setWin32Error(rtlNtStatusToDosError(e.ntError)); return nullptr; } + catch (const std::bad_alloc&) //not unlikely in this context! => handle! + { + setWin32Error(rtlNtStatusToDosError(STATUS_NO_MEMORY)); + return nullptr; + } } diff --git a/zen/FindFilePlus/find_file_plus.h b/zen/FindFilePlus/find_file_plus.h index a2f61cdc..a26bdeb3 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 (zenju 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 @@ -87,5 +87,6 @@ const char funName_closeDir[] = "closeDir"; inline const wchar_t* getDllName() { return zen::is64BitBuild ? L"FindFilePlus_x64.dll" : L"FindFilePlus_Win32.dll"; } } +#undef DLL_FUNCTION_DECLARATION #endif //FIND_FIRST_FILE_PLUS_HEADER_087483434 diff --git a/zen/FindFilePlus/init_dll_binding.h b/zen/FindFilePlus/init_dll_binding.h index 993a3790..44591ab4 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 (zenju 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 5f72e31b..c9396f6d 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 (zenju 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 ce414733..d661c4b9 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 (zenju 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/dll_main.cpp b/zen/IFileOperation/dll_main.cpp index 95d14910..4665154a 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 (zenju 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 3861c5c0..8acc3d17 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 (zenju 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 c9df1e1e..86efc340 100644 --- a/zen/IFileOperation/file_op.h +++ b/zen/IFileOperation/file_op.h @@ -1,16 +1,16 @@ // ************************************************************************** // * 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 * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef RECYCLER_DLL_H #define RECYCLER_DLL_H #ifdef FILE_OP_DLL_EXPORTS -#define FILE_OP_DLL_API extern "C" __declspec(dllexport) +#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllexport) #else -#define FILE_OP_DLL_API extern "C" __declspec(dllimport) +#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllimport) #endif #include @@ -25,25 +25,25 @@ namespace fileop //COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize //minimum OS: Windows Vista or later -FILE_OP_DLL_API +DLL_FUNCTION_DECLARATION bool moveToRecycleBin(const wchar_t* fileNames[], size_t fileNo); //size of fileNames array -FILE_OP_DLL_API +DLL_FUNCTION_DECLARATION bool copyFile(const wchar_t* sourceFile, const wchar_t* targetFile); -FILE_OP_DLL_API +DLL_FUNCTION_DECLARATION bool checkRecycler(const wchar_t* dirname, bool& isRecycler); //returns false on error -FILE_OP_DLL_API +DLL_FUNCTION_DECLARATION bool getLockingProcesses(const wchar_t* filename, const wchar_t*& procList); //get list of processes as single string, call freeString(procList) after use! -FILE_OP_DLL_API +DLL_FUNCTION_DECLARATION void freeString(const wchar_t* str); //get last error message if any of the functions above fail -FILE_OP_DLL_API +DLL_FUNCTION_DECLARATION const wchar_t* getLastError(); //no nullptr check required! /*---------- @@ -73,4 +73,6 @@ const char funName_getLastError [] = "getLastError"; inline const wchar_t* getDllName() { return zen::is64BitBuild ? L"FileOperation_x64.dll" : L"FileOperation_Win32.dll"; } } +#undef DLL_FUNCTION_DECLARATION + #endif //RECYCLER_DLL_H diff --git a/zen/assert_static.h b/zen/assert_static.h index 0f2a150a..c5b7f8c1 100644 --- a/zen/assert_static.h +++ b/zen/assert_static.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * 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 fd4e3611..5f18ea36 100644 --- a/zen/base64.h +++ b/zen/base64.h @@ -1,31 +1,31 @@ // ************************************************************************** // * 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef BASE64_HEADER_08473021856321840873021487213453214 #define BASE64_HEADER_08473021856321840873021487213453214 +#ifndef NDEBUG //no release build dependencies! #include #include -#include "assert_static.h" +#endif namespace zen { //http://en.wikipedia.org/wiki/Base64 /* Usage: - const std::string input = "Sample text"; + const std::string input = "Sample text"; std::string output; zen::encodeBase64(input.begin(), input.end(), std::back_inserter(output)); //output contains "U2FtcGxlIHRleHQ=" */ template -OutputIterator encodeBase64(InputIterator first, InputIterator last, OutputIterator result); //throw () +OutputIterator encodeBase64(InputIterator first, InputIterator last, OutputIterator result); //nothrow! template -OutputIterator decodeBase64(InputIterator first, InputIterator last, OutputIterator result); //throw () +OutputIterator decodeBase64(InputIterator first, InputIterator last, OutputIterator result); //nothrow! @@ -38,14 +38,11 @@ OutputIterator decodeBase64(InputIterator first, InputIterator last, OutputItera - - - - -//---------------------------------------- implementation ---------------------------------------- +//------------------------- implementation ------------------------------- namespace implementation { -const char ENCODING_MIME[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; //64 chars for base64 encoding + padding char +//64 chars for base64 encoding + padding char +const char ENCODING_MIME[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; const signed char DECODING_MIME[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -57,7 +54,7 @@ const signed char DECODING_MIME[] = -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 }; -const size_t INDEX_PAD = 64; +const unsigned char INDEX_PAD = 64; //"=" } @@ -66,12 +63,12 @@ template inline OutputIterator encodeBase64(InputIterator first, InputIterator last, OutputIterator result) { using namespace implementation; - assert_static(sizeof(std::iterator_traits::value_type) == 1); - assert_static(sizeof(ENCODING_MIME) == 65 + 1); + static_assert(sizeof(typename std::iterator_traits::value_type) == 1, ""); + static_assert(sizeof(ENCODING_MIME) == 65 + 1, ""); while (first != last) { - const unsigned char a = *first++; + const unsigned char a = static_cast(*first++); *result++ = ENCODING_MIME[a >> 2]; if (first == last) @@ -81,7 +78,7 @@ OutputIterator encodeBase64(InputIterator first, InputIterator last, OutputItera *result++ = ENCODING_MIME[INDEX_PAD]; break; } - const unsigned char b = *first++; + const unsigned char b = static_cast(*first++); *result++ = ENCODING_MIME[((a & 0x3) << 4) | (b >> 4)]; if (first == last) @@ -90,7 +87,7 @@ OutputIterator encodeBase64(InputIterator first, InputIterator last, OutputItera *result++ = ENCODING_MIME[INDEX_PAD]; break; } - const unsigned char c = *first++; + const unsigned char c = static_cast(*first++); *result++ = ENCODING_MIME[((b & 0xf) << 2) | (c >> 6)]; *result++ = ENCODING_MIME[c & 0x3f]; } @@ -103,10 +100,10 @@ template inline OutputIterator decodeBase64(InputIterator first, InputIterator last, OutputIterator result) { using namespace implementation; - assert_static(sizeof(std::iterator_traits::value_type) == 1); - assert_static(sizeof(DECODING_MIME) == 128); + static_assert(sizeof(typename std::iterator_traits::value_type) == 1, ""); + static_assert(sizeof(DECODING_MIME) == 128, ""); - const int INDEX_END = INDEX_PAD + 1; + const unsigned char INDEX_END = INDEX_PAD + 1; auto readIndex = [&]() -> unsigned char //return index within [0, 64] or INDEX_END if end of input { @@ -115,17 +112,17 @@ OutputIterator decodeBase64(InputIterator first, InputIterator last, OutputItera if (first == last) return INDEX_END; - unsigned char ch = *first++; - if (ch < 128) //skip all unknown characters (including carriage return, line-break, tab) + const unsigned char ch = static_cast(*first++); + if (ch < 128) //we're in lower ASCII table half { const int index = implementation::DECODING_MIME[ch]; - if (0 <= index && index <= INDEX_PAD) //respect padding + if (0 <= index && index <= static_cast(INDEX_PAD)) //skip all unknown characters (including carriage return, line-break, tab) return index; } } }; - while (true) + for (;;) { const unsigned char index1 = readIndex(); const unsigned char index2 = readIndex(); @@ -134,7 +131,7 @@ OutputIterator decodeBase64(InputIterator first, InputIterator last, OutputItera assert(index1 == INDEX_END && index2 == INDEX_END); break; } - *result++ = (index1 << 2) | (index2 >> 4); + *result++ = static_cast((index1 << 2) | (index2 >> 4)); const unsigned char index3 = readIndex(); if (index3 >= INDEX_PAD) //padding @@ -142,7 +139,7 @@ OutputIterator decodeBase64(InputIterator first, InputIterator last, OutputItera assert(index3 == INDEX_PAD); break; } - *result++ = ((index2 & 0xf) << 4) | (index3 >> 2); + *result++ = static_cast(((index2 & 0xf) << 4) | (index3 >> 2)); const unsigned char index4 = readIndex(); if (index4 >= INDEX_PAD) //padding @@ -150,7 +147,7 @@ OutputIterator decodeBase64(InputIterator first, InputIterator last, OutputItera assert(index4 == INDEX_PAD); break; } - *result++ = ((index3 & 0x3) << 6) | index4; + *result++ = static_cast(((index3 & 0x3) << 6) | index4); } return result; } diff --git a/zen/basic_math.h b/zen/basic_math.h index 2c0381bf..7923dc5d 100644 --- a/zen/basic_math.h +++ b/zen/basic_math.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef BASIC_MATH_HEADER_34726398432 @@ -14,7 +13,6 @@ #include #include - namespace numeric { template diff --git a/zen/build_info.h b/zen/build_info.h index 822a78d1..d69a8c1c 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 (zenju 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 f5463d68..eaa7744f 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 (zenju 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 9328d645..bb52b5cb 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 (zenju 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 ac733566..4f7cd0b8 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 (zenju 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 04c42a91..45283da5 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 (zenju 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 f8273163..ea7771b4 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "debug_new.h" diff --git a/zen/debug_new.h b/zen/debug_new.h index ed732a87..6007344d 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef DEBUGNEW_H_INCLUDED diff --git a/zen/deprecate.h b/zen/deprecate.h index cd7c1e08..56f8e27c 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 (zenju 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 a76c0cc3..c6f0b5e6 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "dir_watcher.h" diff --git a/zen/dir_watcher.h b/zen/dir_watcher.h index 52a08226..56497040 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef DIR_WATCHER_348577025748023458 diff --git a/zen/dll.h b/zen/dll.h index 837e21a0..6f139ac3 100644 --- a/zen/dll.h +++ b/zen/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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef DLLLOADER_H_INCLUDED @@ -20,9 +20,13 @@ Manage DLL function and library ownership - full value semantics Usage: - typedef BOOL (WINAPI* IsWow64ProcessFun)(HANDLE hProcess, PBOOL Wow64Process); - const zen::SysDllFun isWow64Process(L"kernel32.dll", "IsWow64Process"); - if (isWow64Process) ... use function ptr ... + typedef BOOL (WINAPI* IsWow64ProcessFun)(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(getDllName(), dll_ns::funName_##name); + DEF_DLL_FUN(funname1); DEF_DLL_FUN(funname2); DEF_DLL_FUN(funname3); */ template @@ -32,15 +36,13 @@ public: DllFun() : fun(nullptr) {} DllFun(const wchar_t* libraryName, const char* functionName) : - hLibRef(new HMODULE(::LoadLibrary(libraryName)), deleter), - fun(*hLibRef ? reinterpret_cast(::GetProcAddress(*hLibRef, functionName)) : nullptr) {} + hLibRef(::LoadLibrary(libraryName), ::FreeLibrary), + fun(hLibRef ? reinterpret_cast(::GetProcAddress(static_cast(hLibRef.get()), functionName)) : nullptr) {} operator Func() const { return fun; } private: - static void deleter(HMODULE* ptr) { if (*ptr) ::FreeLibrary(*ptr); delete ptr; } - - std::shared_ptr hLibRef; + std::shared_ptr hLibRef; //we would prefer decltype(*HMODULE()) if only it would work... Func fun; }; diff --git a/zen/error_log.h b/zen/error_log.h index c591e470..e42ca89d 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 (zenju 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 e5ff6515..f107a736 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILEERROR_H_INCLUDED diff --git a/zen/file_handling.cpp b/zen/file_handling.cpp index 732c90f4..a646a13f 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "file_handling.h" @@ -13,15 +13,15 @@ #include "symlink_target.h" #include "file_io.h" #include "assert_static.h" -#include #include "file_id_def.h" +#include #ifdef FFS_WIN +#include #include "privilege.h" #include "dll.h" #include "win.h" //includes "windows.h" #include "long_path_prefix.h" -#include #include "dst_hack.h" #include "win_ver.h" #include "IFileOperation/file_op.h" @@ -269,8 +269,8 @@ DWORD retrieveVolumeSerial(const Zstring& pathName) //return 0 on error! return volumeSerial; } -#elif defined FFS_LINUX +#elif defined FFS_LINUX dev_t retrieveVolumeSerial(const Zstring& pathName) //return 0 on error! { Zstring volumePathName = pathName; @@ -655,6 +655,10 @@ void zen::removeDirectory(const Zstring& directory, CallbackRemoveDir* callback) if (::rmdir(directory.c_str()) != 0) #endif throw FileError(replaceCpy(_("Cannot delete directory %x."), L"%x", fmtFileName(directory)) + L"\n\n" + getLastErrorFormatted()); + //may spuriously fail with ERROR_DIR_NOT_EMPTY(145) even though all child items have + //successfully been *marked* for deletion, but some application still has a handle open! + //e.g. Open "C:\Test\Dir1\Dir2" (filled with lots of files) in Explorer, then delete "C:\Test\Dir1" via ::RemoveDirectory() => Error 145 + //Sample code: http://us.generation-nt.com/answer/createfile-directory-handles-removing-parent-help-29126332.html if (callback) callback->notifyDirDeletion(directory); //and once per folder @@ -834,8 +838,56 @@ void zen::setFileTime(const Zstring& filename, const Int64& modificationTime, Pr } } + std::wstring errorMsg = replaceCpy(_("Cannot write modification time of %x."), L"%x", fmtFileName(filename)) + L"\n\n" + getLastErrorFormatted(lastErr); + + //add more meaningful message: FAT accepts only a subset of the NTFS date range + if (lastErr == ERROR_INVALID_PARAMETER && + dst::isFatDrive(filename)) + { + //we need a low-level reliable routine to format a potentially invalid date => don't use strftime!!! + auto fmtDate = [](const FILETIME& ft) -> Zstring + { + SYSTEMTIME st = {}; + if (!::FileTimeToSystemTime(&ft, //__in const FILETIME *lpFileTime, + &st)) //__out LPSYSTEMTIME lpSystemTime + return Zstring(); + + Zstring dateTime; + { + const int bufferSize = ::GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, nullptr, nullptr, 0); + if (bufferSize > 0) + { + std::vector buffer(bufferSize); + if (::GetDateFormat(LOCALE_USER_DEFAULT, //_In_ LCID Locale, + 0, //_In_ DWORD dwFlags, + &st, //_In_opt_ const SYSTEMTIME *lpDate, + nullptr, //_In_opt_ LPCTSTR lpFormat, + &buffer[0], //_Out_opt_ LPTSTR lpDateStr, + bufferSize) > 0) //_In_ int cchDate + dateTime = &buffer[0]; //GetDateFormat() returns char count *including* 0-termination! + } + } + + const int bufferSize = ::GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, nullptr, nullptr, 0); + if (bufferSize > 0) + { + std::vector buffer(bufferSize); + if (::GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, nullptr, &buffer[0], bufferSize) > 0) + { + dateTime += L" "; + dateTime += &buffer[0]; //GetDateFormat() returns char count *including* 0-termination! + } + } + return dateTime; + }; + + errorMsg += std::wstring(L"\nA FAT volume can only store dates between 1980 and 2107:\n") + + L"\twrite (UTC): \t" + fmtDate(lastWriteTime) + + (!isNullTime(creationTime) ? L"\n\tcreate (UTC): \t" + fmtDate(creationTime) : L""); + } + if (lastErr != ERROR_SUCCESS) - throw FileError(replaceCpy(_("Cannot write modification time of %x."), L"%x", fmtFileName(filename)) + L"\n\n" + getLastErrorFormatted(lastErr)); + throw FileError(errorMsg); } #ifndef NDEBUG //dst hack: verify data written @@ -1926,7 +1978,7 @@ DWORD CALLBACK copyCallbackInternal(LARGE_INTEGER totalFileSize, ::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 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", + This will then be handled in future versions of FreeFileSync.\n\nThanks -Zenju", nullptr, 0); try { @@ -1971,7 +2023,9 @@ void copyFileWindowsDefault(const Zstring& sourceFile, //if (supportUnbufferedCopy) //see http://blogs.technet.com/b/askperf/archive/2007/05/08/slow-large-file-copy-issues.aspx // copyFlags |= COPY_FILE_NO_BUFFERING; //no perf difference at worst, huge improvement for large files (20% in test NTFS -> NTFS) - //It's a shame this flag causes file corruption! https://sourceforge.net/tracker/?func=detail&atid=1093080&aid=3529683&group_id=234430 + //It's a shame this flag causes file corruption! https://sourceforge.net/projects/freefilesync/forums/forum/847542/topic/5177950 + //documentation on CopyFile2() even states: "It is not recommended to pause copies that are using this flag." How dangerous is this thing, why offer it at all??? + //perf advantage: ~15% faster CallbackData cbd(callback, sourceFile, targetFile); @@ -2043,12 +2097,12 @@ void copyFileWindowsDefault(const Zstring& sourceFile, //DST hack const Int64 modTime = getFileTime(sourceFile, SYMLINK_FOLLOW); //throw FileError setFileTime(targetFile, modTime, SYMLINK_FOLLOW); //throw FileError + //caveat: - ::CopyFileEx() silently *ignores* failure to set modification time!!! => we need to set again in order to catch such errors! + // - this sequence leads to a loss of precision of up to 1 sec! + // - perf-loss on USB sticks with many small files of about 30%! damn! if (newAttrib) newAttrib->modificationTime = modTime; - - //note: this sequence leads to a loss of precision of up to 1 sec! - //perf-loss on USB sticks with many small files of about 30%! damn! } guardTarget.dismiss(); //target has been created successfully! diff --git a/zen/file_handling.h b/zen/file_handling.h index 12fbb31c..878c467c 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILE_HANDLING_H_INCLUDED diff --git a/zen/file_id.cpp b/zen/file_id.cpp index 6730252e..3d04ce34 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 (zenju 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 ba11483d..9f73a29b 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 (zenju 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 cb80dc19..5f485c68 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILE_ID_INTERNAL_HEADER_013287632486321493 diff --git a/zen/file_io.cpp b/zen/file_io.cpp index 279b3a72..0b5586b0 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 (zenju 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 f37554f3..b4d58ea4 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 (zenju 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 37b83ce6..a95f5dee 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #include "file_traverser.h" diff --git a/zen/file_traverser.h b/zen/file_traverser.h index 3fc9b57c..d8a99a4d 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FILETRAVERSER_H_INCLUDED diff --git a/zen/fixed_list.h b/zen/fixed_list.h index 6d083f8b..e3083c89 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef FIXED_LIST_01238467085684139453534 diff --git a/zen/format_unit.cpp b/zen/format_unit.cpp new file mode 100644 index 00000000..8e5b04d3 --- /dev/null +++ b/zen/format_unit.cpp @@ -0,0 +1,342 @@ +// ************************************************************************** +// * 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 * +// ************************************************************************** + +#include "format_unit.h" +#include +#include +#include +#include //swprintf +#include +#include + +#ifdef FFS_WIN +#include //includes "windows.h" +#include + +#elif defined FFS_LINUX +#include //thousands separator +#include // +#endif + +using namespace zen; + + +std::wstring zen::filesizeToShortString(Int64 size) +{ + //if (size < 0) return _("Error"); -> really? there's at least one exceptional case: a failed rename operation falls-back to copy + delete, reducing "bytes transferred" to potentially < 0! + + if (numeric::abs(size) <= 999) + return replaceCpy(_P("1 Byte", "%x Bytes", to(size)), + L"%x", + numberTo(size)); + else + { + double filesize = to(size); + + filesize /= 1024; + std::wstring output = _("%x KB"); + if (numeric::abs(filesize) > 999) + { + filesize /= 1024; + output = _("%x MB"); + if (numeric::abs(filesize) > 999) + { + filesize /= 1024; + output = _("%x GB"); + if (numeric::abs(filesize) > 999) + { + filesize /= 1024; + output = _("%x TB"); + if (numeric::abs(filesize) > 999) + { + filesize /= 1024; + output = _("%x PB"); + } + } + } + } + //print just three significant digits: 0,01 | 0,11 | 1,11 | 11,1 | 111 + const size_t fullunits = static_cast(numeric::abs(filesize)); + const int precisionDigits = fullunits < 10 ? 2 : fullunits < 100 ? 1 : 0; //sprintf requires "int" + + wchar_t buffer[50]; +#ifdef __MINGW32__ + int charsWritten = ::snwprintf(buffer, 50, L"%.*f", precisionDigits, filesize); //MinGW does not comply to the C standard here +#else + int charsWritten = std::swprintf(buffer, 50, L"%.*f", precisionDigits, filesize); +#endif + return charsWritten > 0 ? replaceCpy(output, L"%x", std::wstring(buffer, charsWritten)) : _("Error"); + } +} + + +enum UnitRemTime +{ + URT_SEC, + URT_MIN, + URT_HOUR, + URT_DAY +}; + +std::wstring zen::remainingTimeToShortString(double timeInSec) +{ + double remainingTime = timeInSec; + + //determine preferred unit + UnitRemTime unit = URT_SEC; + if (remainingTime > 59) + { + unit = URT_MIN; + remainingTime /= 60; + if (remainingTime > 59) + { + unit = URT_HOUR; + remainingTime /= 60; + if (remainingTime > 23) + { + unit = URT_DAY; + remainingTime /= 24; + } + } + } + + int formattedTime = numeric::round(remainingTime); + + //reduce precision to 5 seconds + if (unit == URT_SEC) + formattedTime = static_cast(std::ceil(formattedTime / 5.0) * 5); + + //generate output message + std::wstring output; + switch (unit) + { + case URT_SEC: + output = _P("1 sec", "%x sec", formattedTime); + break; + case URT_MIN: + output = _P("1 min", "%x min", formattedTime); + break; + case URT_HOUR: + output = _P("1 hour", "%x hours", formattedTime); + break; + case URT_DAY: + output = _P("1 day", "%x days", formattedTime); + break; + } + return replaceCpy(output, L"%x", zen::numberTo(formattedTime)); +} + + +std::wstring zen::fractionToShortString(double fraction) +{ + //return replaceCpy(_("%x%"), L"%x", printNumber(L"%3.2f", fraction * 100.0), false); + return printNumber(L"%3.2f", fraction * 100.0) + L'%'; //no need to internationalize fraction!? +} + + +#ifdef FFS_WIN +namespace +{ +bool getUserSetting(LCTYPE lt, UINT& setting) +{ + return ::GetLocaleInfo(LOCALE_USER_DEFAULT, //__in LCID Locale, + lt | LOCALE_RETURN_NUMBER, //__in LCTYPE LCType, + reinterpret_cast(&setting), //__out LPTSTR lpLCData, + sizeof(setting) / sizeof(TCHAR)) > 0; //__in int cchData +} + + +bool getUserSetting(LCTYPE lt, std::wstring& setting) +{ + int bufferSize = ::GetLocaleInfo(LOCALE_USER_DEFAULT, lt, nullptr, 0); + if (bufferSize > 0) + { + std::vector buffer(bufferSize); + if (::GetLocaleInfo(LOCALE_USER_DEFAULT, //__in LCID Locale, + lt, //__in LCTYPE LCType, + &buffer[0], //__out LPTSTR lpLCData, + bufferSize) > 0) //__in int cchData + { + setting = &buffer[0]; //GetLocaleInfo() returns char count *including* 0-termination! + return true; + } + } + return false; +} + +class IntegerFormat +{ +public: + static const NUMBERFMT& get() { return getInst().fmt; } + static bool isValid() { return getInst().valid_; } + +private: + static const IntegerFormat& getInst() + { + static IntegerFormat inst; //not threadsafe in MSVC until C++11, but not required right now + return inst; + } + + IntegerFormat() : fmt(), valid_(false) + { + //all we want is default NUMBERFMT, but set NumDigits to 0 + fmt.NumDigits = 0; + + //what a disgrace: + std::wstring grouping; + if (getUserSetting(LOCALE_ILZERO, fmt.LeadingZero) && + getUserSetting(LOCALE_SGROUPING, grouping) && + getUserSetting(LOCALE_SDECIMAL, decimalSep) && + getUserSetting(LOCALE_STHOUSAND, thousandSep) && + getUserSetting(LOCALE_INEGNUMBER, fmt.NegativeOrder)) + { + fmt.lpDecimalSep = &decimalSep[0]; //not used + fmt.lpThousandSep = &thousandSep[0]; + + //convert LOCALE_SGROUPING to Grouping: http://blogs.msdn.com/b/oldnewthing/archive/2006/04/18/578251.aspx + replace(grouping, L';', L""); + if (endsWith(grouping, L'0')) + grouping.resize(grouping.size() - 1); + else + grouping += L'0'; + fmt.Grouping = stringTo(grouping); + valid_ = true; + } + } + + NUMBERFMT fmt; + std::wstring thousandSep; + std::wstring decimalSep; + bool valid_; +}; +} +#endif + + +std::wstring zen::ffs_Impl::includeNumberSeparator(const std::wstring& number) +{ +#ifdef FFS_WIN + if (IntegerFormat::isValid()) + { + int bufferSize = ::GetNumberFormat(LOCALE_USER_DEFAULT, 0, number.c_str(), &IntegerFormat::get(), nullptr, 0); + if (bufferSize > 0) + { + std::vector buffer(bufferSize); + if (::GetNumberFormat(LOCALE_USER_DEFAULT, //__in LCID Locale, + 0, //__in DWORD dwFlags, + number.c_str(), //__in LPCTSTR lpValue, + &IntegerFormat::get(), //__in_opt const NUMBERFMT *lpFormat, + &buffer[0], //__out_opt LPTSTR lpNumberStr, + bufferSize) > 0) //__in int cchNumber + return &buffer[0]; //GetNumberFormat() returns char count *including* 0-termination! + } + } + return number; + +#else + //we have to include thousands separator ourselves; this doesn't work for all countries (e.g india), but is better than nothing + + //::setlocale (LC_ALL, ""); -> implicitly called by wxLocale + const lconv* localInfo = ::localeconv(); //always bound according to doc + const std::wstring& thousandSep = utfCvrtTo(localInfo->thousands_sep); + + // THOUSANDS_SEPARATOR = std::use_facet >(std::locale("")).thousands_sep(); - why not working? + // DECIMAL_POINT = std::use_facet >(std::locale("")).decimal_point(); + + std::wstring output(number); + size_t i = output.size(); + for (;;) + { + if (i <= 3) + break; + i -= 3; + if (!isDigit(output[i - 1])) + break; + output.insert(i, thousandSep); + } + return output; +#endif +} + +/* +#include + +void zen::scrollToBottom(wxScrolledWindow* scrWindow) +{ + int height = 0; + scrWindow->GetClientSize(nullptr, &height); + + int pixelPerLine = 0; + scrWindow->GetScrollPixelsPerUnit(nullptr, &pixelPerLine); + + if (height > 0 && pixelPerLine > 0) + { + const int scrollLinesTotal = scrWindow->GetScrollLines(wxVERTICAL); + const int scrollLinesOnScreen = height / pixelPerLine; + const int scrollPosBottom = scrollLinesTotal - scrollLinesOnScreen; + + if (0 <= scrollPosBottom) + scrWindow->Scroll(0, scrollPosBottom); + } +} +*/ + +#ifdef FFS_WIN +namespace +{ +const bool useNewLocalTimeCalculation = zen::vistaOrLater(); +} +#endif + + +std::wstring zen::utcToLocalTimeString(Int64 utcTime) +{ + auto errorMsg = [&] { return _("Error") + L" (time_t: " + numberTo(utcTime) + L")"; }; + +#ifdef FFS_WIN + FILETIME lastWriteTimeUtc = tofiletime(utcTime); //convert ansi C time to FILETIME + + SYSTEMTIME systemTimeLocal = {}; + + if (useNewLocalTimeCalculation) //use DST setting from source date (like in Windows 7, see http://msdn.microsoft.com/en-us/library/ms724277(VS.85).aspx + { + SYSTEMTIME systemTimeUtc = {}; + if (!::FileTimeToSystemTime(&lastWriteTimeUtc, //__in const FILETIME *lpFileTime, + &systemTimeUtc)) //__out LPSYSTEMTIME lpSystemTime + return errorMsg(); + + if (!::SystemTimeToTzSpecificLocalTime(nullptr, //__in_opt LPTIME_ZONE_INFORMATION lpTimeZone, + &systemTimeUtc, //__in LPSYSTEMTIME lpUniversalTime, + &systemTimeLocal)) //__out LPSYSTEMTIME lpLocalTime + return errorMsg(); + } + else //use DST setting (like in Windows 2000 and XP) + { + FILETIME fileTimeLocal = {}; + if (!::FileTimeToLocalFileTime(&lastWriteTimeUtc, //_In_ const FILETIME *lpFileTime, + &fileTimeLocal)) //_Out_ LPFILETIME lpLocalFileTime + return errorMsg(); + + if (!::FileTimeToSystemTime(&fileTimeLocal, //__in const FILETIME *lpFileTime, + &systemTimeLocal)) //__out LPSYSTEMTIME lpSystemTime + return errorMsg(); + } + + zen::TimeComp loc; + loc.year = systemTimeLocal.wYear; + loc.month = systemTimeLocal.wMonth; + loc.day = systemTimeLocal.wDay; + loc.hour = systemTimeLocal.wHour; + loc.minute = systemTimeLocal.wMinute; + loc.second = systemTimeLocal.wSecond; + +#elif defined FFS_LINUX + zen::TimeComp loc = zen::localTime(to(utcTime)); +#endif + + std::wstring dateString = formatTime(L"%x %X", loc); + return !dateString.empty() ? dateString : errorMsg(); +} diff --git a/zen/format_unit.h b/zen/format_unit.h new file mode 100644 index 00000000..f634e5e5 --- /dev/null +++ b/zen/format_unit.h @@ -0,0 +1,59 @@ +// ************************************************************************** +// * 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 FMT_UNIT_8702184019487324 +#define FMT_UNIT_8702184019487324 + +#include +#include +#include + +namespace zen +{ +std::wstring filesizeToShortString(Int64 filesize); +std::wstring remainingTimeToShortString(double timeInSec); +std::wstring fractionToShortString(double fraction); //within [0, 1] + +template +std::wstring toGuiString(NumberType number); //format integer number including thousands separator + +std::wstring utcToLocalTimeString(Int64 utcTime); //like Windows Explorer would... + + + + + + + + + + + + + + + + + + + + + +//--------------- inline impelementation ------------------------------------------- +namespace ffs_Impl +{ +std::wstring includeNumberSeparator(const std::wstring& number); +} + +template inline +std::wstring toGuiString(NumberType number) +{ + //assert_static(IsInteger::value); -> doesn't work for UInt64 + return ffs_Impl::includeNumberSeparator(zen::numberTo(number)); +} +} + +#endif diff --git a/zen/guid.h b/zen/guid.h index 5308af6a..823f4431 100644 --- a/zen/guid.h +++ b/zen/guid.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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef GUID_H_INCLUDED diff --git a/zen/i18n.h b/zen/i18n.h index ece55311..217d506c 100644 --- a/zen/i18n.h +++ b/zen/i18n.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 (zenju 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 17c34b9f..238efb14 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 (zenju 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 e5665989..356192ab 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 (zenju 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 cd81b8b2..80b5453e 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 (zenju 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 e2940036..29958f0c 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 (zenju 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 91e462bd..dc8149a0 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 (zenju 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 4003824b..4d85e53a 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef OPTIONAL_H_2857428578342203589 diff --git a/zen/perf.h b/zen/perf.h index 8760ef0b..c8a14950 100644 --- a/zen/perf.h +++ b/zen/perf.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 (zenju 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 9e5f12e8..70d5b7f1 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 (zenju 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 402403d8..0678ac52 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 (zenju 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 3fd86c33..6593540a 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 (zenju 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 8a9ab13b..cdadf371 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 (zenju 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 f25b7dc3..7d79e115 100644 --- a/zen/scope_guard.h +++ b/zen/scope_guard.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * 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 cc694bb5..d22e3cea 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 (zenju 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 8f1ee704..52f9f916 100644 --- a/zen/stl_tools.h +++ b/zen/stl_tools.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * 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 834aff05..19bf6267 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 (zenju 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 87d5d4d0..32d12119 100644 --- a/zen/string_tools.h +++ b/zen/string_tools.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * 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 38ae9116..93e8c510 100644 --- a/zen/string_traits.h +++ b/zen/string_traits.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * 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 d1576990..1a616559 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 (zenju 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 cffed5ed..440940ce 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef BOOST_THREAD_WRAP_H @@ -86,6 +86,10 @@ private: //###################### implementation ###################### +#ifndef BOOST_HAS_THREADS +#error just some paranoia check... +#endif + template inline auto async2(Function fun) -> boost::unique_future //workaround VS2010 bug: bool (*fun)(); decltype(fun()) == int! { diff --git a/zen/tick_count.h b/zen/tick_count.h index 5c7daa00..962ebcb0 100644 --- a/zen/tick_count.h +++ b/zen/tick_count.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef ZEN_TICK_COUNT_HEADER_3807326 diff --git a/zen/time.h b/zen/time.h index 932deca8..aa1613cc 100644 --- a/zen/time.h +++ b/zen/time.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef ZEN_TIME_HEADER_845709281432434 @@ -11,7 +10,6 @@ #include #include "string_tools.h" - namespace zen { struct TimeComp //replaces "struct std::tm" and SYSTEMTIME @@ -168,23 +166,28 @@ struct GetFormat //%Y-%m-%d %H:%M:%S - e.g. 2001-08-23 14: // 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) +size_t strftimeWrap_impl(char* buffer, size_t bufferSize, const char* format, const struct std::tm* timeptr) { return std::strftime(buffer, bufferSize, format, timeptr); } inline -size_t strftimeWrap(wchar_t* buffer, size_t bufferSize, const wchar_t* format, const struct std::tm* timeptr) +size_t strftimeWrap_impl(wchar_t* buffer, size_t bufferSize, const wchar_t* format, const struct std::tm* timeptr) { return std::wcsftime(buffer, bufferSize, format, timeptr); } - +/* inline bool isValid(const struct std::tm& t) { - auto inRange = [](int value, int minVal, int maxVal) { return minVal <= value && value <= maxVal; }; + -> not enough! MSCRT has different limits than the C standard which even seem to change with different versions: + _VALIDATE_RETURN((( timeptr->tm_sec >=0 ) && ( timeptr->tm_sec <= 59 ) ), EINVAL, FALSE) + _VALIDATE_RETURN(( timeptr->tm_year >= -1900 ) && ( timeptr->tm_year <= 8099 ), EINVAL, FALSE) + -> also std::mktime does *not* help here at all! + + 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) && @@ -197,6 +200,21 @@ bool isValid(const struct std::tm& t) inRange(t.tm_yday, 0, 365); //tm_isdst }; +*/ + +template inline +size_t strftimeWrap(CharType* buffer, size_t bufferSize, const CharType* format, const struct std::tm* timeptr) +{ +#if defined _MSC_VER && !defined NDEBUG + //it's no use: application init must register an invalid parameter that does nothing !!! + //=> strftime will abort with 0 and set errno to EINVAL instead of CRASH THE APPLICATION! + _invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(nullptr); + assert(oldHandler); + _set_invalid_parameter_handler(oldHandler); +#endif + + return strftimeWrap_impl(buffer, bufferSize, format, timeptr); +} struct UserDefinedFormatTag {}; @@ -210,9 +228,6 @@ String formatTime(const String2& format, const TimeComp& comp, UserDefinedFormat 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); diff --git a/zen/type_tools.h b/zen/type_tools.h index 7bf75ae0..c83e8f1e 100644 --- a/zen/type_tools.h +++ b/zen/type_tools.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * 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 4945da19..15352e8c 100644 --- a/zen/type_traits.h +++ b/zen/type_traits.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef TYPE_TRAITS_HEADER_3425628658765467 diff --git a/zen/utf.h b/zen/utf.h index fa96dcb1..27804a21 100644 --- a/zen/utf.h +++ b/zen/utf.h @@ -1,8 +1,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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt * +// * 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 6beefee7..70679a12 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef WARN_STATIC_HEADER_08724567834560832745 diff --git a/zen/win.h b/zen/win.h index ebc54064..45487a09 100644 --- a/zen/win.h +++ b/zen/win.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 (zenju 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 0c18a822..2c5e2f81 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef WINDOWS_VERSION_HEADER_238470348254325 @@ -15,6 +15,7 @@ bool winXpOrLater(); bool winServer2003orLater(); bool vistaOrLater(); bool win7OrLater(); +bool win8OrLater(); @@ -35,6 +36,7 @@ bool win7OrLater(); //Server 2003 is version 5.2 //Vista is version 6.0 //Seven is version 6.1 +//Eight is version 6.2 namespace impl { @@ -60,6 +62,9 @@ bool vistaOrLater() { return impl::winXyOrLater(6, 0); } inline bool win7OrLater() { return impl::winXyOrLater(6, 1); } + +inline +bool win8OrLater() { return impl::winXyOrLater(6, 2); } } #endif //WINDOWS_VERSION_HEADER_238470348254325 diff --git a/zen/zstring.cpp b/zen/zstring.cpp index 96566638..a1913755 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 (zenju 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 ff38f966..9d93d2d3 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 (zenju AT gmx DOT de) - All Rights Reserved * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef ZSTRING_H_INCLUDED -- cgit