diff options
Diffstat (limited to '')
-rw-r--r-- | Game/Code/MacOSX/Wrapper/UMacResources.pp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Game/Code/MacOSX/Wrapper/UMacResources.pp b/Game/Code/MacOSX/Wrapper/UMacResources.pp new file mode 100644 index 00000000..65c817fc --- /dev/null +++ b/Game/Code/MacOSX/Wrapper/UMacResources.pp @@ -0,0 +1 @@ +unit UMacResources;
interface
procedure init;
implementation
uses
SysUtils,
Classes;
procedure init;
const
PathName : string = '/Library/Application Support/UltraStarDeluxe/Resources';
var
RelativePath, BaseDir, OldBaseDir : string;
SearchInfo : TSearchRec;
DirectoryList, FileList : TStringList;
DirectoryIsFinished : longint;
counter : longint;
UserPathName : string;
SourceFile, TargetFile : TFileStream;
FileCopyBuffer : array [1..4096] of byte;
NumberOfBytes : integer;
begin
getdir (0, OldBaseDir);
BaseDir := OldBaseDir + '/UltraStarDeluxe.app/Contents/Resources';
chdir (BaseDir);
UserPathName := GetEnvironmentVariable('HOME') + PathName;
DirectoryIsFinished := 0;
DirectoryList := TStringList.Create();
FileList := TStringList.Create();
DirectoryList.Add('.');
repeat
RelativePath := DirectoryList[DirectoryIsFinished];
chdir (BaseDir + '/' + RelativePath);
if (FindFirst('*', faAnyFile, SearchInfo) = 0) then
repeat
if DirectoryExists(SearchInfo.Name) then
begin
if (SearchInfo.Name <> '.') and (SearchInfo.Name <> '..') then
DirectoryList.Add(RelativePath + '/' + SearchInfo.Name);
end
else
Filelist.Add(RelativePath + '/' + SearchInfo.Name);
until (FindNext(SearchInfo) <> 0);
FindClose(SearchInfo);
DirectoryIsFinished := succ(DirectoryIsFinished);
until (DirectoryIsFinished = DirectoryList.Count);
if not DirectoryExists(UserPathName) then
mkdir (UserPathName);
for counter := 0 to DirectoryList.Count-1 do
if not DirectoryExists(UserPathName + '/' + DirectoryList[counter]) then
mkdir (UserPathName + '/' + DirectoryList[counter]);
DirectoryList.Free();
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;
FileList.Free();
chdir (OldBaseDir);
end;
end.
\ No newline at end of file |