Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SusanDoggie committed Dec 9, 2017
1 parent 68091fc commit 35dbfae
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions Sources/Doggie/Foundation/FileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension FileManager {
var checked: Set<URL> = []
var searchPaths = Array(urls)

while let url = searchPaths.popLast()?.resolvingSymlinksInPath() {
while let url = searchPaths.popLast()?.standardized.resolvingSymlinksInPath() {

guard !checked.contains(url) else { continue }
guard let enumerator = self.enumerator(at: url, includingPropertiesForKeys: nil, options: [], errorHandler: nil) else { continue }
Expand All @@ -43,13 +43,40 @@ extension FileManager {

for url in enumerator {

guard let url = url as? URL, let resourceValues = try? url.resourceValues(forKeys: [.isRegularFileKey]) else { continue }
guard let url = url as? URL else { continue }

if resourceValues.isRegularFile == true {
result.insert(url)
} else {
searchPaths.append(url)
}
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)

guard let resourceValues = try? url.resourceValues(forKeys: [.isRegularFileKey, .isSymbolicLinkKey, .isAliasFileKey]) else { continue }

if resourceValues.isAliasFile == true {

guard let _url = try? URL(resolvingAliasFileAt: url) else { continue }
searchPaths.append(_url)

} else if resourceValues.isSymbolicLink == true {

searchPaths.append(url)

} else if resourceValues.isRegularFile == true {

result.insert(url)
}

#else

guard let resourceValues = try? url.resourceValues(forKeys: [.isRegularFileKey, .isSymbolicLinkKey]) else { continue }

if resourceValues.isSymbolicLink == true {

searchPaths.append(url)

} else if resourceValues.isRegularFile == true {

result.insert(url)
}

#endif
}
}

Expand Down

0 comments on commit 35dbfae

Please sign in to comment.