Files
GitHawk/Classes/Models/FilePath.swift
Bas Broek 0db76b3b76 Add + update a11x for navigation titles (#1257)
* Add + update a11x for navigation items

* A file is not a file extension
2017-12-16 22:15:29 -05:00

45 lines
943 B
Swift

//
// FilePath.swift
// Freetime
//
// Created by Ryan Nystrom on 12/3/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
struct FilePath {
static private let joiner = "/"
let components: [String]
var path: String {
return components.joined(separator: FilePath.joiner)
}
var basePath: String? {
let count = components.count
guard count > 1 else { return nil }
return components[0..<count-1].joined(separator: FilePath.joiner)
}
var current: String? {
return components.last
}
var fileExtension: String? {
let components = current?.components(separatedBy: ".") ?? []
if components.count > 1 {
return components.last
} else {
return nil
}
}
func appending(_ component: String) -> FilePath {
return FilePath(components: components + [component])
}
}