Entry.files defaults to all files
This commit is contained in:
@@ -51,7 +51,14 @@ public extension Array where Element == Entry {
|
||||
}
|
||||
}
|
||||
|
||||
/// Filters the list of entries to be a list of Paths that are files with the specified extension
|
||||
/// Filters the list of entries to be a list of Paths that are files.
|
||||
var files: [Path] {
|
||||
return compactMap {
|
||||
$0.kind == .file ? $0.path : nil
|
||||
}
|
||||
}
|
||||
|
||||
/// Filters the list of entries to be a list of Paths that are files with the specified extension.
|
||||
func files(withExtension ext: String) -> [Path] {
|
||||
return compactMap {
|
||||
$0.kind == .file && $0.path.extension == ext ? $0.path : nil
|
||||
|
||||
@@ -73,10 +73,15 @@ public struct Path: Equatable, Hashable, Comparable {
|
||||
/**
|
||||
Returns the filename extension of this path.
|
||||
- Remark: Implemented via `NSString.pathExtension`.
|
||||
- Note: We special case eg. `foo.tar.gz`.
|
||||
*/
|
||||
@inlinable
|
||||
public var `extension`: String {
|
||||
return (string as NSString).pathExtension
|
||||
if string.hasSuffix(".tar.gz") {
|
||||
return "tar.gz"
|
||||
} else {
|
||||
return (string as NSString).pathExtension
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: Pathing
|
||||
|
||||
Reference in New Issue
Block a user