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