Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kylef/PathKit
Effortless path operations in Swift
https://github.com/kylef/PathKit
Last synced: 10 days ago
JSON representation
Effortless path operations in Swift
- Host: GitHub
- URL: https://github.com/kylef/PathKit
- Owner: kylef
- License: bsd-2-clause
- Created: 2014-09-10T16:23:51.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-16T18:30:21.000Z (6 months ago)
- Last Synced: 2024-05-18T13:41:25.235Z (6 months ago)
- Language: Swift
- Size: 207 KB
- Stars: 1,436
- Watchers: 31
- Forks: 168
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - PathKit
- awesome-swift-cn - PathKit - Effortless path operations in Swift. (Libs / Data Management)
- fucking-awesome-swift - PathKit - Effortless path operations. (Libs / Files)
- awesome-swift - PathKit - Effortless path operations. (Libs / Files)
- awesome-swift - PathKit - Effortless path operations in Swift ` 📝 a month ago ` (Files [🔝](#readme))
- awesome-swift - PathKit - Effortless path operations. (Libs / Files)
README
# PathKit
[![Build Status](https://travis-ci.org/kylef/PathKit.svg)](https://travis-ci.org/kylef/PathKit)
Effortless path operations in Swift.
## Usage
```swift
let path = Path("/usr/bin/swift")
```#### Joining paths
```swift
let path = Path("/usr/bin") + Path("swift")
```#### Determine if a path is absolute
```swift
path.isAbsolute
```#### Determine if a path is relative
```swift
path.isRelative
```#### Determine if a file or directory exists at the path
```swift
path.exists()
```#### Determine if a path is a directory
```swift
path.isDirectory()
```#### Get an absolute path
```swift
let absolutePath = path.absolute()
```#### Normalize a path
This cleans up any redundant `..` or `.` and double slashes in paths.
```swift
let normalizedPath = path.normalize()
```#### Deleting a path
```swift
path.delete()
```#### Moving a path
```swift
path.move(newPath)
```#### Current working directory
```swift
Path.current
Path.current = "/usr/bin"
```#### Changing the current working directory
```swift
path.chdir {
// Path.current would be set to path during execution of this closure
}
```#### Children paths
```swift
path.children()
```#### Reading
```swift
path.read()
```#### Writing
```swift
path.write("Hello World!")
```#### Glob
```swift
let paths = Path.glob("*.swift")
```### Contact
Kyle Fuller
- https://fuller.li
- https://twitter.com/kylefuller### License
PathKit is licensed under the [BSD License](LICENSE).