/** * Tae Won Ha - http://taewon.de - @hataewon * See LICENSE */ import Foundation extension URL { func isDirectParent(of url: URL) -> Bool { guard self.isFileURL && url.isFileURL else { return false } let myPathComps = self.pathComponents let targetPathComps = url.pathComponents guard targetPathComps.count == myPathComps.count + 1 else { return false } return Array(targetPathComps[0.. Bool { guard self.isFileURL && url.isFileURL else { return false } let myPathComps = self.pathComponents let targetPathComps = url.pathComponents guard targetPathComps.count > myPathComps.count else { return false } return Array(targetPathComps[0.. Bool { if parentUrl == self { return false } let pathComps = self.pathComponents let parentPathComps = parentUrl.pathComponents guard pathComps.count > parentPathComps.count else { return false } guard Array(pathComps[0.. Bool { var rsrc: AnyObject? do { try (self as NSURL).getResourceValue(&rsrc, forKey: URLResourceKey(rawValue: key)) } catch let error as NSError { // FIXME error handling print("\(#function): \(self) -> ERROR while getting \(key): \(error)") return false } if let result = rsrc as? NSNumber { return result.boolValue } return false } }