1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-22 05:01:50 +03:00
vimr/VimR/FileItem.swift

60 lines
1.3 KiB
Swift
Raw Normal View History

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Foundation
class Token: Equatable {}
func == (left: Token, right: Token) -> Bool {
return left === right
}
func ==(left: FileItem, right: FileItem) -> Bool {
return left.url == right.url
}
class FileItem : CustomStringConvertible, Hashable {
2016-09-25 18:50:33 +03:00
let url: URL
2016-11-12 18:42:10 +03:00
let isDir: Bool
let isHidden: Bool
let isPackage: Bool
var hashValue: Int {
return url.hashValue
}
/// When nil, then it has never been fnmatch'ed.
weak var ignoreToken: Token?
var ignore = false
var needsScanChildren = false
var childrenScanned = false
var children: [FileItem] = []
var description: String {
2016-11-12 18:42:10 +03:00
return "<FileItem: \(self.url), dir=\(self.isDir), hidden=\(self.isHidden), package=\(self.isPackage), "
+ "needsScan=\(self.needsScanChildren), childrenScanned=\(self.childrenScanned), "
+ "ignore=\(self.ignore), ignoreToken=\(self.ignoreToken), "
+ "children=\(self.children.count)>"
}
2016-09-25 18:50:33 +03:00
init(_ url: URL) {
self.url = url
2016-11-12 18:42:10 +03:00
self.isDir = url.isDir
self.isHidden = url.isHidden
self.isPackage = url.isPackage
}
2016-09-07 21:12:18 +03:00
2016-09-25 18:50:33 +03:00
func removeChild(withUrl url: URL) {
guard let idx = self.children.index(where: { $0.url == url }) else {
2016-09-07 21:12:18 +03:00
return
}
2016-09-25 18:50:33 +03:00
self.children.remove(at: idx)
2016-09-07 21:12:18 +03:00
}
}