OSDN Git Service

shared instanceを持つようにした
[kcd/KCD.git] / KCD / ApplicationDirecrories.swift
index c37fe30..bbab898 100644 (file)
@@ -18,8 +18,21 @@ private func supportDirName() -> String {
         ?? "UnknownAppliation"
 }
 
+func localizedAppName() -> String {
+    
+    guard let name = Bundle.main.localizedInfoDictionary?["CFBundleName"] as? String,
+        !name.isEmpty else {
+            
+            return supportDirName()
+    }
+    
+    return name
+}
+
 struct ApplicationDirecrories {
     
+    static let shared = ApplicationDirecrories()
+    
     static let support = searchedURL(for: .applicationSupportDirectory)
         .appendingPathComponent(supportDirName())
     
@@ -35,6 +48,7 @@ struct ApplicationDirecrories {
     }
 }
 
+
 func createDirectory(_ url: URL) -> Bool {
     
     do {
@@ -65,7 +79,7 @@ func checkDirectory(_ url: URL, create: Bool) -> Bool {
         
         return true
         
-    } catch (let error as NSError) {
+    } catch let error as NSError {
         
         if create, error.code == NSFileReadNoSuchFileError {