-// Copyright (C) 2009-2017 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2009-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//#define _DEBUG_
#include "Launcher_Job.hxx"
#include "Launcher.hxx"
+
+#include <Basics_DirUtils.hxx>
+
#include <boost/filesystem.hpp>
#ifdef WITH_LIBBATCH
#endif
#include <sstream>
+#ifdef WIN32
+ static const char SEPARATOR = '\\';
+#include <process.h>
+#else
+ static const char SEPARATOR = '/';
+#endif
Launcher::Job::Job()
{
std::string user_name = "";
if (resource_definition.UserName == "")
{
+#ifndef WIN32
user_name = getenv("USER");
+#else
+ user_name = getenv("USERNAME");
+#endif
if (user_name == "")
user_name = getenv("LOGNAME");
if (user_name == "")
}
_job_file = job_file;
- std::string::size_type p1 = _job_file.find_last_of("/");
+ std::string::size_type p1 = _job_file.find_last_of(SEPARATOR);
std::string::size_type p2 = _job_file.find_last_of(".");
_job_file_name_complete = _job_file.substr(p1+1);
_job_file_name = _job_file.substr(p1+1,p2-p1-1);
params[Batch::NAME] = getJobName();
params[Batch::NBPROC] = _resource_required_params.nb_proc;
- params[Batch::NBPROCPERNODE] = _resource_required_params.nb_proc_per_node;
+ if(_resource_required_params.nb_proc_per_node > 0)
+ params[Batch::NBPROCPERNODE] = _resource_required_params.nb_proc_per_node;
if(_resource_required_params.nb_node > 0)
params[Batch::NBNODE] = _resource_required_params.nb_node;
{
std::string date_dir = std::string("/job_") + date;
std::ostringstream str_pid;
+#ifdef WIN32
+ str_pid << _getpid();
+#else
str_pid << ::getpid();
+#endif
std::string job_dir = date_dir + "-" + str_pid.str();
_work_directory = _resource_definition.working_directory + job_dir;
}
else
{
+#ifndef WIN32
_work_directory = std::string("/$HOME/Batch/workdir_");
+#else
+ _work_directory = std::string("%USERPROFILE%\\Batch\\workdir_");
+#endif
_work_directory += date;
}
}
params[Batch::LAUNCHER_FILE] = _launcher_file;
params[Batch::LAUNCHER_ARGS] = _launcher_args;
- // If result_directory is not defined, we use HOME environnement
+ // If result_directory is not defined, we use HOME environment
if (_result_directory == "")
- _result_directory = getenv("HOME");
+ _result_directory = Kernel_Utils::HomePath();
// _in_files
std::list<std::string> in_files(_in_files);
// local file -> If file is not an absolute path, we apply _local_directory
std::string local_file;
+#ifndef WIN32
if (file.substr(0, 1) == std::string("/"))
+#else
+ // On Windows, absolute paths may begin with something like "C:"
+ if (file.substr(1, 1) == std::string(":"))
+#endif
local_file = file;
else if (file.substr(0, 1) == std::string("-")) // using rsync options
local_file = file;
// /a/b/./c/f -> _working_directory/c/f
local_file = _local_directory + "/./" + file;
#else
- local_file = file;
+ local_file = _local_directory + SEPARATOR + file;
#endif
// remote file -> get only file name from in_files