From 27ae008cc69acb6ecfe509d1850ed8480395f3f4 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Thu, 7 Apr 2011 06:35:58 +0000 Subject: [PATCH] fpchess: Implements obtaining the resources directory, allows running from the Bundle in Mac OS X git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1553 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/fpchess/chessconfig.pas | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/applications/fpchess/chessconfig.pas b/applications/fpchess/chessconfig.pas index 3edbc8233..be9b4d257 100644 --- a/applications/fpchess/chessconfig.pas +++ b/applications/fpchess/chessconfig.pas @@ -22,11 +22,41 @@ var implementation +{$ifdef Darwin} +uses + MacOSAll; +{$endif} + +const + BundleResourcesDirectory = '/Contents/Resources/'; + { TChessConfig } function TChessConfig.GetResourcesDir: string; +{$ifdef Darwin} +var + pathRef: CFURLRef; + pathCFStr: CFStringRef; + pathStr: shortstring; +{$endif} begin +{$ifdef UNIX} +{$ifdef Darwin} + pathRef := CFBundleCopyBundleURL(CFBundleGetMainBundle()); + pathCFStr := CFURLCopyFileSystemPath(pathRef, kCFURLPOSIXPathStyle); + CFStringGetPascalString(pathCFStr, @pathStr, 255, CFStringGetSystemEncoding()); + CFRelease(pathRef); + CFRelease(pathCFStr); + Result := pathStr + BundleResourcesDirectory; +{$else} + Result := ''; +{$endif} +{$endif} + +{$ifdef Windows} + Result := ExtractFilePath(Application.EXEName); +{$endif} end; function TChessConfig.GetCurrentSkinDir: string;