Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created March 25, 2016 18:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odrobnik/bbfb369fe66de722940d to your computer and use it in GitHub Desktop.
Save odrobnik/bbfb369fe66de722940d to your computer and use it in GitHub Desktop.
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