Swiftpack.co - Package - BinaryBirds/Dir

Dir (🌳)

Working with directories in a nice way using Swift.

Usage

Some examples:

import Dir

let cachesDir = Dir.systemDirectory(for: .caches)
let homeDir = Dir()
let parentDir = homeDir.parent
let rootDir = Dir.root
let currentDir = Dir.current
let testDir = currentDir.child("test")

print(testDir.isExistingDirectory)
print(testDir.listFiles(skipHidden: true))
print(testDir.listDirs())

do {
    let workDir = try homeDir.add("my-work-dir", isHidden: true)

    print(workDir.path)

    try testDir.delete()
    try testDir.create()
    
    let a = currentDir.child("a")
    try a.create()
    
    let b = currentDir.child("b")
    let c = currentDir.child("c")
    let d = currentDir.child("d")

    try a.copy(to: b)
    try a.link(to: c)
    try a.move(to: d, force: true)
}
catch {
    print(error.localizedDescription)
}

Install

Just use the Swift Package Manager as usual:

.package(url: "https://github.com/binarybirds/dir", from: "1.0.0"),

⚠️ Don't forget to add "Dir" to your target as a dependency!

License

WTFPL - Do what the fuck you want to.

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

1.0.1 - Feb 27, 2019

  • file permission api
  • fixed file operation access level

1.0.0 - Feb 27, 2019

  • Working with directories in a nice way using Swift.