Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
At 4:05 PM + 2/6/09, Frank Peelo apparently wrote: >Ken G. Brown wrote: >>Basically from point of sale system running on Macintosh, I needed >>to pick up a file with a known name located in the same folder as >>the application bundle, and process it for printing in a custom >>format. This way it does not need the file path hard coded in case >>it is different on the different computers. > >But, does what Jonas said not apply here? Is the Mac a multi-user machine now? >Even Windows has different users, hence c:\Documents and Settings\ > >If the Mac has different users, maybe the file to be printed/processed should >go in the user's home directory? If the machine is to be used as a single POS >terminal, then a standard location for the file might be appropriate (does the >Mac have an equivalent to the Filesystem Hierarchy Standard in Linux?) The POS computer is always automatically booted into a single user that is always the same but not necessarily the same user on a different terminal. The information from the POS software for a custom invoice print format is presented in a file in the current folder of the POS software, I don't think there is a setting to control that but I'll look. So easiest for me right now is to put the custom print format output program there too, then the program works wherever the POS software is. Thx, Ken >I don't know the Mac, or your app, so this is probably all wrong, or >inappropriate for you -- but I thought it worth mentioning because when I >started using Linux it was not at all obvious to me that what Jonas described >(the Unixy way of doing things) could work instead of the Windows way of >putting files in the same directory as the .exe file. But, surprisingly, it >does work quite well :) > >Frank > >___ >fpc-pascal maillist - fpc-pascal@lists.freepascal.org >http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
On 06 Feb 2009, at 17:05, Frank Peelo wrote: Ken G. Brown wrote: Basically from point of sale system running on Macintosh, I needed to pick up a file with a known name located in the same folder as the application bundle, and process it for printing in a custom format. This way it does not need the file path hard coded in case it is different on the different computers. But, does what Jonas said not apply here? No, because he's using a bundled application and not a command line app. In that case, conventions (and user expectations) are different. Is the Mac a multi-user machine now? Mac OS X Server 1.0 was released in 1999, and Mac OS X (client) 10.0 in 2001 on the desktop side (actually, even System 9 already had the concept of multiple users, but I don't remember anymore when it was released). But that's not really relevant here. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
Ken G. Brown wrote: Basically from point of sale system running on Macintosh, I needed to pick up a file with a known name located in the same folder as the application bundle, and process it for printing in a custom format. This way it does not need the file path hard coded in case it is different on the different computers. But, does what Jonas said not apply here? Is the Mac a multi-user machine now? Even Windows has different users, hence c:\Documents and Settings\ If the Mac has different users, maybe the file to be printed/processed should go in the user's home directory? If the machine is to be used as a single POS terminal, then a standard location for the file might be appropriate (does the Mac have an equivalent to the Filesystem Hierarchy Standard in Linux?) I don't know the Mac, or your app, so this is probably all wrong, or inappropriate for you -- but I thought it worth mentioning because when I started using Linux it was not at all obvious to me that what Jonas described (the Unixy way of doing things) could work instead of the Windows way of putting files in the same directory as the .exe file. But, surprisingly, it does work quite well :) Frank ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
Basically from point of sale system running on Macintosh, I needed to pick up a file with a known name located in the same folder as the application bundle, and process it for printing in a custom format. This way it does not need the file path hard coded in case it is different on the different computers. All that is required os for the Prin.app to be located in the same folder as the file. There are certainly other options. Here is what I ended up with that is working, I'm open to suggestions for improvement: -- var indexOfBundleNameStart : SInt32 = 0; success : boolean = false; mainBundle : CFBundleRef; bundlePath : CFURLRef; bundlePathStr : CFStringRef; myBundlePathStr : pchar; pathToPrintApp : Str255 = ''; const printAppName : Str255 = 'Print.app'; begin // Get the main bundle for the app mainBundle := CFBundleGetMainBundle(); bundlePath := CFBundleCopyBundleURL(mainBundle); bundlePathStr := CFURLCopyFileSystemPath (bundlePath, kCFURLPOSIXPathStyle); myBundlePathStr := getmem(CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); success := CFStringGetFileSystemRepresentation (bundlePathStr, myBundlePathStr, CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); if (success = true) then {get rid of 'Print.app' at the end of the path} begin pathToPrintApp := copy(myBundlePathStr, 1, Length(myBundlePathStr)); indexOfBundleNameStart := Pos(printAppName, pathToPrintApp); delete(pathToPrintApp, indexOFBundleNameStart, Length(printAppName)); end; // Writeln(stdout, myBundlePathStr); // Writeln(stdout, 'Path to the app folder = ' + pathToPrintApp); -- You would do something similar to pick up the paths to the other files of interest within the app bundle package using whatever other routines necessary as Jonas indicated. Ken G. Brown At 7:25 AM -0600 2/6/09, Travis Siegel apparently wrote: >So, as someone who only uses terminal apps written in fpc ( since ibuilder >isn't really that usable and writing interface generating code is still beyond >me despit trying for 4 years) Could you please post a copy of a code segment >that shows how you performed this little marvel of finding files inside the >app bundle? I've been trying (unsuccessfully) to imitate compiled programs by >running interpreters on files located inside an app bundle. Thus far, I've >had little success, but if you've gotten this working, then it's exactly what >I was trying to do, and I sure could use your hard work. :-). > > >On Feb 5, 2009, at 9:05 PM, Ken G. Brown wrote: > >>Thanks a bunch for all the help! >>My legacy OS 9 app is now upgraded to OS X and working! >>It put up a hell of a fight but with all your help, the obstacles have been >>overcome. >>Awesome! >> >>Ken G. Brown >> >>At 9:51 PM +0100 2/5/09, Jonas Maebe apparently wrote: >>><> >>>You have to allocate memory for it. Something like >>> >>>myBundlePathStr:=getmem(CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); >>>success := CFStringGetFileSystemRepresentation (bundlePathStr, >>>myBundlePathStr, >>>CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); >>> >>>When interfacing with C routines, you have to do the same things as if you >>>were using C. >>> And I notice that CFStringGetFileSystemRepresentation is only available for 10.4 and newer. What do i need to do instead if wanting to deploy to 10.3.9? >>> >>>Call CFStringGetCStringPtr and/or CFStringGetCStringPtr and tell it to >>>convert to utf-8 (kCFStringEncodingUTF8). >>> >>> >>>Jonas >>>___ >>>fpc-pascal maillist - fpc-pascal@lists.freepascal.org >>>http://lists.freepascal.org/mailman/listinfo/fpc-pascal >> >>___ >>fpc-pascal maillist - fpc-pascal@lists.freepascal.org >>http://lists.freepascal.org/mailman/listinfo/fpc-pascal > >___ >fpc-pascal maillist - fpc-pascal@lists.freepascal.org >http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
So, as someone who only uses terminal apps written in fpc ( since ibuilder isn't really that usable and writing interface generating code is still beyond me despit trying for 4 years) Could you please post a copy of a code segment that shows how you performed this little marvel of finding files inside the app bundle? I've been trying (unsuccessfully) to imitate compiled programs by running interpreters on files located inside an app bundle. Thus far, I've had little success, but if you've gotten this working, then it's exactly what I was trying to do, and I sure could use your hard work. :-). On Feb 5, 2009, at 9:05 PM, Ken G. Brown wrote: Thanks a bunch for all the help! My legacy OS 9 app is now upgraded to OS X and working! It put up a hell of a fight but with all your help, the obstacles have been overcome. Awesome! Ken G. Brown At 9:51 PM +0100 2/5/09, Jonas Maebe apparently wrote: <> You have to allocate memory for it. Something like myBundlePathStr := getmem (CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); success := CFStringGetFileSystemRepresentation (bundlePathStr, myBundlePathStr, CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); When interfacing with C routines, you have to do the same things as if you were using C. And I notice that CFStringGetFileSystemRepresentation is only available for 10.4 and newer. What do i need to do instead if wanting to deploy to 10.3.9? Call CFStringGetCStringPtr and/or CFStringGetCStringPtr and tell it to convert to utf-8 (kCFStringEncodingUTF8). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
Thanks a bunch for all the help! My legacy OS 9 app is now upgraded to OS X and working! It put up a hell of a fight but with all your help, the obstacles have been overcome. Awesome! Ken G. Brown At 9:51 PM +0100 2/5/09, Jonas Maebe apparently wrote: ><> >You have to allocate memory for it. Something like > >myBundlePathStr:=getmem(CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); >success := CFStringGetFileSystemRepresentation (bundlePathStr, >myBundlePathStr, >CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); > >When interfacing with C routines, you have to do the same things as if you >were using C. > >>And I notice that CFStringGetFileSystemRepresentation is only available for >>10.4 and newer. What do i need to do instead if wanting to deploy to 10.3.9? > >Call CFStringGetCStringPtr and/or CFStringGetCStringPtr and tell it to convert >to utf-8 (kCFStringEncodingUTF8). > > >Jonas >___ >fpc-pascal maillist - fpc-pascal@lists.freepascal.org >http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
At 9:51 PM +0100 2/5/09, Jonas Maebe apparently wrote: >On 05 Feb 2009, at 21:29, Ken G. Brown wrote: > >>So far I have the following external definitions: > >All external definitions you need are already in the MacOSAll unit shipped >with FPC. > >>Function CFStringGetFileSystemRepresentation(myPathString : CFStringRef; >>buffer : ppchar; maxBufLen : CFIndex) : Boolean; cdecl; External; >>Function _CFStringGetFileSystemRepresentation(myPathString : CFStringRef; >>buffer : ppchar; maxBufLen : CFIndex) : Boolean; C; External; >> >>Function CFStringGetMaximumSizeOfFileSystemRepresentation(myPathStr2 : >>CFStringRef) : CFIndex; cdecl; External; >>Function _CFStringGetMaximumSizeOfFileSystemRepresentation(myPathStr2 : >>CFStringRef) : CFIndex; C; External; >> >>Function CFBundleGetMainBundle() : CFBundleRef; cdecl; External; >>Function _CFBundleGetMainBundle() : CFBundleRef; C; External; > >The ones with the extra underscore don't exist. > >>and the following snippet >> >>var >> success : boolean = false; >> mainBundle : CFBundleRef; >> bundlePath : CFURLRef; >> bundlePathStr : CFStringRef; >> myBundlePathStr : ppchar; > >myBundlePathStr has to be a pchar; > >>begin >> >> >>// Get the main bundle for the app >> mainBundle := CFBundleGetMainBundle(); >> bundlePath := CFBundleCopyBundleURL(mainBundle); >> >> bundlePathStr := CFURLCopyFileSystemPath (bundlePath, >> kCFURLPOSIXPathStyle); >> >> >>success := CFStringGetFileSystemRepresentation (bundlePathStr, >>myBundlePathStr, >>CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); >> >>I'm not quite sure if I am doing the 2nd arg correctly, it's supposed to be >>char *buffer. >> >>Does this look alright? If not, what should I be using for the >>myBundlePathString type? > >You have to allocate memory for it. Something like > >myBundlePathStr:=getmem(CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); >success := CFStringGetFileSystemRepresentation (bundlePathStr, >myBundlePathStr, >CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); Ah! Sweet! I'm getting the path! Now all that's left is to get the path without the app name and add my filename! :) Thank you Sir! Ken >When interfacing with C routines, you have to do the same things as if you >were using C. > >>And I notice that CFStringGetFileSystemRepresentation is only available for >>10.4 and newer. What do i need to do instead if wanting to deploy to 10.3.9? > >Call CFStringGetCStringPtr and/or CFStringGetCStringPtr and tell it to convert >to utf-8 (kCFStringEncodingUTF8). > > >Jonas >___ >fpc-pascal maillist - fpc-pascal@lists.freepascal.org >http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
On 05 Feb 2009, at 21:29, Ken G. Brown wrote: So far I have the following external definitions: All external definitions you need are already in the MacOSAll unit shipped with FPC. Function CFStringGetFileSystemRepresentation(myPathString : CFStringRef; buffer : ppchar; maxBufLen : CFIndex) : Boolean; cdecl; External; Function _CFStringGetFileSystemRepresentation(myPathString : CFStringRef; buffer : ppchar; maxBufLen : CFIndex) : Boolean; C; External; Function CFStringGetMaximumSizeOfFileSystemRepresentation(myPathStr2 : CFStringRef) : CFIndex; cdecl; External; Function _CFStringGetMaximumSizeOfFileSystemRepresentation(myPathStr2 : CFStringRef) : CFIndex; C; External; Function CFBundleGetMainBundle() : CFBundleRef; cdecl; External; Function _CFBundleGetMainBundle() : CFBundleRef; C; External; The ones with the extra underscore don't exist. and the following snippet var success : boolean = false; mainBundle : CFBundleRef; bundlePath : CFURLRef; bundlePathStr : CFStringRef; myBundlePathStr : ppchar; myBundlePathStr has to be a pchar; begin // Get the main bundle for the app mainBundle := CFBundleGetMainBundle(); bundlePath := CFBundleCopyBundleURL(mainBundle); bundlePathStr := CFURLCopyFileSystemPath (bundlePath, kCFURLPOSIXPathStyle); success := CFStringGetFileSystemRepresentation (bundlePathStr, myBundlePathStr, CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); I'm not quite sure if I am doing the 2nd arg correctly, it's supposed to be char *buffer. Does this look alright? If not, what should I be using for the myBundlePathString type? You have to allocate memory for it. Something like myBundlePathStr := getmem(CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); success := CFStringGetFileSystemRepresentation (bundlePathStr, myBundlePathStr, CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); When interfacing with C routines, you have to do the same things as if you were using C. And I notice that CFStringGetFileSystemRepresentation is only available for 10.4 and newer. What do i need to do instead if wanting to deploy to 10.3.9? Call CFStringGetCStringPtr and/or CFStringGetCStringPtr and tell it to convert to utf-8 (kCFStringEncodingUTF8). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
So far I have the following external definitions: Function CFStringGetFileSystemRepresentation(myPathString : CFStringRef; buffer : ppchar; maxBufLen : CFIndex) : Boolean; cdecl; External; Function _CFStringGetFileSystemRepresentation(myPathString : CFStringRef; buffer : ppchar; maxBufLen : CFIndex) : Boolean; C; External; Function CFStringGetMaximumSizeOfFileSystemRepresentation(myPathStr2 : CFStringRef) : CFIndex; cdecl; External; Function _CFStringGetMaximumSizeOfFileSystemRepresentation(myPathStr2 : CFStringRef) : CFIndex; C; External; Function CFBundleGetMainBundle() : CFBundleRef; cdecl; External; Function _CFBundleGetMainBundle() : CFBundleRef; C; External; and the following snippet var success : boolean = false; mainBundle : CFBundleRef; bundlePath : CFURLRef; bundlePathStr : CFStringRef; myBundlePathStr : ppchar; begin // Get the main bundle for the app mainBundle := CFBundleGetMainBundle(); bundlePath := CFBundleCopyBundleURL(mainBundle); bundlePathStr := CFURLCopyFileSystemPath (bundlePath, kCFURLPOSIXPathStyle); success := CFStringGetFileSystemRepresentation (bundlePathStr, myBundlePathStr, CFStringGetMaximumSizeOfFileSystemRepresentation(bundlePathStr)); I'm not quite sure if I am doing the 2nd arg correctly, it's supposed to be char *buffer. Does this look alright? If not, what should I be using for the myBundlePathString type? And I notice that CFStringGetFileSystemRepresentation is only available for 10.4 and newer. What do i need to do instead if wanting to deploy to 10.3.9? Thx again for all the help, sooo close! Ken G. Brown At 6:24 PM +0100 2/5/09, Jonas Maebe apparently wrote: >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 >___ >fpc-pascal maillist - fpc-pascal@lists.freepascal.org >http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
Whew! Thx! I was part way through all that but wasn't sure what I could pass to reset(); Digging through it now. I haven't dealt with this stuff before. Ken At 6:24 PM +0100 2/5/09, Jonas Maebe apparently wrote: >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 >___ >fpc-pascal maillist - fpc-pascal@lists.freepascal.org >http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
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 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
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? Thx, Ken G. Brown At 10:29 AM +0100 2/5/09, Jonas Maebe apparently wrote: >On 05 Feb 2009, at 08:54, Ken G. Brown wrote: > >>How can I find the directory path to the executable of the currently >>executing program from within the program? >> >>Or alternately, how can I specify the relative path to a file that is located >>in the same folder as the application bundle for my currently executing >>program? >> >>Using ./filename does not appear to work for me. >> >>Are there file and directory type utilities available? Where can I read up on >>them? > >http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/CFBundles.html > >E.g., >http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/Tasks/locating.html#//apple_ref/doc/uid/20001123-123785 > > >Jonas >___ >fpc-pascal maillist - fpc-pascal@lists.freepascal.org >http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
On 05 Feb 2009, at 08:54, Ken G. Brown wrote: How can I find the directory path to the executable of the currently executing program from within the program? Or alternately, how can I specify the relative path to a file that is located in the same folder as the application bundle for my currently executing program? Using ./filename does not appear to work for me. Are there file and directory type utilities available? Where can I read up on them? http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/CFBundles.html E.g., http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/Tasks/locating.html#/ /apple_ref/doc/uid/20001123-123785 Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] specifying the relative path to a file that is located in the same folder as the application bundle?
MacOS X, 10.5.6, fpc 2.2.2 How can I find the directory path to the executable of the currently executing program from within the program? Or alternately, how can I specify the relative path to a file that is located in the same folder as the application bundle for my currently executing program? Using ./filename does not appear to work for me. Are there file and directory type utilities available? Where can I read up on them? Thx for any tips, Ken G. Brown ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal