summaryrefslogtreecommitdiffstats
path: root/Source/CPack/OSXScriptLauncher.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2007-01-31 18:53:30 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2007-01-31 18:53:30 (GMT)
commit4240fc1bcb57c2971ac8b5fda8c245a03faff1b3 (patch)
tree16104dd759d69c7f17da8b2fb24bd321c0e0de92 /Source/CPack/OSXScriptLauncher.cxx
parentc32af51867d1b49625eb687a12d7cb555111a338 (diff)
downloadCMake-4240fc1bcb57c2971ac8b5fda8c245a03faff1b3.zip
CMake-4240fc1bcb57c2971ac8b5fda8c245a03faff1b3.tar.gz
CMake-4240fc1bcb57c2971ac8b5fda8c245a03faff1b3.tar.bz2
COMP: Use new API
Diffstat (limited to 'Source/CPack/OSXScriptLauncher.cxx')
-rw-r--r--Source/CPack/OSXScriptLauncher.cxx50
1 files changed, 12 insertions, 38 deletions
diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx
index 7148ca6..19b1501 100644
--- a/Source/CPack/OSXScriptLauncher.cxx
+++ b/Source/CPack/OSXScriptLauncher.cxx
@@ -6,7 +6,8 @@
#include <Carbon/Carbon.h>
#include <CoreFoundation/CoreFoundation.h>
-#define MaximumPathLength 1024
+// For the PATH_MAX constant
+#include <sys/syslimits.h>
#define DebugError(x) \
ofs << x << cmsys_ios::endl; \
@@ -21,8 +22,6 @@ int main(int argc, char* argv[])
CFStringRef fileName;
CFBundleRef appBundle;
CFURLRef scriptFileURL;
- FSRef fileRef;
- FSSpec fileSpec;
UInt8 *path;
//get CF URL for script
@@ -31,12 +30,7 @@ int main(int argc, char* argv[])
DebugError("Cannot get main bundle");
return 1;
}
- if (! (fileName = CFStringCreateWithCString(NULL, "RuntimeScript",
- kCFStringEncodingASCII)))
- {
- DebugError("CFStringCreateWithCString failed");
- return 1;
- }
+ fileName = CFSTR("RuntimeScript");
if (! (scriptFileURL = CFBundleCopyResourceURL(appBundle, fileName, NULL,
NULL)))
{
@@ -44,44 +38,24 @@ int main(int argc, char* argv[])
return 1;
}
- //Get file reference from Core Foundation URL
- if (! CFURLGetFSRef(scriptFileURL, &fileRef))
- {
- DebugError("CFURLGetFSRef failed");
- return 1;
- }
-
- //dispose of the CF variables
- CFRelease(scriptFileURL);
- CFRelease(fileName);
-
- //convert FSRef to FSSpec
- if (FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec,
- NULL))
+ //create path string
+ if (! (path = new UInt8[PATH_MAX]))
{
- DebugError("FSGetCatalogInfo failed");
return 1;
}
- //create path string
- if (! (path = new UInt8[MaximumPathLength]))
+ //get the file system path of the url as a cstring
+ //in an encoding suitable for posix apis
+ if ( CFURLGetFileSystemRepresentation(scriptFileURL, true, path,
+ PATH_MAX) == false)
{
+ DebugError("CFURLGetFileSystemRepresentation failed");
return 1;
}
- //create file reference from file spec
- OSErr err = FSpMakeFSRef(&fileSpec, &fileRef);
- if(err)
- {
- return err;
- }
+ //dispose of the CF variable
+ CFRelease(scriptFileURL);
- // and then convert the FSRef to a path
- if ( FSRefMakePath(&fileRef, path, MaximumPathLength) )
- {
- DebugError("FSRefMakePath failed");
- return 1;
- }
cmsys_stl::string fullScriptPath = reinterpret_cast<char*>(path);
delete [] path;