Instance Methodswift-nio 2.72.0_NIOFileSystem
createDirectory(at:withIntermediateDirectories:permissions:)
Create a directory at the given path.
FileSystem.swift:233- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
func createDirectory(at path: FilePath, withIntermediateDirectories createIntermediateDirectories: Bool, permissions: FilePermissions?) async throws
Parameters
- path
The directory to create.
- createIntermediateDirectories
Whether intermediate directories should be created.
- permissions
The permissions to set on the new directory; default permissions will be used if not specified.
If a directory (or file) already exists at path
a FileSystemError
with code fileAlreadyExists
is thrown.
If the parent directory of the directory to created does not exist a FileSystemError
with invalidArgument
is thrown. Missing directories can be created by passing true
to createIntermediateDirectories
.
Errors
Error codes thrown include:
fileAlreadyExists
if a file or directory already exists .invalidArgument
if a component in thepath
prefix does not exist andcreateIntermediateDirectories
isfalse
.
Implementation details
Uses the mkdir(2)
system call.
Other members in extension
Type members
init(threadPool: NIOThreadPool
) Creates a new
FileSystem
using the provided thread pool.
Instance members
var currentWorkingDirectory: FilePath
Returns the path of the current working directory.
var temporaryDirectory: FilePath
Returns a path to a temporary directory.
func copyItem(at: FilePath, to: FilePath, strategy: CopyStrategy, shouldProceedAfterError: @escaping (_ source: DirectoryEntry, _ error: Error) async throws -> Void, shouldCopyItem: @escaping (_ source: DirectoryEntry, _ destination: FilePath) async -> Bool
) async throws func createSymbolicLink(at: FilePath, withDestination: FilePath
) async throws Creates a symbolic link between two files.
func createTemporaryDirectory(template: FilePath
) async throws -> FilePath Create a temporary directory at the given path, using a template.
func destinationOfSymbolicLink(at: FilePath
) async throws -> FilePath Returns the path of the item pointed to by a symbolic link.
func info(forFileAt: FilePath, infoAboutSymbolicLink: Bool
) async throws -> FileInfo? Returns information about the file at
path
if it exists; nil otherwise.func moveItem(at: FilePath, to: FilePath
) async throws Moves the named file or directory to a new location.
func openDirectory(atPath: FilePath, options: OpenOptions.Directory
) async throws -> DirectoryFileHandle Open the directory at
path
.func openFile(forReadingAndWritingAt: FilePath, options: OpenOptions.Write
) async throws -> ReadWriteFileHandle Open the file at
path
for reading and writing.func openFile(forReadingAt: FilePath, options: OpenOptions.Read
) async throws -> ReadFileHandle Open the file at
path
for reading.func openFile(forWritingAt: FilePath, options: OpenOptions.Write
) async throws -> WriteFileHandle Open the file at
path
for writing.func removeItem(at: FilePath, recursively: Bool
) async throws -> Int Deletes the file or directory (and its contents) at
path
.func replaceItem(at: FilePath, withItemAt: FilePath
) async throws Replaces the item at
destinationPath
with the item atexistingPath
.