OSDN Git Service
(root)
/
kcd
/
KCD.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0c3ec4c
)
staticプロパティをインスタンスプロパティに変更
master
author
masakih
<masakih@users.sourceforge.jp>
Tue, 14 Aug 2018 11:52:52 +0000
(20:52 +0900)
committer
masakih
<masakih@users.sourceforge.jp>
Tue, 14 Aug 2018 11:52:52 +0000
(20:52 +0900)
KCD/ApplicationDirecrories.swift
patch
|
blob
|
history
KCD/ApplicationDirecroriesExtension.swift
patch
|
blob
|
history
KCD/CustomHTTPProtocol.swift
patch
|
blob
|
history
KCD/LoggerExtension.swift
patch
|
blob
|
history
KCD/UpgradableShipsWindowController.swift
patch
|
blob
|
history
diff --git
a/KCD/ApplicationDirecrories.swift
b/KCD/ApplicationDirecrories.swift
index
bbab898
..
ce1f60a
100644
(file)
--- a/
KCD/ApplicationDirecrories.swift
+++ b/
KCD/ApplicationDirecrories.swift
@@
-33,14
+33,14
@@
struct ApplicationDirecrories {
static let shared = ApplicationDirecrories()
static let shared = ApplicationDirecrories()
-
static
let support = searchedURL(for: .applicationSupportDirectory)
+ let support = searchedURL(for: .applicationSupportDirectory)
.appendingPathComponent(supportDirName())
.appendingPathComponent(supportDirName())
-
static
let documents = searchedURL(for: .documentDirectory)
+ let documents = searchedURL(for: .documentDirectory)
-
static
let pictures = searchedURL(for: .picturesDirectory)
+ let pictures = searchedURL(for: .picturesDirectory)
-
private
static func searchedURL(for directory: FileManager.SearchPathDirectory) -> URL {
+ static func searchedURL(for directory: FileManager.SearchPathDirectory) -> URL {
return FileManager.default.urls(for: directory, in: .userDomainMask)
.last
return FileManager.default.urls(for: directory, in: .userDomainMask)
.last
@@
-48,44
+48,46
@@
struct ApplicationDirecrories {
}
}
}
}
-
-func createDirectory(_ url: URL) -> Bool {
+extension ApplicationDirecrories {
- do {
-
- try FileManager.default.createDirectory(at: url,
- withIntermediateDirectories: false,
- attributes: nil)
-
- return true
+ func createDirectory(_ url: URL) -> Bool {
- } catch {
-
- return false
- }
-}
-
-func checkDirectory(_ url: URL, create: Bool) -> Bool {
-
- do {
-
- let resourceValue = try url.resourceValues(forKeys: [.isDirectoryKey])
- if !resourceValue.isDirectory! {
+ do {
+
+ try FileManager.default.createDirectory(at: url,
+ withIntermediateDirectories: false,
+ attributes: nil)
+
+ return true
- print("Expected a folder to store application data, found a file \(url.path).")
+ } catch {
return false
}
return false
}
+ }
+
+ func checkDirectory(_ url: URL, create: Bool) -> Bool {
- return true
-
- } catch let error as NSError {
-
- if create, error.code == NSFileReadNoSuchFileError {
+ do {
+
+ let resourceValue = try url.resourceValues(forKeys: [.isDirectoryKey])
+ if !resourceValue.isDirectory! {
+
+ print("Expected a folder to store application data, found a file \(url.path).")
+
+ return false
+ }
- return createDirectory(url)
+ return true
+
+ } catch let error as NSError {
+
+ if create, error.code == NSFileReadNoSuchFileError {
+
+ return createDirectory(url)
+ }
+
+ return false
}
}
-
- return false
}
}
}
}
diff --git
a/KCD/ApplicationDirecroriesExtension.swift
b/KCD/ApplicationDirecroriesExtension.swift
index
27b0e5a
..
9420ce4
100644
(file)
--- a/
KCD/ApplicationDirecroriesExtension.swift
+++ b/
KCD/ApplicationDirecroriesExtension.swift
@@
-20,7
+20,7
@@
extension ApplicationDirecrories {
var screenShotSaveDirectory: String {
var screenShotSaveDirectory: String {
- return UserDefaults.standard[.screenShotSaveDirectory] ?? ApplicationDirecrories.pictures.path
+ return UserDefaults.standard[.screenShotSaveDirectory] ?? ApplicationDirecrories.
shared.
pictures.path
}
func setScreenshotDirectory(_ newValue: String) {
}
func setScreenshotDirectory(_ newValue: String) {
diff --git
a/KCD/CustomHTTPProtocol.swift
b/KCD/CustomHTTPProtocol.swift
index
9bb625f
..
53d129d
100644
(file)
--- a/
KCD/CustomHTTPProtocol.swift
+++ b/
KCD/CustomHTTPProtocol.swift
@@
-94,7
+94,7
@@
extension URLCache {
static let kcd = URLCache(memoryCapacity: 32 * 1024 * 1024,
diskCapacity: 1024 * 1024 * 1024,
static let kcd = URLCache(memoryCapacity: 32 * 1024 * 1024,
diskCapacity: 1024 * 1024 * 1024,
- diskPath: ApplicationDirecrories.support.appendingPathComponent("Caches").path)
+ diskPath: ApplicationDirecrories.s
hared.s
upport.appendingPathComponent("Caches").path)
static let cachedExtensions = ["swf", "flv", "png", "jpg", "jpeg", "mp3"]
func storeIfNeeded(for task: URLSessionTask, data: Data) {
static let cachedExtensions = ["swf", "flv", "png", "jpg", "jpeg", "mp3"]
func storeIfNeeded(for task: URLSessionTask, data: Data) {
diff --git
a/KCD/LoggerExtension.swift
b/KCD/LoggerExtension.swift
index
1055d40
..
eadc277
100644
(file)
--- a/
KCD/LoggerExtension.swift
+++ b/
KCD/LoggerExtension.swift
@@
-10,5
+10,5
@@
import Foundation
extension Logger {
extension Logger {
- static let shared = Logger(destination: ApplicationDirecrories.support.appendingPathComponent("KCD.log"))
+ static let shared = Logger(destination: ApplicationDirecrories.s
hared.s
upport.appendingPathComponent("KCD.log"))
}
}
diff --git
a/KCD/UpgradableShipsWindowController.swift
b/KCD/UpgradableShipsWindowController.swift
index
e597206
..
e721e6c
100644
(file)
--- a/
KCD/UpgradableShipsWindowController.swift
+++ b/
KCD/UpgradableShipsWindowController.swift
@@
-105,7
+105,7
@@
final class UpgradableShipsWindowController: NSWindowController {
private var excludeShipIDsSaveURL: URL {
private var excludeShipIDsSaveURL: URL {
- return ApplicationDirecrories.support.appendingPathComponent("ExcludeShipIDs")
+ return ApplicationDirecrories.s
hared.s
upport.appendingPathComponent("ExcludeShipIDs")
}
override func windowWillLoad() {
}
override func windowWillLoad() {