Commit Graph

151 Commits

Author SHA1 Message Date
Martchus ac35a5fad1 Fix a few Doxygen warnings 2023-11-18 22:32:04 +01:00
Martchus 938e441336 Extend documentation of the BitReader class
I asked ChatGPT to write documentation for this class and got this. It is
too hilarious to not copy it here verbatimly.
2023-11-02 16:48:00 +01:00
Martchus ad39cbd604 Apply clang-format 2023-04-29 12:53:18 +02:00
Martchus e8b4279062 Don't use sendfile64() if input and output are the same to avoid EBADF
This does not work and leads to sendfile64() running into EBADF ("Bad file
descriptor").
2023-04-23 21:21:32 +02:00
Martchus a55a3604bd Fallback from sendfile64() in case of ENOSYS as well
As suggested on https://man7.org/linux/man-pages/man2/sendfile.2.html.
2023-04-23 21:04:31 +02:00
Martchus 83025c17a1 Fallback to unoptimized version if sendfile64() fails
It might fail on some filesystems such as `ecryptfs`, see
https://github.com/Martchus/cpp-utilities/issues/24.
2023-04-23 19:38:56 +02:00
Martchus 2467c4f815 Make use of platform-specific APIs for optimizing CopyHelper configurable
There might be unexpected limitations like
https://github.com/Martchus/cpp-utilities/issues/24. To be able to at least
workaround those limitations it makes sense to allow disabling the
optimization completely.
2023-04-23 19:23:47 +02:00
Andrew J. Hesford c9131ce6e7 Fix use of `sendfile()` on 32-bit systems 2023-04-06 11:36:06 -04:00
Martchus 2a123df86d Avoid use of non-standard escape character to avoid MSVC warning about it 2023-03-26 21:49:54 +02:00
Martchus 9b1a7b3bf4 Fix includes in `copy.h` when using `sendfile()` 2023-03-19 20:09:14 +01:00
Martchus ec891b48f6 Use `sendfile()` to speed up copying 2023-03-19 20:02:32 +01:00
Martchus ab298b200f Apply clang-format 2023-03-11 17:05:08 +01:00
Martchus 6ec77a1d1c Add `extractNativePath()` as counterpart to `makeNativePath()` 2023-03-06 22:17:44 +01:00
Martchus 07e9546855 Avoid relying on compiler optimizations for binary conversions
* Add/update binary conversion functions to use `std::memcopy`
* Only GCC could actually optimize the custom code using bit operations
    * Clang could only optimize the `getBytes()` functions
    * MSVC could not optimize any of the functions
* The to…Int…() functions cannot be updated as they are `constexpr` (and
  thus `std::memcopy` and `reinterpret_cast` cannot be used). So they stay
  as-is and `toInt()` has been added instead
* The `BinaryReader` class has been updated to use the new `toInt()`
  function
2023-02-05 21:29:22 +01:00
Martchus fe6ad81340 Fix copy helper for large data sizes on 32-bit platforms
On 32-bit platforms `std::size_t` is just 4 bytes big which is not enough
to handle large data sizes. Using `std::streamsize` would likely be most
appropriate but switching signdness is likely not the best idea for
compatibility and it would mean a comparison with different signdness
because the buffer size is still `std::size_t`. So using `std::uint64_t`
now.
2022-07-14 00:30:40 +02:00
Martchus c931e2d928 Fix missing `#pragma GCC diagnostic push` 2022-05-21 12:13:01 +02:00
Martchus c1152ca062 Ignore warning about possible null pointer dereferences appearing with GCC 12
Not sure why this warning is occurring but it is likely incorrect
2022-05-12 20:31:05 +02:00
Martchus 052f8d2bd2 Add helper to make native path from internal representaton 2022-03-17 22:31:11 +01:00
Martchus 3d59664021 Add `std::string_view` overloads to certain I/O functions 2022-03-04 21:04:22 +01:00
Martchus 2bb04c64ea Use std::string_view::value_type in BufferSearch 2021-07-16 15:58:40 +02:00
Martchus 77b2c3281f Add overload to BufferSearch required by arch-repo-manager 2021-07-16 15:56:28 +02:00
Martchus 6558ff487a Add BufferSearch (from arch-repo-manager) to use it in syncthingtray as well 2021-07-15 02:24:28 +02:00
Martchus b3ebe5ce38 Fix typos found via `codespell --skip .git -w` 2021-07-03 19:07:49 +02:00
Martchus 8c033ca243 Fix warnings 2021-03-20 21:56:45 +01:00
Martchus 293b18b607 Mark destructor of NativeFileStream as override 2020-12-18 21:09:35 +01:00
Martchus ee96e03043 Mark formattedPhraseString() as experimental 2020-11-25 17:51:43 +01:00
Martchus c6095fbaf8 Add –formattedPhraseString() 2020-11-18 00:37:43 +01:00
Martchus 07e5752af8 Provide "End" phrases within phraseString() 2020-07-07 12:13:31 +02:00
Martchus 6ed057b932 Add BinaryWriter::write overload for std::string_view 2020-06-26 22:06:44 +02:00
Martchus 2ecc0adceb Add TODO for AdvancedIniFile 2020-06-04 20:49:25 +02:00
Martchus 668b149647 Initialize AdvancedIniFile::Field by default with IniFileFieldFlags::HasValue
The case that there's no equal sign is rather odd so don't make it the default.
2020-05-01 13:58:44 +02:00
Martchus 43550b6d55 Add AdvancedIniFile for better preserving certain aspects like comments 2020-05-01 13:47:06 +02:00
Martchus 08bfdeed5e Document missing features / caveats of IniFile class 2020-03-15 01:01:34 +01:00
Martchus 1154ed4d1c Improve exception messages of NativeFileStream
So one gets e.g. "open failed: Permission denied" instead of
just "open failed: iostream error".
2020-02-14 17:13:05 +01:00
Martchus 5020214498 Add function to get string representation of phrase 2020-01-14 21:27:46 +01:00
Martchus c554aebf07 Use type aliases in IniFile 2019-12-27 01:46:21 +01:00
Martchus 07ae1588fa Add writeFile()
Due to the required `file.close()` at then end this is easy
to get wrong. So let's add a helper.
2019-12-15 19:00:15 +01:00
Martchus 83180119c2 Add Phrases::InfoMessage 2019-11-17 22:26:13 +01:00
Martchus 9a95db3773 Add BinaryReader::readRemainingBytes() 2019-10-30 20:29:26 +01:00
Martchus b693c72eb1 Fix old namespaces being mentioned in the documentation 2019-09-04 18:45:28 +02:00
Martchus db4cba4fe5 Add NativeFileStream overloads to CopyHelper
In a future version these overloads could use native APIs such
as POSIX sendfile() to improve the speed. Libraries such as
tagparser will benefit from this change automatically when in
places where NativeFileStream is already used anyways.
2019-08-13 00:32:59 +02:00
Martchus 5bed21c9d2 Improve NativeFileStream
* Expose native file descriptor/handle to be able to
  use native APIs like POSIX sendfile()
* Fix using Boost.Iostreams under Windows
    * Make it compile
    * Workaround issue with append flag
2019-08-13 00:28:25 +02:00
Martchus 6b1a9cec01 Fix build with NativeFileStream for Windows 2019-06-25 10:20:48 +02:00
Martchus b48b2f5c06 Have everything in one top-level namespace 2019-06-10 21:56:46 +02:00
Martchus c701fc25ee Remove directoryEntries() 2019-06-05 23:50:38 +02:00
Martchus 579199fa73 Fix missing std:: in BinaryWriter::writeByte 2019-06-05 23:48:33 +02:00
Martchus 96dda1b862 Prevent use of extra buffer in BinaryReader::readTerminatedString() 2019-06-04 19:40:12 +02:00
Martchus 0f2f98393f Allow inlining more BinaryReader/BinaryWriter functions 2019-06-04 19:27:49 +02:00
Martchus d8a70bb795 Fix implicit signedness conversion 2019-06-04 19:12:08 +02:00
Martchus f95e16bc80 Remove readMultibyteTerminatedString*() functions 2019-06-04 19:10:52 +02:00