1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-11 07:22:23 +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 FileItem : CustomStringConvertible, Hashable, Comparable {
2016-11-24 22:06:56 +03:00
static func ==(left: FileItem, right: FileItem) -> Bool {
return left.url == right.url
}
static func <(left: FileItem, right: FileItem) -> Bool {
return left.url.lastPathComponent < right.url.lastPathComponent
}
2016-09-25 18:50:33 +03:00
let url: URL
2017-05-13 10:40:58 +03:00
var isDir: Bool {
return self.url.isDir
}
var isHidden: Bool {
return self.url.isHidden
}
var isPackage: Bool {
2017-05-14 13:06:21 +03:00
return self.url.isPackage
2017-05-13 10:40:58 +03:00
}
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
2016-11-24 22:06:56 +03:00
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), "
2017-04-24 21:36:34 +03:00
+ "ignore=\(self.ignore), ignoreToken=\(String(describing: self.ignoreToken)), "
+ "children=\(self.children.count)>"
}
2016-09-25 18:50:33 +03:00
init(_ url: URL) {
self.url = url
}
2016-11-25 01:49:53 +03:00
func child(with url: URL) -> FileItem? {
return self.children.first { $0.url == url }
2016-11-25 01:49:53 +03:00
}
}