Created
March 25, 2016 18:05
-
-
Save odrobnik/bbfb369fe66de722940d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Result | |
{ | |
case Success() | |
case Error(error: NSError) | |
case Properties(nodes: [WebDAVNode]) | |
} | |
typealias WebDAVRequestCompletion = (Result)->() | |
func listDirectory(path: String, completion: WebDAVRequestCompletion?) | |
{ | |
var path = path | |
if !path.hasSuffix("/") | |
{ | |
path.appendContentsOf("/") | |
} | |
// need at least level 1 to see the directoy contents | |
retrieveProperties(path, depth: 1) { (result) in | |
if case .Properties(let nodes) = result | |
{ | |
let children = nodes.filter{ (node) -> Bool in | |
return node.href != path | |
} | |
completion?(Result.Properties(nodes: children)) | |
} | |
else | |
{ | |
completion?(result) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment