diff options
author | k-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-07-15 23:46:10 +0000 |
---|---|---|
committer | k-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-07-15 23:46:10 +0000 |
commit | 4dd9427bd27321e5ac8e9bff9a677f527294ac97 (patch) | |
tree | 228bf0f35d7e4e86e37477e14bf9d579010bb461 /Game/Code/MacOSX/Wrapper/UMacResources.pp | |
parent | 17298eb642931ea1eeeb733104a9e0f0432eb04d (diff) | |
download | usdx-4dd9427bd27321e5ac8e9bff9a677f527294ac97.tar.gz usdx-4dd9427bd27321e5ac8e9bff9a677f527294ac97.tar.xz usdx-4dd9427bd27321e5ac8e9bff9a677f527294ac97.zip |
New place for the Resources for Mac OS X: $HOME/Appliations Support/UltraStarDeluxe/Resources
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1201 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/MacOSX/Wrapper/UMacResources.pp')
-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 |