• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

艦娘をちゅーちゅーします


Commit MetaInfo

Révision970f28aac73ca42538dfea33f734c20f7d34e79d (tree)
l'heure2017-08-06 17:24:48
Auteurmasakih <masakih@user...>
Commitermasakih

Message de Log

一時フォルダを削除するようにした

Change Summary

Modification

--- a/ExtractKanMusu/ViewController.swift
+++ b/ExtractKanMusu/ViewController.swift
@@ -28,6 +28,8 @@ struct ApplicationDirecrories {
2828
2929 class ViewController: NSViewController {
3030
31+ static let chuchu = "ちゅーちゅー"
32+ static let tempDirName = "___temp_chu-chu-_ship___"
3133
3234 @IBOutlet var cachePathField: NSPathControl!
3335 @IBOutlet var outputFolderField: NSPathControl!
@@ -109,12 +111,22 @@ extension ViewController {
109111 throw ExtractKanMusu.urlMissing("Cache dir is nil")
110112 }
111113
112- let tempURL = tempParentURL.appendingPathComponent("___temp_chu-chu-_ship___")
114+ let tempURL = tempParentURL.appendingPathComponent(ViewController.tempDirName)
113115
114116 try FileManager.default
115117 .createDirectory(at: tempURL, withIntermediateDirectories: true, attributes: nil)
116118
119+ }
120+ func deleteTempDir() throws {
121+
122+ guard let tempParentURL = cachePathField.url else {
123+
124+ throw ExtractKanMusu.urlMissing("Cache dir is nil")
125+ }
117126
127+ let tempURL = tempParentURL.appendingPathComponent(ViewController.tempDirName)
128+
129+ try FileManager.default.removeItem(at: tempURL)
118130 }
119131 func createDestDir() throws {
120132
@@ -123,12 +135,11 @@ extension ViewController {
123135 throw ExtractKanMusu.urlMissing("Output dir is nil")
124136 }
125137
126- let destURL = destParentURL.appendingPathComponent("ちゅーちゅー")
138+ let destURL = destParentURL.appendingPathComponent(ViewController.chuchu)
127139
128140 try FileManager.default
129141 .createDirectory(at: destURL, withIntermediateDirectories: true, attributes: nil)
130142
131-
132143 }
133144
134145
@@ -144,6 +155,18 @@ extension ViewController {
144155 existDestinationDir
145156 else { return }
146157
158+
159+ defer {
160+
161+ do {
162+
163+ try deleteTempDir()
164+
165+ } catch {
166+ print(error)
167+ }
168+ }
169+
147170 do {
148171
149172 try createTempDir()
@@ -175,8 +198,8 @@ extension ViewController {
175198
176199 do {
177200
178- let tempURL = originalDir.appendingPathComponent("___temp_chu-chu-_ship___")
179- let destURL = destinationDir.appendingPathComponent("ちゅーちゅー")
201+ let tempURL = originalDir.appendingPathComponent(ViewController.tempDirName)
202+ let destURL = destinationDir.appendingPathComponent(ViewController.chuchu)
180203
181204 let swfs = try FileManager.default
182205 .contentsOfDirectory(at: tempURL, includingPropertiesForKeys: nil)