• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

ギコナビ


Commit MetaInfo

Revisiond037acf5e49a6f1e2c1f36914a46d84a3045f670 (tree)
Time2009-05-24 21:37:06
Authorh677 <h677>
Commiterh677

Log Message

お気に入りのファイルの置き換えタイミングの変更
一旦一時ファイルに出力した後に、バックアップファイルへの変更、
正式ファイル名への置き換えを実施するようにした。

Change Summary

Incremental Difference

--- a/Favorite.pas
+++ b/Favorite.pas
@@ -425,31 +425,47 @@ end;
425425
426426 procedure TFavoriteDM.WriteFavorite;
427427 var
428- FileName, tmpFileName: string;
428+ FileName, tmpFileName, bakFileName: string;
429429 SaveList: TStringList;
430-
430+ Buffer: array[0..MAX_PATH] of Char; // ƒoƒbƒtƒ@
431+ FileRep : Boolean;
431432 begin
432433 FavoriteDM.Modified := true;
433434 FileName := GikoSys.GetConfigDir + FAVORITE_FILE_NAME;
434- if FileExists(FileName) then begin
435- tmpFileName := GikoSys.GetConfigDir + '~' + FAVORITE_FILE_NAME;
436- if FileExists(tmpFileName) then
437- SysUtils.DeleteFile(tmpFileName); //SysUtils.‚ð‚‚¯‚È‚¢‚ÆWinAPI‚Æ‹æ•Ê‚Å‚«‚È‚¢‚Ì‚Å
438- RenameFile(FileName, tmpFileName);
439- end;
440435 SaveList := TStringList.Create;
441- try
442- SaveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>');
443- SaveList.Add('<favorite>');
444- try
445- AddSaveString(TreeView.Items.GetFirstNode.getFirstChild, SaveList);
446- except
447- end;
448- SaveList.Add('</favorite>');
449- SaveList.SaveToFile(FileName);
450- finally
451- SaveList.Free;
452- end;
436+ tmpFileName := '';
437+ // ‘‚«ž‚Ý—pˆêŽžƒtƒ@ƒCƒ‹Žæ“¾
438+ if GetTempFileName(PChar(GikoSys.GetConfigDir), PChar('fav'), 0, Buffer) <> 0 then begin
439+ tmpFileName := Buffer;
440+ try
441+ try
442+ SaveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>');
443+ SaveList.Add('<favorite>');
444+ AddSaveString(TreeView.Items.GetFirstNode.getFirstChild, SaveList);
445+ SaveList.Add('</favorite>');
446+ // ˆêŽžƒtƒ@ƒCƒ‹‚Æ‚µ‚Ä•Û‘¶
447+ SaveList.SaveToFile(tmpFileName);
448+ FileRep := True;
449+ // ‘O‚̃tƒ@ƒCƒ‹‚ðˆÚ“®‚·‚é
450+ if FileExists(FileName) then begin
451+ bakFileName := GikoSys.GetConfigDir + '~' + FAVORITE_FILE_NAME;
452+ if FileExists(bakFileName) then begin
453+ FileRep := SysUtils.DeleteFile(bakFileName); //SysUtils.‚ð‚‚¯‚È‚¢‚ÆWinAPI‚Æ‹æ•Ê‚Å‚«‚È‚¢‚Ì‚Å
454+ end;
455+ if FileRep then begin
456+ FileRep := RenameFile(FileName, bakFileName);
457+ end;
458+ end;
459+ // ³‹K‚̃tƒ@ƒCƒ‹–¼‚ɃŠƒl[ƒ€‚·‚é
460+ if FileRep then begin
461+ FileRep := RenameFile(tmpFileName, FileName);
462+ end;
463+ except
464+ end;
465+ finally
466+ SaveList.Free;
467+ end;
468+ end;
453469 end;
454470
455471 procedure TFavoriteDM.AddSaveString(Node: TTreeNode; SaveList: TStringList);