Created
April 30, 2016 23:29
-
-
Save MTattin/04ca42131f37f65177e447d44947100e to your computer and use it in GitHub Desktop.
空き容量取得メモ ref: http://qiita.com/MTattin/items/103c7b47903108c68d2d
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
/** | |
容量取得 | |
- returns: freeとtotalのサイズ取得 | |
*/ | |
static func GetDiskSize() -> (free: Double?, total: Double?) { | |
let _0_paths: NSArray = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomainMask.UserDomainMask, true) | |
let _0_last: String = _0_paths.lastObject as! String | |
do { | |
let _0_dic: NSDictionary = try NSFileManager.defaultManager().attributesOfFileSystemForPath(_0_last) | |
return ( | |
(_0_dic[NSFileSystemFreeSize] as! NSNumber).doubleValue, | |
(_0_dic[NSFileSystemSize] as! NSNumber).doubleValue | |
) | |
} catch let e as NSError { | |
print("error : \(e.localizedDescription)") | |
return (nil, nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment