Missing functions
This commit is contained in:
@@ -14,6 +14,10 @@ public extension Bundle {
|
||||
public var resources: Path? {
|
||||
return resourcePath.flatMap(Path.init)
|
||||
}
|
||||
|
||||
public var path: Path {
|
||||
return Path(string: bundlePath)
|
||||
}
|
||||
}
|
||||
|
||||
public extension String {
|
||||
|
||||
@@ -41,6 +41,15 @@ public extension Path {
|
||||
return rv
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func move(to: Path, overwrite: Bool = false) throws -> Path {
|
||||
if overwrite, to.exists {
|
||||
try FileManager.default.removeItem(at: to.url)
|
||||
}
|
||||
try FileManager.default.moveItem(at: url, to: to.url)
|
||||
return to
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func move(into: Path) throws -> Path {
|
||||
if !into.exists {
|
||||
@@ -48,8 +57,9 @@ public extension Path {
|
||||
} else if !into.isDirectory {
|
||||
throw CocoaError.error(.fileWriteFileExists)
|
||||
}
|
||||
try FileManager.default.moveItem(at: url, to: into.join(basename()).url)
|
||||
return self
|
||||
let rv = into/basename()
|
||||
try FileManager.default.moveItem(at: url, to: rv.url)
|
||||
return rv
|
||||
}
|
||||
|
||||
@inlinable
|
||||
|
||||
@@ -15,6 +15,10 @@ public extension Path {
|
||||
return FileManager.default.fileExists(atPath: string, isDirectory: &isDir) && !isDir.boolValue
|
||||
}
|
||||
|
||||
var isExecutable: Bool {
|
||||
return FileManager.default.isExecutableFile(atPath: string)
|
||||
}
|
||||
|
||||
var exists: Bool {
|
||||
return FileManager.default.fileExists(atPath: string)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user