SWFファイル内の画像を表示/書き出しするGUIツール
修訂 | 184a680a2c7b3759066c9617a4dabef64ebb1532 (tree) |
---|---|
時間 | 2016-10-02 20:59:31 |
作者 | masakih <masakih@user...> |
Commiter | masakih |
例外の処理方法を変更
@@ -108,14 +108,19 @@ class HMSwfDocument: NSDocument { | ||
108 | 108 | guard $0 != NSModalResponseCancel else { return } |
109 | 109 | |
110 | 110 | if FileManager().fileExists(atPath: panel.url!.path) { |
111 | - guard let _ = try? FileManager().removeItem(at: panel.url!) else { | |
111 | + do { | |
112 | + try FileManager().removeItem(at: panel.url!) | |
113 | + } catch { | |
112 | 114 | Swift.print("Fail to remove item.") |
113 | 115 | return |
114 | 116 | } |
115 | 117 | } |
116 | - guard let _ = try? FileManager().copyItem(at: target.url, to: panel.url!) else { | |
118 | + | |
119 | + do { | |
120 | + try FileManager().copyItem(at: target.url, to: panel.url!) | |
121 | + } catch { | |
117 | 122 | Swift.print("Fail to copy item") |
118 | - return | |
123 | + | |
119 | 124 | } |
120 | 125 | } |
121 | 126 | } |
@@ -17,16 +17,18 @@ struct HMTemporaryDirectory { | ||
17 | 17 | |
18 | 18 | init(name: String) throws { |
19 | 19 | let tempDir: URL |
20 | - let o = NSTemporaryDirectory() | |
20 | + let t = NSTemporaryDirectory() | |
21 | 21 | if let identifier = Bundle.main.bundleIdentifier { |
22 | - tempDir = URL(fileURLWithPath: o).appendingPathComponent(identifier) | |
22 | + tempDir = URL(fileURLWithPath: t).appendingPathComponent(identifier) | |
23 | 23 | } else { |
24 | - tempDir = URL(fileURLWithPath: o).appendingPathComponent("KoreNoKaraSu") | |
24 | + tempDir = URL(fileURLWithPath: t).appendingPathComponent("KoreNoKaraSu") | |
25 | 25 | } |
26 | 26 | |
27 | 27 | url = tempDir.appendingPathComponent(name) |
28 | 28 | |
29 | - guard let _ = try? FileManager().createDirectory(at: url, withIntermediateDirectories: true, attributes: nil) else { | |
29 | + do { | |
30 | + try FileManager().createDirectory(at: url, withIntermediateDirectories: true, attributes: nil) | |
31 | + } catch { | |
30 | 32 | print("Can not create directory \(url.path)") |
31 | 33 | throw HMTemporaryDirectoryError.CoanNotCreateDirectory |
32 | 34 | } |