• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

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

ギコナビ


Commit MetaInfo

修訂3916c684b7c91c1c55f3e081cfc0759e56cd9a85 (tree)
時間2006-07-03 23:00:35
作者h677 <h677>
Commiterh677

Log Message

初期化ファイルの処理をまとめるクラスを新設

Change Summary

差異

--- /dev/null
+++ b/DefaultFileManager.pas
@@ -0,0 +1,94 @@
1+unit DefaultFileManager;
2+
3+{!
4+\file DefaultFileManager.pas
5+\brief ‰ŠúÝ’èƒtƒ@ƒCƒ‹ŠÇ—ƒNƒ‰ƒX
6+}
7+interface
8+
9+uses
10+ Windows, Classes, Controls, ComCtrls, SysUtils;
11+
12+type
13+
14+ TDefaultFileManager = class(TObject)
15+ private
16+ {!
17+ \brief â‘΃pƒX‚Å•Ô‚·iƒCƒ“ƒXƒg[ƒ‹ƒtƒHƒ‹ƒ_‰º)
18+ \param Path ƒCƒ“ƒXƒg[ƒ‹ƒtƒHƒ‹ƒ_‚©‚ç‚Ì‘Š‘΃pƒX
19+ }
20+ class function GetFilePath(const Path: String) : String;
21+ {!
22+ \brief FromFile‚ª‘¶Ý‚µCToFile‚ª‘¶Ý‚µ‚È‚¢ê‡‚ɃRƒs[‚·‚é
23+ \param FromFile ‰ŠúÝ’èƒtƒ@ƒCƒ‹”z’uŒ³
24+ \param ToFile ”z’uæ
25+ }
26+ class procedure CopyFile(const FromFile: String; const ToFile : String);
27+ public
28+ {!
29+ \brief ‰ŠúÝ’èƒtƒ@ƒCƒ‹‚ðŽw’èˆÊ’u‚ɃRƒs[‚·‚é
30+ \param FileName ‰ŠúÝ’èƒtƒ@ƒCƒ‹‚Ì”z’uŽw’èƒtƒ@ƒCƒ‹
31+ }
32+ class procedure CopyDefaultFiles(const FileName: String);
33+ end;
34+
35+implementation
36+
37+uses
38+ IniFiles,ShellAPI, GikoSystem, MojuUtils;
39+
40+class procedure TDefaultFileManager.CopyDefaultFiles(const FileName: String);
41+const
42+ FROM_KEY = 'FROM';
43+ TO_KEY = 'TO';
44+var
45+ ini : TMemIniFile;
46+ sections : TStringList;
47+ i: Integer;
48+begin
49+ if ( FileExists(FileName) ) then begin
50+ ini := TMemIniFile.Create( FileName );
51+ sections := TStringList.Create;
52+ try
53+ // ‚·‚ׂẴZƒNƒVƒ‡ƒ“‚ð“ǂݍž‚Þ
54+ ini.ReadSections(sections);
55+ for i := 0 to sections.Count - 1 do begin
56+ // FROM ‚©‚ç TO‚Ƀtƒ@ƒCƒ‹‚ðƒRƒs[‚·‚é
57+ CopyFile( ini.ReadString(sections[i], FROM_KEY, ''),
58+ ini.ReadString(sections[i], TO_KEY, '') );
59+ end;
60+ finally
61+ sections.Clear;
62+ sections.Free;
63+ ini.Free;
64+ end;
65+ end;
66+
67+end;
68+class procedure TDefaultFileManager.CopyFile(
69+ const FromFile: String; const ToFile : String);
70+var
71+ fromPath, toPath : String;
72+begin
73+ // ”z’uŒ³C”z’uæ‚Ì‚Ç‚¿‚ç‚©‚ª–¢’è‚̏ꍇ‚͉½‚à‚µ‚È‚¢
74+ if ( (FromFile <> '') and (ToFile <> '') ) then begin
75+ // ../ ‚Æ‚©‚ŃCƒ“ƒXƒg[ƒ‹ƒtƒHƒ‹ƒ_‚æ‚èã‚̗̈æ‚ɃAƒNƒZƒX‚³‚ê‚é‚Æ
76+ // ¢‚é‚Ì‚Å’uŠ·‚µ‚Ä‚µ‚Ü‚¤
77+ fromPath := GetFilePath( FromFile );
78+ toPath := GetFilePath( ToFile );
79+ if ( FileExists(fromPath) ) then begin
80+ // ”z’uæ‚É‚ ‚Á‚½‚牽‚à‚µ‚È‚¢
81+ if (not FileExists(toPath)) then begin
82+ Windows.CopyFile( PChar(fromPath), PChar(toPath), False);
83+ end;
84+ end;
85+ end;
86+
87+end;
88+class function TDefaultFileManager.GetFilePath(const Path: String): String;
89+begin
90+ Result := GikoSys.GetAppDir +
91+ CustomStringReplace(
92+ CustomStringReplace(Path, '/', '\' ), '..\', '');
93+end;
94+end.
--- a/GikoDataModule.pas
+++ b/GikoDataModule.pas
@@ -448,7 +448,8 @@ uses
448448 ToolBarUtil, NewBoard, HTMLCreate, IndividualAbon,
449449 GikoBayesian, About, ShellAPI,
450450 RoundName, RoundData, Menus, ListViewUtils,
451- ThreadControl, GikoMessage, InputAssist;
451+ ThreadControl, GikoMessage, InputAssist,
452+ DefaultFileManager;
452453
453454 const
454455 MSG_ERROR : string = 'ƒGƒ‰[';
@@ -1507,6 +1508,11 @@ end;
15071508 ////////////////////////////////ƒXƒŒƒbƒh‚Ü‚Å‚¨‚µ‚Ü‚¢/////////////////////
15081509 procedure TGikoDM.DataModuleCreate(Sender: TObject);
15091510 begin
1511+ // GikoDM‚æ‚è‚à‘‚­‰Šú‰»‚³‚ê‚é•K—v‚ª‚ ‚éƒtƒ@ƒCƒ‹‚ª‚¢‚é‚Æ‚±‚¯‚éII
1512+ // ‰Šú‰»‡”Ô‚É’ˆÓ‚·‚邱‚ƁII
1513+ //‰‰ñ‹N“®Žž‚̏‰Šú‰»ƒtƒ@ƒCƒ‹Ý’è
1514+ TDefaultFileManager.CopyDefaultFiles(
1515+ GikoSys.GetAppDir + 'defaultFiles.ini');
15101516 end;
15111517 // *************************************************************************
15121518 //! ƒƒOŒŸõƒ_ƒCƒAƒƒO‚ð•\Ž¦‚·‚é
--- a/gikoNavi.dpr
+++ b/gikoNavi.dpr
@@ -71,7 +71,8 @@ uses
7171 BrowserRecord in 'BrowserRecord.pas',
7272 GikoMessage in 'GikoMessage.pas',
7373 InputAssist in 'InputAssist.pas' {InputAssistForm},
74- InputAssistDataModule in 'InputAssistDataModule.pas' {InputAssistDM: TDataModule};
74+ InputAssistDataModule in 'InputAssistDataModule.pas' {InputAssistDM: TDataModule},
75+ DefaultFileManager in 'DefaultFileManager.pas';
7576
7677 {$R *.RES}
7778 {$R gikoResource.res}
Binary files a/gikoNavi.res and b/gikoNavi.res differ