OSDN Git Service

archive-inst,元のフォルダ構成にない設定ファイル用フォルダがあるとき、インストールが失敗する不具合を修正
authorttp <ttp@users.sourceforge.jp>
Thu, 8 Oct 2009 04:28:41 +0000 (13:28 +0900)
committerttp <ttp@users.sourceforge.jp>
Thu, 8 Oct 2009 04:28:41 +0000 (13:28 +0900)
archive-inst/Program.cs

index 75ac08c..002f6c2 100644 (file)
@@ -39,14 +39,22 @@ namespace ArchiveInstall
                                } catch {\r
                                }\r
                                if (list != null) {\r
-                                       foreach (InstalledFile changedFile in list.Verify(targetDir)) { // 変更されたファイルたちを。。。\r
+                                       // 変更されたファイル(設定ファイル)をキープする処理\r
+                                       foreach (InstalledFile changedFile in list.Verify(targetDir)) {\r
                                                string changedFilePath = Path.Combine(targetDir, changedFile.Path);\r
                                                string toBeChangedFilePath = Path.Combine(installSrc, changedFile.Path);\r
                                                \r
+                                               // 新規のファイルは退避させる\r
                                                if (File.Exists(toBeChangedFilePath)) {\r
-                                                       File.Move(toBeChangedFilePath, toBeChangedFilePath + ".newfile"); // 新規を退避させて\r
+                                                       File.Move(toBeChangedFilePath, toBeChangedFilePath + ".newfile");\r
                                                }\r
-                                               File.Copy(changedFilePath, toBeChangedFilePath); // installSrcの方に反映させておく\r
+                                               \r
+                                               // 変更済みファイルをinstallSrcの方に反映させる\r
+                                               if (! Directory.Exists(Path.GetDirectoryName(toBeChangedFilePath))) {\r
+                                                       // フォルダがない場合は作る\r
+                                                       Directory.CreateDirectory(Path.GetDirectoryName(toBeChangedFilePath));\r
+                                               }\r
+                                               File.Copy(changedFilePath, toBeChangedFilePath);\r
                                        }\r
                                }\r
                        } else {\r