Path
public struct Path
Represents a file system path.
- Example:
“`
let absolutePath = Path(
/usr/bin/zip
) absolutePath.isAbsolute absolutePath.isRelative
let relativePath = Path(bin/whatever
)
relativePath.isAbsolute
relativePath.isRelative
let concatenatedPath = Path(/usr
) + Path(/bin
)
let messyPath = Path(//usr/../usr/local/bin/./whatever
)
messyPath.normalized
let pathFromLiteralString: Path = /this/is/a/path
let pathFromEmptyString: Path = ”
let pathFromConcatenatedStrings: Path =
/usr+
/bin"
let pathFromComponents = Path(components: [/
, usr/
, bin
, /
, swift
])
let pathFromEmptyComponents = Path(components: [])
let appendedPath = Path(/usr/local
).appendingComponent(bin
)
let appendedPath3 = Path(/usr/local
).appending(Path(bin
))
let appendedPath2 = Path(/usr/local
) + Path(bin
)
let imagePath = Path(photos/photo
).appendingExtension(jpg
)
imagePath.extension
let imagePathWithoutExtension = imagePath.deletingExtension let imagePathWithoutLastComponent = imagePath.deletingLastComponent
absolutePath.exists absolutePath.isFile absolutePath.isDirectory absolutePath.isDeletable absolutePath.isExecutable absolutePath.isReadable absolutePath.isWritable
-
Undocumented
Declaration
Swift
public var isAbsolute: Bool { get }
-
Undocumented
Declaration
Swift
public var isRelative: Bool { get }
-
Undocumented
Declaration
Swift
public var normalized: Path { get }
-
Undocumented
Declaration
Swift
public var string: String { get }
-
Undocumented
Declaration
Swift
public var url: URL { get }
-
Undocumented
Declaration
Swift
public init()
-
Undocumented
Declaration
Swift
public init(_ path: String)
-
Undocumented
Declaration
Swift
public func appending(_ path: Path) -> Path
-
Undocumented
Declaration
Swift
public init<T>(components: T) where T : Collection, T.Element == String
-
Undocumented
Declaration
Swift
public var lastComponent: String { get }
-
Undocumented
Declaration
Swift
public var deletingLastComponent: Path { get }
-
Undocumented
Declaration
Swift
public func appendingComponent(_ string: String) -> Path
-
Undocumented
Declaration
Swift
public func replacingLastComponent(with string: String) -> Path
-
Undocumented
Declaration
Swift
public var `extension`: String { get }
-
Undocumented
Declaration
Swift
public var deletingExtension: Path { get }
-
Undocumented
Declaration
Swift
public func appendingExtension(_ string: String) -> Path
-
Undocumented
Declaration
Swift
public func replacingExtension(with string: String) -> Path
-
Note: No-op if file does not exist.
Declaration
Swift
func excludeFromBackup() throws
-
Undocumented
Declaration
Swift
var exists: Bool { get }
-
Undocumented
Declaration
Swift
var doesNotExist: Bool { get }
-
Undocumented
Declaration
Swift
var isFile: Bool { get }
-
Undocumented
Declaration
Swift
var isDirectory: Bool { get }
-
Undocumented
Declaration
Swift
var isDeletable: Bool { get }
-
Undocumented
Declaration
Swift
var isExecutable: Bool { get }
-
Undocumented
Declaration
Swift
var isReadable: Bool { get }
-
Undocumented
Declaration
Swift
var isWritable: Bool { get }
-
Undocumented
Declaration
Swift
func contentsOfDirectory(fullPaths: Bool = false) throws -> [Path]
-
Undocumented
Declaration
Swift
static var currentDirectory: Path { get }
-
Undocumented
Declaration
Swift
static var homeDirectory: Path? { get }
-
Undocumented
Declaration
Swift
static var documentDirectory: Path? { get }
-
Undocumented
Declaration
Swift
static var cachesDirectory: Path { get }
-
The application support directory typically does not exist at first. You need to create it if it doesn’t exist. The getter of this variable will try to append the app bundle identifier to the path as recommended by Apple.
Declaration
Swift
static var applicationSupportDirectory: Path { get }
-
Undocumented
Declaration
Swift
static var downloadsDirectory: Path? { get }
-
Undocumented
Declaration
Swift
static var desktopDirectory: Path? { get }
-
Undocumented
Declaration
Swift
static var applicationsDirectory: Path? { get }
-
Undocumented
Declaration
Swift
func becomeCurrentDirectory()
-
Undocumented
Declaration
Swift
func createDirectory(withIntermediateDirectories createIntermediateDirectories: Bool = true, attributes: [FileAttributeKey : Any]? = nil) throws
-
Undocumented
Declaration
Swift
func remove() throws
-
Undocumented
Declaration
Swift
func copy(to toPath: Path) throws
-
Undocumented
Declaration
Swift
func copy(to toPath: String) throws
-
Undocumented
Declaration
Swift
func copy(to toURL: URL) throws
-
Undocumented
Declaration
Swift
func safeReplace(withItemAt itemPath: Path) throws -> URL?
-
Set POSIX file permissions. Same as chmod. Octal number is recommended.
Declaration
Swift
func setPosixPermissions(_ permissions: Int) throws
-
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public typealias UnicodeScalarLiteralType = StringLiteralType
-
Declaration
Swift
public typealias ExtendedGraphemeClusterLiteralType = StringLiteralType
-
Declaration
Swift
public init(unicodeScalarLiteral value: UnicodeScalarLiteralType)
-
Declaration
Swift
public init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterLiteralType)
-
Declaration
Swift
public init(stringLiteral value: StringLiteralType)
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
Declaration
Swift
public static func == (lhs: Path, rhs: Path) -> Bool
-
Declaration
Swift
public static func < (lhs: Path, rhs: Path) -> Bool