6 #include <CoreFoundation/CoreFoundation.h>
8 int fileExists(char* filename)
13 if ( access(filename, R_OK) != 0 )
15 printf("Cannot find file: %s\n", filename);
21 int findBundleFile(char* exec, const char* file)
24 char* nexec = strdup(exec);
25 char* fpath = (char*)malloc(strlen(exec) + 100);
28 printf("Process executable name: %s\n", exec);
30 // Remove the executable name and directory name
31 for ( cc = strlen(nexec)-1; cc > 0; cc -- )
33 if ( nexec[cc] == '/' )
43 printf("Process executable path: %s\n", nexec);
44 sprintf(fpath, "%s/%s", nexec, file);
45 printf("Check for file: %s\n", fpath);
46 res = fileExists(fpath);
54 // Call a CoreFoundation function...
56 CFBundleRef br = CFBundleGetMainBundle();
59 int res1 = findBundleFile(exec, "Resources/randomResourceFile.plist");
60 int res2 = findBundleFile(exec, "MacOS/SomeRandomFile.txt");
61 int res3 = findBundleFile(exec, "MacOS/ChangeLog.txt");