summaryrefslogtreecommitdiff
path: root/zen
diff options
context:
space:
mode:
Diffstat (limited to 'zen')
-rw-r--r--zen/file_traverser.cpp2
-rw-r--r--zen/legacy_compiler.h1
-rw-r--r--zen/shutdown.cpp2
-rw-r--r--zen/thread.cpp2
-rwxr-xr-xzen/xml_io.cpp83
-rwxr-xr-xzen/xml_io.h26
6 files changed, 3 insertions, 113 deletions
diff --git a/zen/file_traverser.cpp b/zen/file_traverser.cpp
index cc6e0c0b..2d2a0cce 100644
--- a/zen/file_traverser.cpp
+++ b/zen/file_traverser.cpp
@@ -39,7 +39,7 @@ void zen::traverseFolder(const Zstring& dirPath,
return;
THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot read directory %x."), L"%x", fmtPath(dirPath)), L"readdir");
- //don't retry but restart dir traversal on error! https://blogs.msdn.microsoft.com/oldnewthing/20140612-00/?p=753/
+ //don't retry but restart dir traversal on error! https://devblogs.microsoft.com/oldnewthing/20140612-00/?p=753/
}
//don't return "." and ".."
diff --git a/zen/legacy_compiler.h b/zen/legacy_compiler.h
index 54605945..5b69ed94 100644
--- a/zen/legacy_compiler.h
+++ b/zen/legacy_compiler.h
@@ -7,7 +7,6 @@
#ifndef LEGACY_COMPILER_H_839567308565656789
#define LEGACY_COMPILER_H_839567308565656789
-//#include <span> //requires C++20
namespace std
diff --git a/zen/shutdown.cpp b/zen/shutdown.cpp
index cd37d57c..aecd4121 100644
--- a/zen/shutdown.cpp
+++ b/zen/shutdown.cpp
@@ -36,7 +36,7 @@ void zen::terminateProcess(int exitCode)
std::exit(exitCode); //[[noreturn]]; "Stack is not unwound: destructors of variables with automatic storage duration are not called." => perfect
//don't use std::abort() => crashes process with "EXC_CRASH (SIGABRT)" on macOS
for (;;) //why still here?? => crash deliberately!
- *reinterpret_cast<volatile int*>(0) = 0; //crude but at least we'll get crash dumps if it happens
+ *reinterpret_cast<volatile int*>(0) = 0; //crude but at least we'll get crash dumps if it ever happens
}
diff --git a/zen/thread.cpp b/zen/thread.cpp
index 08bfaa25..49c6d9b3 100644
--- a/zen/thread.cpp
+++ b/zen/thread.cpp
@@ -26,7 +26,7 @@ namespace
uint64_t getThreadIdNative()
{
const pid_t tid = ::syscall(SYS_gettid); //no-fail
- //"Invalid thread and process IDs": https://blogs.msdn.microsoft.com/oldnewthing/20040223-00/?p=40503
+ //"Invalid thread and process IDs": https://devblogs.microsoft.com/oldnewthing/20040223-00/?p=40503
//if (tid == 0) -> not sure this holds on Linux, too!
// throw std::runtime_error(std::string(__FILE__) + "[" + numberTo<std::string>(__LINE__) + "] Failed to get thread ID.");
static_assert(sizeof(uint64_t) >= sizeof(tid));
diff --git a/zen/xml_io.cpp b/zen/xml_io.cpp
deleted file mode 100755
index dd116ef0..00000000
--- a/zen/xml_io.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// *****************************************************************************
-// * This file is part of the FreeFileSync project. It is distributed under *
-// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 *
-// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
-// *****************************************************************************
-
-#include "xml_io.h"
-#include "file_access.h"
-#include "file_io.h"
-
-using namespace zen;
-
-
-XmlDoc zen::loadXmlDocument(const Zstring& filePath) //throw FileError
-{
- FileInput fileIn(filePath, nullptr /*notifyUnbufferedIO*/); //throw FileError, ErrorFileLocked
- const size_t blockSize = fileIn.getBlockSize();
- const std::string xmlPrefix = "<?xml version=";
- bool xmlPrefixChecked = false;
-
- std::string buffer;
- for (;;)
- {
- buffer.resize(buffer.size() + blockSize);
- const size_t bytesRead = fileIn.read(&*(buffer.end() - blockSize), blockSize); //throw FileError, ErrorFileLocked, (X); return "bytesToRead" bytes unless end of stream!
- buffer.resize(buffer.size() - blockSize + bytesRead); //caveat: unsigned arithmetics
-
- //quick test whether input is an XML: avoid loading large binary files up front!
- if (!xmlPrefixChecked && buffer.size() >= xmlPrefix.size() + strLength(BYTE_ORDER_MARK_UTF8))
- {
- xmlPrefixChecked = true;
- if (!startsWith(buffer, xmlPrefix) &&
- !startsWith(buffer, BYTE_ORDER_MARK_UTF8 + xmlPrefix)) //allow BOM!
- throw FileError(replaceCpy(_("File %x does not contain a valid configuration."), L"%x", fmtPath(filePath)));
- }
-
- if (bytesRead < blockSize) //end of file
- break;
- }
-
- try
- {
- return parse(buffer); //throw XmlParsingError
- }
- catch (const XmlParsingError& e)
- {
- throw FileError(
- replaceCpy(replaceCpy(replaceCpy(_("Error parsing file %x, row %y, column %z."),
- L"%x", fmtPath(filePath)),
- L"%y", numberTo<std::wstring>(e.row + 1)),
- L"%z", numberTo<std::wstring>(e.col + 1)));
- }
-}
-
-
-void zen::saveXmlDocument(const XmlDoc& doc, const Zstring& filePath) //throw FileError
-{
- const std::string stream = serialize(doc); //noexcept
-
- //only update XML file if there are real changes
- try
- {
- if (getFileSize(filePath) == stream.size()) //throw FileError
- if (loadBinContainer<std::string>(filePath, nullptr /*notifyUnbufferedIO*/) == stream) //throw FileError
- return;
- }
- catch (FileError&) {}
-
- saveBinContainer(filePath, stream, nullptr /*notifyUnbufferedIO*/); //throw FileError
-}
-
-
-void zen::checkForMappingErrors(const XmlIn& xmlInput, const Zstring& filePath) //throw FileError
-{
- if (xmlInput.errorsOccured())
- {
- std::wstring msg = _("The following XML elements could not be read:") + L"\n";
- for (const std::wstring& elem : xmlInput.getErrorsAs<std::wstring>())
- msg += L"\n" + elem;
-
- throw FileError(replaceCpy(_("Configuration file %x is incomplete. The missing elements will be set to their default values."), L"%x", fmtPath(filePath)) + L"\n\n" + msg);
- }
-}
diff --git a/zen/xml_io.h b/zen/xml_io.h
deleted file mode 100755
index 81b45aa1..00000000
--- a/zen/xml_io.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// *****************************************************************************
-// * This file is part of the FreeFileSync project. It is distributed under *
-// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 *
-// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
-// *****************************************************************************
-
-#ifndef XML_IO_H_8914759321263879
-#define XML_IO_H_8914759321263879
-
-#include <zenxml/xml.h>
-#include "file_error.h"
-
-
-//combine zen::Xml and zen file I/O
-//-> loadXmlDocument vs loadStream:
-//1. better error reporting
-//2. quick exit if (potentially large) input file is not an XML
-namespace zen
-{
-XmlDoc loadXmlDocument(const Zstring& filePath); //throw FileError
-void checkForMappingErrors(const XmlIn& xmlInput, const Zstring& filePath); //throw FileError
-
-void saveXmlDocument(const XmlDoc& doc, const Zstring& filePath); //throw FileError
-}
-
-#endif //XML_IO_H_8914759321263879
bgstack15