mirror of
https://github.com/apple/swift-nio
synced 2026-11-26 04:57:49 +00:00
Update FilePath references to NIOFilePath (#3333)
Motivation: Currently, file paths are represented by the `SystemPackage.FilePath` type in `NIOFileSystem`. Following from #3322, we want to use `NIOFilePath` instead. Modifications: This change provides `NIOFilePath` accepting/returning variants to all existing public methods that accept/return `SystemPackage.FilePath`. The bulk of the changes are in `FileSystemProtocol` and `FileHandleProtocol`, and their conforming types. The protocols have been modified to require `NIOFilePath` accepting/returning methods. Default implementations are provided for `SystemPackage.FilePath` accepting/returning methods---these call through to the `NIOFilePath` variants. Result: `NIOFilePath` path representations can now be used with the methods for interacting with the file system. --------- Co-authored-by: George Barnett <gbarnett@apple.com>
This commit is contained in:
1 parent
b881f6ec60
commit
8997a24524
20 files changed
+1387
-191
No files matched your search
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the SwiftNIO open source project
|
||||
//
|
||||
// Copyright (c) 2023 Apple Inc. and the SwiftNIO project authors
|
||||
// Copyright (c) 2025 Apple Inc. and the SwiftNIO project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
@@ -1178,13 +1178,13 @@ extension SystemFileHandle: DirectoryFileHandleProtocol {
|
||||
}
|
||||
|
||||
public func openFile(
|
||||
forReadingAt path: FilePath,
|
||||
forReadingAt path: NIOFilePath,
|
||||
options: OpenOptions.Read
|
||||
) async throws -> SystemFileHandle {
|
||||
let opts = options.descriptorOptions.union(.nonBlocking)
|
||||
let handle = try await self.threadPool.runIfActive { [sendableView] in
|
||||
let handle = try sendableView._open(
|
||||
atPath: path,
|
||||
atPath: path.underlying,
|
||||
mode: .readOnly,
|
||||
options: opts,
|
||||
transactionalIfPossible: false
|
||||
@@ -1196,14 +1196,14 @@ extension SystemFileHandle: DirectoryFileHandleProtocol {
|
||||
}
|
||||
|
||||
public func openFile(
|
||||
forReadingAndWritingAt path: FilePath,
|
||||
forReadingAndWritingAt path: NIOFilePath,
|
||||
options: OpenOptions.Write
|
||||
) async throws -> SystemFileHandle {
|
||||
let perms = options.permissionsForRegularFile
|
||||
let opts = options.descriptorOptions.union(.nonBlocking)
|
||||
let handle = try await self.threadPool.runIfActive { [sendableView] in
|
||||
let handle = try sendableView._open(
|
||||
atPath: path,
|
||||
atPath: path.underlying,
|
||||
mode: .readWrite,
|
||||
options: opts,
|
||||
permissions: perms,
|
||||
@@ -1216,14 +1216,14 @@ extension SystemFileHandle: DirectoryFileHandleProtocol {
|
||||
}
|
||||
|
||||
public func openFile(
|
||||
forWritingAt path: FilePath,
|
||||
forWritingAt path: NIOFilePath,
|
||||
options: OpenOptions.Write
|
||||
) async throws -> SystemFileHandle {
|
||||
let perms = options.permissionsForRegularFile
|
||||
let opts = options.descriptorOptions.union(.nonBlocking)
|
||||
let handle = try await self.threadPool.runIfActive { [sendableView] in
|
||||
let handle = try sendableView._open(
|
||||
atPath: path,
|
||||
atPath: path.underlying,
|
||||
mode: .writeOnly,
|
||||
options: opts,
|
||||
permissions: perms,
|
||||
@@ -1236,13 +1236,13 @@ extension SystemFileHandle: DirectoryFileHandleProtocol {
|
||||
}
|
||||
|
||||
public func openDirectory(
|
||||
atPath path: FilePath,
|
||||
atPath path: NIOFilePath,
|
||||
options: OpenOptions.Directory
|
||||
) async throws -> SystemFileHandle {
|
||||
let opts = options.descriptorOptions.union(.nonBlocking)
|
||||
let handle = try await self.threadPool.runIfActive { [sendableView] in
|
||||
let handle = try sendableView._open(
|
||||
atPath: path,
|
||||
atPath: path.underlying,
|
||||
mode: .readOnly,
|
||||
options: opts,
|
||||
transactionalIfPossible: false
|
||||
|
||||
Reference in new issue
Block a user