Develop and Download Open Source Software

Browse CVS Repository

Annotation of /gikonavigoeson/gikonavi/DefaultFileManager.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download) (as text)
Mon Jul 3 14:37:29 2006 UTC (17 years, 9 months ago) by h677
Branch: MAIN
Changes since 1.1: +2 -0 lines
File MIME type: text/x-pascal
配置先フォルダが存在しないとコピーできない不具合の修正

1 h677 1.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 h677 1.2 // ??臀???????????????????????
83     GikoSys.ForceDirectoriesEx(toPath);
84 h677 1.1 Windows.CopyFile( PChar(fromPath), PChar(toPath), False);
85     end;
86     end;
87     end;
88    
89     end;
90     class function TDefaultFileManager.GetFilePath(const Path: String): String;
91     begin
92     Result := GikoSys.GetAppDir +
93     CustomStringReplace(
94     CustomStringReplace(Path, '/', '\' ), '..\', '');
95     end;
96     end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26