FileUtilities

public struct FileUtilities

Specifies utility methods for working with files.

  • Gets the path to the directory.

    Declaration

    Swift

    public static func getDirectoryPath() -> String

    Return Value

    The path.

  • Changes the current directory.

    Declaration

    Swift

    public static func chageDirectory(_ directory: Directories)

    Parameters

    directory

    The name of the new directory.

  • Creates a new file with the specified name and content.

    Declaration

    Swift

    public static func createFile(_ filename: String, fileContent: String)

    Parameters

    filename

    The name of the file.

    fileContent

    The contents of the new file.

  • Undocumented

    Declaration

    Swift

    public static func createFile(_ fileUrl: URL, fileContent: String)
  • Cycles through the temp directory and enumerates all files in it.

    Declaration

    Swift

    public static func enumerateTempDirectory() -> [String]

    Return Value

    A string array with the names of all files in the temp directory.

  • Checks if a file exists.

    Declaration

    Swift

    public static func isFileExists(_ filename: String) -> Bool

    Parameters

    filename

    The name of the file to check.

    Return Value

    true if the file exists; otherwise false.

  • Reads the contents of the specified file.

    Declaration

    Swift

    public static func readFileContent(_ filename: String) -> String

    Parameters

    filename

    The name of the file to read.

    Return Value

    The contents of the file as a string.

  • Deletes the specified file.

    Declaration

    Swift

    public static func deleteFile(_ filename: String)

    Parameters

    filename

    The name of the file to delete.