LoginSignup
5
5

More than 5 years have passed since last update.

空き容量取得メモ

Posted at

調べたのでメモ。

    /**
    容量取得
    - 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)
        }
    }
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5