14 Commits

Author SHA1 Message Date
gmipf
6dddf7db37 Do not follow linked directories in SafeGetFiles outside of Windows (#8)
* Do not follow linked directories in SafeGetFiles outside of Windows

SafeGetFiles with SearchOption.AllDirectories follows directory symlinks.
On Linux, the UDF view of some PC/Mac hybrid discs has symlinks whose
target reads as empty, and each one resolves to its own folder, so the
recursion never ends (fixes #2, SabreTools/BinaryObjectScanner#276).

Outside of Windows, walk the tree one directory at a time and do not enter
directories that carry FileAttributes.ReparsePoint. Files are matched with
Directory.GetFiles per directory, so the pattern behaves as before, and the
order is the same breadth-first order. Windows keeps Directory.GetFiles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Do not follow linked directories in the other AllDirectories overloads

SafeGetDirectories and the SafeEnumerateDirectories, SafeEnumerateFiles
and SafeEnumerateFileSystemEntries wrappers follow directory symlinks in
the same way. On Linux, with one directory linked to itself,
SafeEnumerateFiles returns 43 files instead of 2, and with three such
links it is still running after 10 seconds.

The walk from SafeGetFiles is now a lazy iterator that all of them share,
so the Enumerate wrappers stay lazy. Each directory is listed with the
matching overload without SearchOption (Directory.GetFiles,
SafeEnumerateFiles and so on), so patterns and inaccessible directories
behave as in the recursive search. If the attributes of a subdirectory
cannot be read, such as below a directory without execute permission, it
is entered anyway, so it fails in the same way as in the recursive search.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Check for linked directories without catching exceptions

DirectoryInfo.Exists returns false where the attributes cannot be read, and the criteria for the walk are checked one at a time with their reasons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 13:52:11 +01:00
Matt Nadareski
1b1bea3a17 Separate out device extensions 2026-11-02 07:43:13 -05:00
Matt Nadareski
1ffc627d8a Port mount point methods from MPF 2026-11-02 07:36:25 -05:00
Matt Nadareski
4235315f58 Unix IO stuff ported/opnened from MPF 2026-10-12 11:00:43 -04:00
Matt Nadareski
e07da60916 These helpers should be private 2026-07-09 16:03:47 -04:00
Matt Nadareski
72c523595e Give reasonable defaults to recent helpers 2026-07-09 16:01:55 -04:00
Matt Nadareski
486c95582f Port *nix device methods, update tests 2026-07-09 15:45:00 -04:00
Matt Nadareski
9281796251 ResolvePath should always return an aboslute path 2026-07-02 10:21:15 -04:00
Matt Nadareski
a893de700a Add ResolvePath extension from MPF 2026-07-02 10:01:18 -04:00
Matt Nadareski
6307b9c361 Concatenate to IOExtensions 2026-03-24 09:57:40 -04:00
Matt Nadareski
77dc8ebed7 Separate out collections extensions
Even though there are relatively few collections extensions right now, there is a relatively high chance that other extension will be used in the future.
2026-03-23 10:50:09 -04:00
Matt Nadareski
1f1a5c51f3 Port GetFileSize method from BOS 2026-03-22 17:17:13 -04:00
Matt Nadareski
86040947b5 Combine ParentablePathExtensions into IO extensions and sort 2026-03-22 15:35:11 -04:00
Matt Nadareski
d614379cf5 Libraries
This change looks dramatic, but it's just separating out the already-split namespaces into separate top-level folders. In theory, every single one could be built into their own Nuget package. `SabreTools.IO.Meta` builds the normal Nuget package that is used by all other projects and includes all namespaces. `SabreTools.IO` builds to `SabreTools.IO.Common` to avoid overwriting issues on publish.
2026-03-21 13:55:42 -04:00