• R/O
  • HTTP
  • SSH
  • HTTPS

KCD: Commit

main code repository.


Commit MetaInfo

Revisionfa6a0a0b51735ab1f9a4caef2dc9bad3ec09bd9e (tree)
Time2018-08-14 20:52:52
Authormasakih <masakih@user...>
Commitermasakih

Log Message

staticプロパティをインスタンスプロパティに変更

Change Summary

Incremental Difference

--- a/KCD/ApplicationDirecrories.swift
+++ b/KCD/ApplicationDirecrories.swift
@@ -33,14 +33,14 @@ struct ApplicationDirecrories {
3333
3434 static let shared = ApplicationDirecrories()
3535
36- static let support = searchedURL(for: .applicationSupportDirectory)
36+ let support = searchedURL(for: .applicationSupportDirectory)
3737 .appendingPathComponent(supportDirName())
3838
39- static let documents = searchedURL(for: .documentDirectory)
39+ let documents = searchedURL(for: .documentDirectory)
4040
41- static let pictures = searchedURL(for: .picturesDirectory)
41+ let pictures = searchedURL(for: .picturesDirectory)
4242
43- private static func searchedURL(for directory: FileManager.SearchPathDirectory) -> URL {
43+ static func searchedURL(for directory: FileManager.SearchPathDirectory) -> URL {
4444
4545 return FileManager.default.urls(for: directory, in: .userDomainMask)
4646 .last
@@ -48,44 +48,46 @@ struct ApplicationDirecrories {
4848 }
4949 }
5050
51-
52-func createDirectory(_ url: URL) -> Bool {
51+extension ApplicationDirecrories {
5352
54- do {
55-
56- try FileManager.default.createDirectory(at: url,
57- withIntermediateDirectories: false,
58- attributes: nil)
59-
60- return true
53+ func createDirectory(_ url: URL) -> Bool {
6154
62- } catch {
63-
64- return false
65- }
66-}
67-
68-func checkDirectory(_ url: URL, create: Bool) -> Bool {
69-
70- do {
71-
72- let resourceValue = try url.resourceValues(forKeys: [.isDirectoryKey])
73- if !resourceValue.isDirectory! {
55+ do {
56+
57+ try FileManager.default.createDirectory(at: url,
58+ withIntermediateDirectories: false,
59+ attributes: nil)
60+
61+ return true
7462
75- print("Expected a folder to store application data, found a file \(url.path).")
63+ } catch {
7664
7765 return false
7866 }
67+ }
68+
69+ func checkDirectory(_ url: URL, create: Bool) -> Bool {
7970
80- return true
81-
82- } catch let error as NSError {
83-
84- if create, error.code == NSFileReadNoSuchFileError {
71+ do {
72+
73+ let resourceValue = try url.resourceValues(forKeys: [.isDirectoryKey])
74+ if !resourceValue.isDirectory! {
75+
76+ print("Expected a folder to store application data, found a file \(url.path).")
77+
78+ return false
79+ }
8580
86- return createDirectory(url)
81+ return true
82+
83+ } catch let error as NSError {
84+
85+ if create, error.code == NSFileReadNoSuchFileError {
86+
87+ return createDirectory(url)
88+ }
89+
90+ return false
8791 }
88-
89- return false
9092 }
9193 }
--- a/KCD/ApplicationDirecroriesExtension.swift
+++ b/KCD/ApplicationDirecroriesExtension.swift
@@ -20,7 +20,7 @@ extension ApplicationDirecrories {
2020
2121 var screenShotSaveDirectory: String {
2222
23- return UserDefaults.standard[.screenShotSaveDirectory] ?? ApplicationDirecrories.pictures.path
23+ return UserDefaults.standard[.screenShotSaveDirectory] ?? ApplicationDirecrories.shared.pictures.path
2424 }
2525
2626 func setScreenshotDirectory(_ newValue: String) {
--- a/KCD/CustomHTTPProtocol.swift
+++ b/KCD/CustomHTTPProtocol.swift
@@ -94,7 +94,7 @@ extension URLCache {
9494
9595 static let kcd = URLCache(memoryCapacity: 32 * 1024 * 1024,
9696 diskCapacity: 1024 * 1024 * 1024,
97- diskPath: ApplicationDirecrories.support.appendingPathComponent("Caches").path)
97+ diskPath: ApplicationDirecrories.shared.support.appendingPathComponent("Caches").path)
9898 static let cachedExtensions = ["swf", "flv", "png", "jpg", "jpeg", "mp3"]
9999
100100 func storeIfNeeded(for task: URLSessionTask, data: Data) {
--- a/KCD/LoggerExtension.swift
+++ b/KCD/LoggerExtension.swift
@@ -10,5 +10,5 @@ import Foundation
1010
1111 extension Logger {
1212
13- static let shared = Logger(destination: ApplicationDirecrories.support.appendingPathComponent("KCD.log"))
13+ static let shared = Logger(destination: ApplicationDirecrories.shared.support.appendingPathComponent("KCD.log"))
1414 }
--- a/KCD/UpgradableShipsWindowController.swift
+++ b/KCD/UpgradableShipsWindowController.swift
@@ -105,7 +105,7 @@ final class UpgradableShipsWindowController: NSWindowController {
105105
106106 private var excludeShipIDsSaveURL: URL {
107107
108- return ApplicationDirecrories.support.appendingPathComponent("ExcludeShipIDs")
108+ return ApplicationDirecrories.shared.support.appendingPathComponent("ExcludeShipIDs")
109109 }
110110
111111 override func windowWillLoad() {
Show on old repository browser