[fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Feb 5 18:24:53 CET 2009


On 05 Feb 2009, at 17:03, Ken G. Brown wrote:

> Thx for the quick response!
> I think I'm almost there. I seem to have a bundlePath : CFURLRef;  
> but I don't quite know what to do with it. How do I convert it to  
> something I can use in a Reset() to open a file?

If you enter CFURLRef in the search box at the top right point of the  
page, the first link in the search results is http://developer.apple.com/documentation/CoreFoundation/Reference/CFBundleRef/Reference/reference.html

The Overview section notes:

***
You can also obtain locations of subdirectories in a bundle  
represented as CFURL objects. The CFBundleCopyExecutableURL function  
returns the location of the application's executable. The functions  
CFBundleCopyResourceURL, CFBundleCopySharedFrameworksURL,  
CFBundleCopyPrivateFrameworksURL,CFBundleCopySharedSupportURL, and  
CFBundleCopyBuiltInPlugInsURL return the location of a bundle's  
subdirectory containing resources, shared frameworks, private  
frameworks, shared support files, and plug-ins
***

Clicking on CFURLRef in the declarations of these functions redirects  
to http://developer.apple.com/documentation/CoreFoundation/Reference/CFURLRef/Reference/reference.html#/ 
/apple_ref/doc/c_ref/CFURLRef

On that page, under "Functions by Task" and then "Accessing the Parts  
of a URL", there is a function called CFURLCopyFileSystemPath. This  
function can return a POSIX path (kCFURLPOSIXPathStyle) in a  
CFStringRef.

Clicking on CFStringRef redirects to http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html#/ 
/apple_ref/doc/c_ref/CFStringRef

There, under "Functions by Task" and then "String File System  
Representations", there is a function called  
CFStringGetFileSystemRepresentation, which in combination with  
CFStringGetMaximumSizeOfFileSystemRepresentation can be used to obtain  
a null-terminated string containing a path that can be passed to reset  
etc.


Jonas



More information about the fpc-pascal mailing list