aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-08-20 23:57:04 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-08-20 23:57:04 +0000
commit936d33b3e06375559062ddb451f58da066983d55 (patch)
treecf1f37d34afdbab857449fe2aaf8f4c7e16cd1c1 /Game/Code/Classes
parent3c3a4aa9118e2b7c707505cc62f7b3eddc250618 (diff)
downloadusdx-936d33b3e06375559062ddb451f58da066983d55.tar.gz
usdx-936d33b3e06375559062ddb451f58da066983d55.tar.xz
usdx-936d33b3e06375559062ddb451f58da066983d55.zip
Usage of CopyFile
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1282 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UPlatformMacOSX.pas49
1 files changed, 17 insertions, 32 deletions
diff --git a/Game/Code/Classes/UPlatformMacOSX.pas b/Game/Code/Classes/UPlatformMacOSX.pas
index 68acae25..849c354b 100644
--- a/Game/Code/Classes/UPlatformMacOSX.pas
+++ b/Game/Code/Classes/UPlatformMacOSX.pas
@@ -143,29 +143,21 @@ var
// which is the last one completely searched. Later folders are still to be
// searched for additional files and folders.
DirectoryIsFinished: longint;
- counter: longint;
+ Counter: longint;
UserPathName: string;
- // SourceFile and TaretFile are used to copy a file from on folder to another.
- SourceFile, TargetFile: TFileStream;
- // FileCopyBuffer is the buffer for copying @link(SourceFile) to @link(TargetFile).
- // Its size (4096) has been choosen with little testing. A smaller size makes
- // copying slower. A larger size may make copying large files faster.
- FileCopyBuffer: array [1..4096] of byte;
- // number of bytes read from @link(SourceFile)
- NumberOfBytes: integer;
const
// used to construct the @link(UserPathName)
PathName: string = '/Library/Application Support/UltraStarDeluxe/Resources';
begin
// Get the current folder and save it in OldBaseDir for returning to it, when
// finished.
- getdir(0, OldBaseDir);
+ GetDir(0, OldBaseDir);
// UltraStarDeluxe.app/Contents/Resources contains all the default files and
// folders.
BaseDir := OldBaseDir + '/UltraStarDeluxe.app/Contents/Resources';
- chdir(BaseDir);
+ ChDir(BaseDir);
// Right now, only $HOME/Library/Application Support/UltraStarDeluxe/Resources
// is used.
@@ -180,7 +172,7 @@ begin
repeat
RelativePath := DirectoryList[DirectoryIsFinished];
- chdir(BaseDir + '/' + RelativePath);
+ ChDir(BaseDir + '/' + RelativePath);
if (FindFirst('*', faAnyFile, SearchInfo) = 0) then
begin
repeat
@@ -194,35 +186,28 @@ begin
until (FindNext(SearchInfo) <> 0);
end;
FindClose(SearchInfo);
- inc(DirectoryIsFinished);
+ Inc(DirectoryIsFinished);
until (DirectoryIsFinished = DirectoryList.Count);
// create missing folders
- if not ForceDirectories(UserPathName) then
- Log.LogError('Error: Failed to create the folder: ', UserPathName);
-
- for counter := 0 to DirectoryList.Count-1 do
- if not ForceDirectories(UserPathName + '/' + DirectoryList[counter]) then
- Log.LogError('Error: Failed to create the folder: ', UserPathName + '/' + DirectoryList[counter]);
+ for Counter := 0 to DirectoryList.Count-1 do
+ begin
+ if not ForceDirectories(UserPathName + '/' + DirectoryList[Counter]) then
+ Log.LogError('Failed to create the folder "'+ UserPathName + '/' + DirectoryList[Counter] +'"',
+ 'TPlatformMacOSX.CreateUserFolders');
+ end;
DirectoryList.Free();
// copy missing files
- for counter := 0 to Filelist.Count-1 do
- if not FileExists(UserPathName + '/' + Filelist[counter]) then
- begin
- SourceFile := TFileStream.Create(BaseDir + '/' + Filelist[counter], fmOpenRead);
- TargetFile := TFileStream.Create(UserPathName + '/' + Filelist[counter], fmCreate);
- repeat
- NumberOfBytes := SourceFile.Read(FileCopyBuffer, SizeOf(FileCopyBuffer));
- TargetFile.Write(FileCopyBuffer, NumberOfBytes);
- until (NumberOfBytes < SizeOf(FileCopyBuffer));
- SourceFile.Free;
- TargetFile.Free;
- end;
+ for Counter := 0 to Filelist.Count-1 do
+ begin
+ CopyFile(BaseDir + '/' + Filelist[Counter],
+ UserPathName + '/' + Filelist[Counter], true);
+ end;
FileList.Free();
// go back to the initial folder
- chdir(OldBaseDir);
+ ChDir(OldBaseDir);
end;
function TPlatformMacOSX.GetBundlePath: WideString;