gitリポジトリのurlを貼り付けるだけでアプリケーションのビルドを実行するアプリ。 macOS用
Revisión | af2cf488e249135d104a1727e87bc7ee75d60486 (tree) |
---|---|
Tiempo | 2017-08-12 23:00:03 |
Autor | masakih <masakih@user...> |
Commiter | masakih |
処理を読みやすくした
@@ -35,41 +35,46 @@ struct ApplicationDirecrories { | ||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | -func checkDirectory(_ url: URL) -> Bool { | |
38 | +func createDirectory(_ url: URL) -> Bool { | |
39 | 39 | |
40 | - var success = true | |
40 | + do { | |
41 | + | |
42 | + try FileManager.default.createDirectory(at: url, | |
43 | + withIntermediateDirectories: false, | |
44 | + attributes: nil) | |
45 | + | |
46 | + return true | |
47 | + | |
48 | + } catch { | |
49 | + | |
50 | + return false | |
51 | + | |
52 | + } | |
53 | +} | |
54 | + | |
55 | +func checkDirectory(_ url: URL) -> Bool { | |
41 | 56 | |
42 | 57 | do { |
43 | 58 | |
44 | - let p = try url.resourceValues(forKeys: [.isDirectoryKey]) | |
45 | - if !p.isDirectory! { | |
59 | + let resourceValue = try url.resourceValues(forKeys: [.isDirectoryKey]) | |
60 | + if !resourceValue.isDirectory! { | |
46 | 61 | |
47 | 62 | print("Expected a folder to store application data, found a file \(url.path).") |
48 | - success = false | |
63 | + | |
64 | + return false | |
49 | 65 | } |
50 | 66 | |
67 | + return true | |
68 | + | |
51 | 69 | } catch { |
52 | 70 | |
53 | 71 | let nserror = error as NSError |
54 | 72 | if nserror.code == NSFileReadNoSuchFileError { |
55 | 73 | |
56 | - do { | |
57 | - | |
58 | - try FileManager | |
59 | - .default | |
60 | - .createDirectory(at: url, | |
61 | - withIntermediateDirectories: false, | |
62 | - attributes: nil) | |
63 | - | |
64 | - } catch { | |
65 | - | |
66 | - success = false | |
67 | - } | |
68 | - } else { | |
74 | + return createDirectory(url) | |
69 | 75 | |
70 | - success = false | |
71 | 76 | } |
77 | + | |
78 | + return false | |
72 | 79 | } |
73 | - | |
74 | - return success | |
75 | 80 | } |