| 1 |
unit DefaultFileManager; |
| 2 |
|
| 3 |
{! |
| 4 |
\file DefaultFileManager.pas |
| 5 |
\brief ????荐?????<?ゃ???????????/span> |
| 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 腟九????鴻?ц???鐚??ゃ?潟?鴻???若??????????筝?) |
| 18 |
\param Path ?ゃ?潟?鴻???若?????????????????後?????/span> |
| 19 |
} |
| 20 |
class function GetFilePath(const Path: String) : String; |
| 21 |
{! |
| 22 |
\brief FromFile??絖?????鐚?ToFile??絖??????????翫?????潟???若???? |
| 23 |
\param FromFile ????荐?????<?ゃ????臀??? |
| 24 |
\param ToFile ??臀??? |
| 25 |
} |
| 26 |
class procedure CopyFile(const FromFile: String; const ToFile : String); |
| 27 |
public |
| 28 |
{! |
| 29 |
\brief ????荐?????<?ゃ??????絎?篏?臀????潟???若???? |
| 30 |
\param FileName ????荐?????<?ゃ??????臀???絎????<?ゃ??/span> |
| 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 |
// ???鴻?????祉???激?с?潟??茯??粋昭?? |
| 54 |
ini.ReadSections(sections); |
| 55 |
for i := 0 to sections.Count - 1 do begin |
| 56 |
// FROM ???? TO?????<?ゃ?????潟???若???? |
| 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 |
// ??臀???鐚???臀????????<????????????翫????????????? |
| 74 |
if ( (FromFile <> '') and (ToFile <> '') ) then begin |
| 75 |
// ../ ?????с?ゃ?潟?鴻???若??????????????筝??????????≪???祉?鴻????????/span> |
| 76 |
// ?違?????х舟?????????障?? |
| 77 |
fromPath := GetFilePath( FromFile ); |
| 78 |
toPath := GetFilePath( ToFile ); |
| 79 |
if ( FileExists(fromPath) ) then begin |
| 80 |
// ??臀????????c????篏????????? |
| 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. |