mxcl / Path.swift

Delightful, robust, cross-platform and chainable file-pathing functions.
The Unlicense
946 stars 36 forks source link

suggestion: Additional convenience on Entries #53

Closed ConfusedVorlon closed 5 years ago

ConfusedVorlon commented 5 years ago

How about...

extension Array where Element == Entry {
    var paths:[Path] {
        return map { $0.path }
    }
}

This allows

let pathsInDirectory = try? myDirectoryPath.ls().paths

mxcl commented 5 years ago

1.0.0-alpha removed the Entry type altogether and ls() now returns [Path].

This was done as the Entry type was just fiddly and you can compose to get the same results that Entry gave you using eg. filter and isDirectory.

Though this could lead to race conditions, in real life this is unlikely and code concerned thus should use the new Path.find() builder function.

ConfusedVorlon commented 5 years ago

sounds good - I'll be happy to see the back of Entry :)