Add a NIOFilePath based NIOFileSystem (#3363)

Motivation:

We changed the file path type in `_NIOFileSystem` to use `NIOFilePath`
instead of `FilePath`. Originally we planned to use API shims to avoid
breaking API, however in some cases this was inevitable (i.e. where a
file path is returned to the caller).

To roll over to the new API we will instead introduce the
`NIOFileSystem` module using `NIOFilePath` and have `_NIOFileSystem` use
`FilePath`. Users can then opt-in to the new stable API rather than
having it forced upon them.

The first wave of these changes turns `_NIOFileSystem` into
`NIOFileSystem` and uses `NIOFilePath` for its APIs.

Modifications:

- Remove disfavoured overloads (i.e. `FilePath` APIs)
- Update the `DirectoryEntry` API to use `NIOFilePath`.
- Update tests to use `NIOFilePath` since many were relying on the newly
removed shims
- Remove the underscore from the module names and products
- Remove deprecated methods

A follow up change will re-instate the `_NIOFileSystem` (and compat)
module and products using `FilePath`.

Result:

`NIOFileSystem` has a stable API.
This commit is contained in:
George Barnett authored and GitHub committed 2025-09-01 08:11:14 +01:00
1 parent 5bf5054a83
commit 7290551b7f
54 files changed
+234 -1514

No files matched your search

@@ -36,23 +36,6 @@ extension String {
self = Self(buffer: byteBuffer)
}
/// Reads the contents of the file at the path into a String.
///
/// - Parameters:
/// - path: The path of the file to read.
/// - maximumSizeAllowed: The maximum size of file which can be read, in bytes, as a ``ByteCount``. If the file is larger than this, an error is thrown.
/// - fileSystem: The ``FileSystemProtocol`` instance to use to read the file.
///
/// - Throws: If the file is larger than `maximumSizeAllowed`, an ``FileSystemError/Code-swift.struct/resourceExhausted`` error will be thrown.
@_disfavoredOverload
public init(
contentsOf path: FilePath,
maximumSizeAllowed: ByteCount,
fileSystem: some FileSystemProtocol
) async throws {
try await self.init(contentsOf: .init(path), maximumSizeAllowed: maximumSizeAllowed, fileSystem: fileSystem)
}
/// Reads the contents of the file at the path using ``FileSystem``.
///
/// - Parameters:
@@ -70,19 +53,4 @@ extension String {
fileSystem: .shared
)
}
/// Reads the contents of the file at the path using ``FileSystem``.
///
/// - Parameters:
/// - path: The path of the file to read.
/// - maximumSizeAllowed: The maximum size of file which can be read, in bytes, as a ``ByteCount``. If the file is larger than this, an error is thrown.
///
/// - Throws: If the file is larger than `maximumSizeAllowed`, an ``FileSystemError/Code-swift.struct/resourceExhausted`` error will be thrown.
@_disfavoredOverload
public init(
contentsOf path: FilePath,
maximumSizeAllowed: ByteCount
) async throws {
try await self.init(contentsOf: .init(path), maximumSizeAllowed: maximumSizeAllowed)
}
}