Comments (13)
Well, now we have files()
and directories
, so I guess I should make directories a function too.
from path.swift.
I guess that's the most minimal consistent implementation.
personally, I have no issue with var directories
as a duplicate for func directories()
and var files
as an duplicate for func files()
from path.swift.
I have no issue with var directories as a duplicate for func directories()
Swift doesnโt allow this, though I think it would if directories()
had a parameter, so perhaps I can do it for files
.
from path.swift.
Anyway, almost done. Coming up.
from path.swift.
thank you :)
from path.swift.
as you say, swift does allow duplication if there is a parameter - even if that param has a default value
so, I just put this in a playground
class Foo {
var bar:[String] {
return ["this"]
}
func bar(test:Bool = true) -> [String] {
return ["that"]
}
}
let test = Foo()
test.bar
test.bar()
if you want duplicates on directory(), then you'd just need to think of an obscure filter method param and provide a nil default
func directories(startingWith:String? = nil)
from path.swift.
Refs #22
from path.swift.
K released: https://github.com/mxcl/Path.swift/releases/tag/0.10.0
CocoaPods will deploy when CI for the tag succeeds.
from path.swift.
If you found my help useful, please consider reimbursing my time by contributing to my Patreon. Thank you so much!
from path.swift.
that's great - thank you.
from path.swift.
thinking about this a bit more as I work through my own app; It would actually make complete sense for the directories and files APIs to match up exactly, including filtering for extensions.
Extensions on directories seems odd until you think that file bundles are actually directories with extensions.
So Path("~/Applications").directories(withExtension:"app")
is actually useful
on a related note, filtering should probably handle case sensitivity to be properly useful.
It's pretty common for images to turn up as .JPG
as well as .jpg
func files(withExtension ext: String? = nil, caseSensitive:Bool = false)
I'm happy to send these in as pull requests. Let me know if that would help.
from path.swift.
I'm actually considering dropping the extensions-specialization and having the user do the filtering themselves.
ls().files().filter{ ["jpg", "jpeg"] =~ $0.extension.lowercased() }
from path.swift.
yup - seems reasonable. I didn't know about =~
on an array
alternatively, how about a chaining approach with a convenience filter (this has to be a super common use case)
public extension Array where Element == Entry {
func filter(withExtensions:[String],caseSensitive:Bool = false) -> [Entry]
}
that way files
and directories
can both be var
, and you can chain if you want a filter
ls().files.filter(withExtensions:["jpg","png"])
from path.swift.
Related Issues (20)
- Consider making TemporaryDirectory public? HOT 3
- [Swift 5] `swift build` fails because it has a minimum platform requirement HOT 5
- Refactor HOT 3
- Drop `@dynamicMember` HOT 1
- Add `mimeType` property? HOT 1
- Issue with CLion. HOT 1
- Incorrect framework name when using CocoaPods HOT 1
- [Feature request] Add .read_text() and read_bytes() HOT 3
- suggestion: Additional convenience on Entries HOT 2
- error: 'Path' is not a member type of 'Path' HOT 4
- Path.home.find(): Value of type 'Any' has no member 'extension' HOT 5
- Output for ls() is unsorted, but ls in the command line is sorted alphabetically by default
- import Path // mxcl/Path.swift ~> 1.0.0 not working with Xcode 11.4 HOT 6
- How I can properly add Path to swift manifest file HOT 4
- suggestion: check out the swift proposal
- Suggestion: Add option for .find() to ignore hidden files HOT 2
- Add conformances to support Swift ArgumentParser? HOT 2
- Path conflicts with SwiftUI.Path, no way to disambiguate HOT 6
- Is there a way to create a file and its directory if missing?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from path.swift.