WritableFile
public final class WritableFile: File, WritableStream, MutableFileSystemItemA class for writing text to a file.
- 
                  
                  The path to the file DeclarationSwift public internal(set) var path: FilePath
- 
                  
                  The encoding for the text in the file. DeclarationSwift public var encoding: String.Encoding = .utf8
- 
                  
                  The type of file or file-like item this is. DeclarationSwift public let type: FileType
- 
                  
                  Opens the file at ‘path’ for writing. Parameter Parameter path: the path to the file.Throws FileSystemError.notFound, .isDirectory, .invalidAccess.DeclarationSwift public convenience init(open path: FilePath) throwsParameterspaththe path to the file. 
- 
                  
                  Creates a new WritableFile which writes to the provided file handle. The path is /dev/fd/ + the file handle’s filedescriptor.DeclarationSwift public convenience init(_ filehandle: FileHandle)
- 
                  
                  Creates a new file at ‘path’ for writing. 
- Parameters:
- path: The path where the new file should be created.
- ifExists: What to do if it already exists: open, throw error or replace.
 Throws FileSystemError.isDirectory, .couldNotCreate, .alreadyExists, .outsideSandbox.DeclarationSwift public convenience init(create path: FilePath, ifExists: AlreadyExistsOptions) throwsParameterspathThe path where the new file should be created. ifExistsWhat to do if it already exists: open, throw error or replace. 
- Parameters:
- 
                  
                  Creates a new file at ‘stringpath’ for writing. 
- Parameters:
- stringpath: The path where the new file should be created.
- ifExists: What to do if it already exists: open, throw error or replace.
 Throws FileSystemError.isDirectory, .couldNotCreate, .alreadyExists, .outsideSandbox.DeclarationSwift public convenience init(create stringpath: String, ifExists: AlreadyExistsOptions) throwsParametersstringpathThe path where the new file should be created. ifExistsWhat to do if it already exists: open, throw error or replace. 
- Parameters:
- 
                  
                  Deletes this file. For ever. DeclarationSwift public func delete() throws
- 
                  
                  Appends the string to the file. Nothing is overwritten, just added to the end of the file. DeclarationSwift public func write(_ string: String)
- 
                  
                  Closes the file. No more writing. DeclarationSwift public func close()
- 
                  
                  Replaces the entire contents of the file with the string. - warning: The current contents of the file will be lost. - warning: Will crash if this is not a regular file. DeclarationSwift public func overwrite(_ string: String)
- 
                  
                  A WritableStream which writes to standard output. DeclarationSwift static public var stdout: WritableStream = StdoutStream.default
- 
                  
                  A WritableStream which writes to standard error. DeclarationSwift static public var stderror: WritableStream =
 View on GitHub
View on GitHub WritableFile Class Reference
        WritableFile Class Reference