summaryrefslogtreecommitdiff
path: root/Source/CPack/OSXScriptLauncher.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CPack/OSXScriptLauncher.cxx')
-rw-r--r--Source/CPack/OSXScriptLauncher.cxx92
1 files changed, 37 insertions, 55 deletions
diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx
index b3ddeee356..19204a207a 100644
--- a/Source/CPack/OSXScriptLauncher.cxx
+++ b/Source/CPack/OSXScriptLauncher.cxx
@@ -20,72 +20,65 @@
// For the PATH_MAX constant
#include <sys/syslimits.h>
-#define DebugError(x) \
- ofs << x << std::endl; \
+#define DebugError(x) \
+ ofs << x << std::endl; \
std::cout << x << std::endl
int main(int argc, char* argv[])
{
- //if ( cmsys::SystemTools::FileExists(
+ // if ( cmsys::SystemTools::FileExists(
std::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory();
cmsys::ofstream ofs("/tmp/output.txt");
CFStringRef fileName;
CFBundleRef appBundle;
CFURLRef scriptFileURL;
- UInt8 *path;
+ UInt8* path;
- //get CF URL for script
- if (! (appBundle = CFBundleGetMainBundle()))
- {
+ // get CF URL for script
+ if (!(appBundle = CFBundleGetMainBundle())) {
DebugError("Cannot get main bundle");
return 1;
- }
+ }
fileName = CFSTR("RuntimeScript");
- if (! (scriptFileURL = CFBundleCopyResourceURL(appBundle, fileName, NULL,
- NULL)))
- {
+ if (!(scriptFileURL =
+ CFBundleCopyResourceURL(appBundle, fileName, NULL, NULL))) {
DebugError("CFBundleCopyResourceURL failed");
return 1;
- }
+ }
- //create path string
- if (! (path = new UInt8[PATH_MAX]))
- {
+ // create path string
+ if (!(path = new UInt8[PATH_MAX])) {
return 1;
- }
+ }
- //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)
- {
+ // 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;
- }
+ }
- //dispose of the CF variable
+ // dispose of the CF variable
CFRelease(scriptFileURL);
std::string fullScriptPath = reinterpret_cast<char*>(path);
- delete [] path;
+ delete[] path;
-
- if (! cmsys::SystemTools::FileExists(fullScriptPath.c_str()))
- {
+ if (!cmsys::SystemTools::FileExists(fullScriptPath.c_str())) {
return 1;
- }
+ }
- std::string scriptDirectory = cmsys::SystemTools::GetFilenamePath(
- fullScriptPath);
+ std::string scriptDirectory =
+ cmsys::SystemTools::GetFilenamePath(fullScriptPath);
ofs << fullScriptPath.c_str() << std::endl;
std::vector<const char*> args;
args.push_back(fullScriptPath.c_str());
int cc;
- for ( cc = 1; cc < argc; ++ cc )
- {
+ for (cc = 1; cc < argc; ++cc) {
args.push_back(argv[cc]);
- }
+ }
args.push_back(0);
cmsysProcess* cp = cmsysProcess_New();
@@ -98,49 +91,38 @@ int main(int argc, char* argv[])
std::vector<char> tempOutput;
char* data;
int length;
- while(cmsysProcess_WaitForData(cp, &data, &length, 0))
- {
+ while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
// Translate NULL characters in the output into valid text.
// Visual Studio 7 puts these characters in the output of its
// build process.
- for(int i=0; i < length; ++i)
- {
- if(data[i] == '\0')
- {
+ for (int i = 0; i < length; ++i) {
+ if (data[i] == '\0') {
data[i] = ' ';
- }
}
- std::cout.write(data, length);
}
+ std::cout.write(data, length);
+ }
cmsysProcess_WaitForExit(cp, 0);
bool result = true;
- if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited)
- {
- if ( cmsysProcess_GetExitValue(cp) != 0 )
- {
+ if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
+ if (cmsysProcess_GetExitValue(cp) != 0) {
result = false;
- }
}
- else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception)
- {
+ } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exception) {
const char* exception_str = cmsysProcess_GetExceptionString(cp);
std::cerr << exception_str << std::endl;
result = false;
- }
- else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
- {
+ } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
const char* error_str = cmsysProcess_GetErrorString(cp);
std::cerr << error_str << std::endl;
result = false;
- }
- else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired)
- {
+ } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) {
const char* error_str = "Process terminated due to timeout\n";
std::cerr << error_str << std::endl;
result = false;
- }
+ }
cmsysProcess_Delete(cp);