254 Commits

Author SHA1 Message Date
Steffen Schümann
29b5acd3d6 equivalent() now compares filesystem identity only; added related tests, refs #210 2026-07-14 23:14:14 +02:00
Steffen Schümann
796515b6be Handle malformed UTF-16 sequences in toUtf8 conversion and update error handling, refs #209. 2026-07-13 21:09:13 +02:00
Steffen Schümann
09540bf5e7 Add symlink handling tests and fix recursive_directory_iterator behavior with symlinks (refs #178) 2026-07-13 01:20:44 +02:00
Steffen Schümann
73212968f6 Squashed commit of the following:
commit 16e1157d4e0a484c5b0045551ce0e083e566d582
Author: Steffen Schümann <s.schuemann@pobox.com>
Date:   Sun Jul 12 14:53:28 2026 +0200

    Improve file time precision checks and initialize `directory_entry`'s `_last_write_time`

commit 4bc18b09557747baf03cdc412102b4166627eba9
Author: Steffen Schümann <s.schuemann@pobox.com>
Date:   Sun Jul 12 13:12:35 2026 +0200

    Preserve subsecond precision for `last_write_time()` and related filesystem metadata (#208)
2026-07-12 15:11:57 +02:00
Steffen Schümann
38f91bd470 last_write_time() now consistently follows symlinks and respects timestamps (#207) 2026-07-12 12:02:18 +02:00
Steffen Schümann
442d95aa41 Handle Windows unknown error codes safely in systemErrorText (#206) 2026-07-12 10:47:39 +02:00
Steffen Schümann
998d93cdf4 copy_file() handls non-regular sources with error reporting (#205) 2026-07-12 10:06:11 +02:00
Steffen Schümann
831d54a21d Squashed commit of the following:
commit a6aab92fb26c569d8fcf417d903601a3b3d4ce6f
Author: Steffen Schümann <s.schuemann@pobox.com>
Date:   Sat Jul 11 23:04:57 2026 +0200

    Refine `weakly_canonical` test to validate error codes and handle invalid paths more robustly.

commit 21b931bd977608fcdcb1ae79aaf4383ffdae517c
Merge: 48a868a 134f5e6
Author: Steffen Schümann <s.schuemann@pobox.com>
Date:   Sat Jul 11 22:11:16 2026 +0200

    Merge branch 'master' into feature-204-weakly-canonical-ignores-errors

commit 48a868a11a69ac174f9ec2eacc5ac78bd72b6ef3
Author: Steffen Schümann <s.schuemann@pobox.com>
Date:   Sat Jul 11 21:48:57 2026 +0200

    Propagate `weakly_canonical()` component lookup errors and improve error handling in filesystem tests (#204)
2026-07-12 00:00:06 +02:00
Steffen Schümann
6dfddd981e Merge branch 'feature-200-fstream-test' 2026-07-11 21:22:43 +02:00
Steffen Schümann
58c373188b Add support for device UNC paths in canonical() (#171) 2026-07-11 20:40:28 +02:00
Steffen Schümann
730589f53e Squashed commit of the following:
commit 333fc89c7d3f8962d7bc1025565c27e046f28e28
Author: Steffen Schümann <s.schuemann@pobox.com>
Date:   Sat Jul 11 18:37:05 2026 +0200

    Removed extra tests that were added but unrelated to the fix.

commit 542f355853fcae25e788c4514fe57494200797ce
Author: Steffen Schümann <s.schuemann@pobox.com>
Date:   Sat Jul 11 18:29:40 2026 +0200

    lexically_normal() preserves IPv6 components in device UNC paths (#170)
2026-07-11 20:18:58 +02:00
Steffen Schümann
4d2f630892 Fix appending to host-only UNC paths by inserting missing separator (#191) 2026-07-11 16:09:44 +02:00
Steffen Schümann
87157acd6c Fix lexically_normal() to correctly preserve unresolved parent components in relative paths 2026-07-11 09:58:07 +02:00
Steffen Schümann
8741115872 Allow iteration while exceptions are disabled and reactivate proximate(...) for that case 2026-07-10 17:01:36 +02:00
Nahuel Gaitan
603dacf69e
add <fstream> to dynamic headers 2026-01-01 22:21:38 -03:00
Steffen Schümann
f539086997 Add Clang-specific diagnostic handling and support checks 2025-12-31 14:21:35 +01:00
Steffen Schümann
dc19ab8f7b Avoid unnecessary temporary string creation in Windows directory iteration 2025-12-31 14:11:31 +01:00
bxwllzz
601efab4be Fix EINTR handling in read() and readdir() loops
- read(): POSIX specifies that errno is undefined when read() return values are >= 0.
  The previous retry logic had bugs:
  When read() returns 0 (EOF), the loop condition checked errno before
  the return value. Since errno might be stale from a previous call, this could
  trigger a false retry on EOF.

- readdir(): When readdir() reaches the end of directory, it returns NULL
  without modifying errno. Setting errno=0 before the loop caused an infinite loop.
2025-12-27 18:22:59 +08:00
Steffen Schümann
076592ce6e
Merge pull request #188 from bbannier/topic/bbannier/getcwd-with-NULL-buf
Avoid GNU `getcwd` extension behavior
2025-01-07 21:00:06 +01:00
Darryl Pogue
f08e8b0064
Check macros are defined before use
This resolves warnings when compiling with -wundef (and errors when
combined with -werror).
2025-01-04 21:45:29 -08:00
Benjamin Bannier
f43846877b Avoid GNU getcwd extension behavior
GNU `getcwd` can allocate a buffer if passed `NULL` for it. This is an
extension which is e.g., not recognized by clang-tidy-19's
`StdCLibraryFunctions` check[^1] which emits a diagnostic on a violated
precondition `buf != NULL`,

```
The 1st argument to 'getcwd' is NULL but should not be NULL [clang-analyzer-unix.StdCLibraryFunctions,-warnings-as-errors]
[build]  3987 |     std::unique_ptr<char, decltype(&std::free)> buffer{::getcwd(NULL, 0), std::free};
```

This patch modifies this use of `getcwd` with this extension behavior to
instead use `get_current_dir_name` which is also a GNU extension, but
does not trigger this diagnostic.

[^1]: https://clang.llvm.org/docs/analyzer/checkers.html#unix-stdclibraryfunctions-c
2024-12-18 15:26:19 +01:00
vgeorgiev
eeed314237
Fix handling of trailing slash 2024-02-21 17:55:00 -06:00
vgeorgiev
768b5cb11b
Fix lexically_relative return when base path evaluates to *this 2024-02-21 11:07:19 -06:00
noexcept
fc19b58459 fix infinite loop when errno is EINTR 2023-12-20 11:56:57 +00:00
Oz
c4683aa4a1
Allow wchar_t constructors of iostreams on Windows when using libstdc++ 2023-09-05 09:00:51 +02:00
Chris Sauer
48d46cccef Improve apple conditionals in filesystem.hpp
Two changes:
- (minor) Rename GHC_OS_MACOS -> GHC_OS_APPLE, since it is defined all apple platforms (iOS, watchOS, etc.), not just macOS.
- Changed the preprocessor conditional in last_write_time to align with its presumed intent. Previously, it would always have been true, which can't be intentional, because the *_OS_VERSION_MIN_REQUIRED is undefined and thus zero for platforms besides the current one, and therefore less than the constants--except for on very old SDKs where, e.g., MAC_OS_X_VERSION_10_13  and others would be undefined and therefore 0 and therefore making the clause false when it needed to be true. Therefore, I changed the conditions to be parallel to those in the dynamic selection headers, checking for the undefined, zero case and hardcoding the version values to support old SDKs.
2023-07-26 23:07:09 -07:00
Chris Sauer
23710d3b56 Remove conditional inclusion snippet in filesystem.hpp
Reduces duplication and tendency to get out of sync.
As evidence of the problem, the snippet had previously (before this PR) started to diverge. It seemed more prudent to delete than to fix, given the usage instructions seem to be centralized in the readme and the dynamic selection headers should probably be recommended anyway.
2023-07-26 21:56:08 -07:00
Chris Sauer
64f9c5a61a Switch internal includes to quoted relative
This makes project integration more flexible, allowing the drag-contents-of-directory project integration contemplated in the readme and allowing use via -iquote
2023-07-26 21:40:38 -07:00
Chris Sauer
a55c96a2ba Minor: seperated typo 2023-07-26 21:28:52 -07:00
Chris Sauer
aaaf381d9d Improvements to preprocessor conditions for falling back to std::filesystem
- Supports more Apple platforms, including future ones, which will always support std::filesystem, like with visionOS
- Simplifies cases.  Undefined preprocessor values are guaranteed to default evaluate to 0
- Moves <Availability.h> include inside conditional, avoiding the include where not needed.
- Removes reference to wchar for std headers on windows, which seemed to be out of date, since the define it might have been referring to was commented
- (And some other small things.)
2023-07-26 21:26:33 -07:00
Steffen Schuemann
72a76d774e head version bumped to wip version 2023-05-18 10:39:25 +02:00
Steffen Schuemann
e5ae1bd3e3 refs #166, ".." does not have extension ." 2023-05-17 07:18:52 +02:00
Steffen Schuemann
8a2edd6d92 Version bump to v1.5.14 2023-03-05 13:06:50 +01:00
Steffen Schuemann
61176cd82a Merge branch 'feature-146-added-EINTR-handling' 2023-03-04 16:39:33 +01:00
Steffen Schuemann
9df22d5396 refs #157, suppress unavoidable warning at cast for GetProcAddress on MSVC 2023-03-04 15:17:13 +01:00
Steffen Schuemann
6a94e84da4 refs #151, stop throwing on fs:🇩🇪:refresh for broken symlinks, and added test 2023-03-04 09:59:16 +01:00
gulrak
3afbd9c315
Merge pull request #144 from actboy168/patch-2
copy_file also copies permissions
2023-03-03 17:35:47 +01:00
gulrak
de64decd91
Merge pull request #143 from actboy168/patch-1
Fixes skip_existing on fs::copy
2023-03-03 17:31:15 +01:00
Steffen Schuemann
f3033c29fb refs #146, added EINTR handling to directory iteration and file copying 2023-03-03 06:44:58 +01:00
Steffen Schuemann
c8113e14b1 Updated readme, bumped to wip version as preparation of upcoming release. 2023-03-02 19:19:22 +01:00
Steffen Schuemann
b6d302f5b9 Merge branch 'feature-156-posix-issue-stem-filename-extension' 2023-03-02 19:01:15 +01:00
Steffen Schuemann
efc077f553 refs #156: Windows path handling artifact bled into POSIX 2023-03-02 08:20:18 +01:00
begasus
9afb43851d filesystem.hpp, add support for Haiku 2023-02-18 10:21:53 +01:00
gulrak
c57242b4bc
Merge pull request #154 from sthibaul/master
Fix build on GNU/Hurd
2023-02-17 17:29:41 +01:00
gulrak
3337cc252a
Merge pull request #153 from kkaefer/last_write_time-ios
Fix `ghc::filesystem::last_write_time()` setter on iOS/tvOS/watchOS
2023-02-17 17:27:12 +01:00
Jianxiang Wang (王健翔)
f0caeb7d58
Update filesystem.hpp
Fix directory iterator treating all files subsequent to a symlink as symlink on Windows
2023-02-16 13:38:48 +08:00
Samuel Thibault
d3d968e583 Fix build on GNU/Hurd
There is no path length limitation there, even via pathconf.  But glibc
provides a getcwd function that allocates the buffer dynamically so we can
just leverage that.
2022-08-16 20:29:54 +02:00
Konstantin Käfer
404c57f1b0 Fix ghc::filesystem::last_write_time() setter on iOS/tvOS/watchOS
The previous implementation tried to detect old deployment targets for macOS that doesn't have the newer `utimensat` call. Unfortunately, it would just detect macOS, and didn't check for the corresponding iOS/tvOS/watchOS version numbers. On those platforms, last_write_time() was effectively a no-op, failing silently and not modifying the mtime of the file.

This patch adds detection for these platforms. It also removes the special casing when newer versions of macOS/iOS/tvOS/watchOS are used as the deployment targets, and instead folds it into the default POSIX branch.
2022-07-27 18:31:16 +02:00
Silent
4f0824fd76
Fix a Y2038 bug in timeToFILETIME
The old code truncated time_t to a 32-bit value
when using Int32x32To64. This example code has been fixed
on MSDN a while ago, so this change only updates it to
the current version.

More on this issue:
https://cookieplmonster.github.io/2022/02/17/year-2038-problem/
2022-05-25 19:56:56 +02:00
actboy168
28f7c929e0
fixes 2022-04-08 11:43:15 +08:00