From 8cbab9e71da7bb9a32b98094ad49e4ac13f7cdc1 Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Fri, 2 Mar 2018 16:14:45 +0100 Subject: [PATCH] Windows compatibility. --- src/Core/Utils.cxx | 5 ++--- src/Local/BatchManager_Local.cxx | 10 +++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Core/Utils.cxx b/src/Core/Utils.cxx index b7371f9..3a17dd1 100644 --- a/src/Core/Utils.cxx +++ b/src/Core/Utils.cxx @@ -119,10 +119,9 @@ string Utils::createAndOpenTemporaryFile(const string & prefix, ofstream & outpu if (tmpDirName == NULL) tmpDirName = getenv("TMPDIR"); if (tmpDirName == NULL) tmpDirName = "/tmp"; - string fileName = (string)tmpDirName + "/libbatch-" + prefix + "-XXXXXX"; - #ifdef WIN32 + string fileName = (string)tmpDirName + "\\libbatch-" + prefix + "-XXXXXX"; char randstr[7]; srand(time(NULL)); @@ -135,7 +134,7 @@ string Utils::createAndOpenTemporaryFile(const string & prefix, ofstream & outpu outputStream.open(fileName.c_str(), ios_base::binary | ios_base::out); #else - + string fileName = (string)tmpDirName + "/libbatch-" + prefix + "-XXXXXX"; char * buf = new char[fileName.size()+1]; fileName.copy(buf, fileName.size()); buf[fileName.size()] = '\0'; diff --git a/src/Local/BatchManager_Local.cxx b/src/Local/BatchManager_Local.cxx index f913ee6..c2c85e0 100644 --- a/src/Local/BatchManager_Local.cxx +++ b/src/Local/BatchManager_Local.cxx @@ -263,12 +263,16 @@ namespace Batch { fileToExecute = param[EXECUTABLE].str(); else throw RunTimeException("param[EXECUTABLE] is not defined. Please define it, cannot submit this job."); - - string::size_type p1 = fileToExecute.find_last_of("/"); +#ifdef WIN32 + const char separator = '\\'; +#else + const char separator = '/'; +#endif + string::size_type p1 = fileToExecute.find_last_of(separator); string::size_type p2 = fileToExecute.find_last_of("."); string rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); string fileNameToExecute = fileToExecute.substr(p1+1); - string remotePath = workDir + "/" + rootNameToExecute + "_launch_job"; + string remotePath = workDir + separator + rootNameToExecute + "_launch_job"; // Create batch submit file ofstream tempOutputFile; -- 2.39.2