         }
     }
     
+    /**
+     Unpack a utree file to default directory in cache. Cache directory is determined by `cacheDirectoryURL`.
+     
+     - parameter treeURL: URL of compressed .utree
+     
+     - returns: URL of folder with .utree extension
+    */
     public func unpackTreeToCacheDirectoryWithTreeURL(treeURL: NSURL) -> NSURL? {
         // Generate unique string to ensure unpack to new clean directory
         let uniqueId = NSUUID().UUIDString

import Foundation
import Zip

public class UsbongFileManager {
    // Make sure it can't be initialized
    private init() {
        // Set custom file extension for Zip
        Zip.addCustomFileExtension("utree")
    }
    
    private static var _defaultManager = UsbongFileManager()
    public static func defaultManager() -> UsbongFileManager {
        return UsbongFileManager._defaultManager
    }
    
    public var rootURL: NSURL = {
        // Default root URL is App's Documents folder
        let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
        return urls[urls.count-1]
    }()
    public var cacheDirectoryURL: NSURL = {
        // Default cache directory is ./Library/Caches/trees/
        let urls = NSFileManager.defaultManager().URLsForDirectory(.CachesDirectory, inDomains: .UserDomainMask)
        return urls[urls.count-1].URLByAppendingPathComponent("trees", isDirectory: true)
    }()
    
    public var defaultFileName = "Untitled"
    
    public func contentsOfDirectoryAtRootURL() -> [NSURL]? {
        return try? NSFileManager.defaultManager().contentsOfDirectoryAtURL(rootURL, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions.SkipsHiddenFiles)
    }
    
    public func clearCacheDirectory() -> Bool {
        do {
            try NSFileManager.defaultManager().removeItemAtURL(cacheDirectoryURL)

        }
    }
    
    /// Get the utree files inside `rootURL`
    public func treesAtRootURL() -> [NSURL] {
        if let contents = contentsOfDirectoryAtRootURL() {
            // filter contents to URLs with path extension 'utree'
            return contents.filter { $0.pathExtension == "utree" }
        }
        
        // Return empty array if contents is nil
        return []
    }
    
    /**
     Get the first found folder with .utree extension. This is typically used for the unpacked .utree.
     
     - parameter url: URL of unpacked .utree
     
     - returns: URL of folder with .utree extension
    */
    public func firstTreeInURL(url: NSURL) -> NSURL? {
        // Get directory of .utree folder in unpack directory
        let contents = try? NSFileManager.defaultManager().contentsOfDirectoryAtURL(url, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions.SkipsHiddenFiles)
