Using stringstream and bugfixing using c_str(). Compatible with kalinka now
This commit is contained in:
@@ -223,32 +223,34 @@ void Simulation::initLogger(void) {
|
||||
|
||||
for (int i = 0; i < numberZBins; i++)
|
||||
{
|
||||
string fileName = dirname + "/z=" + to_string(zLogValues[i]) + ".dat";
|
||||
outStream[i].open(fileName);
|
||||
stringstream fileName;
|
||||
fileName << dirname << "/z=" << zLogValues[i] << ".dat";
|
||||
outStream[i].open(fileName.str().c_str());
|
||||
}
|
||||
}
|
||||
string Simulation::getDirName() {
|
||||
string poub = getenv("poub");
|
||||
string pname = getenv("pname");
|
||||
int i = 1;
|
||||
string dirname;
|
||||
stringstream dirname;
|
||||
struct stat statbuf;
|
||||
int isDir;
|
||||
do {
|
||||
dirname = poub + "/" + pname + "_" + getTimeString() + "_" + to_string(i++);
|
||||
dirname.clear();
|
||||
dirname << poub << "/" << pname << "_" << getTimeString() << "_" << i++;
|
||||
isDir = 0;
|
||||
if (stat(dirname.c_str(), &statbuf) != -1) {
|
||||
if (stat(dirname.str().c_str(), &statbuf) != -1) {
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
isDir = 1;
|
||||
}
|
||||
}
|
||||
} while ( isDir == 1 );
|
||||
|
||||
if (mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
|
||||
cerr<<"Simulation::initLogger: Could not create folder "<<dirname.c_str()<<" for Logging."<<endl;
|
||||
if (mkdir(dirname.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
|
||||
cerr<<"Simulation::initLogger: Could not create folder "<<dirname.str()<<" for Logging."<<endl;
|
||||
exit(1);
|
||||
}
|
||||
return(dirname);
|
||||
return(dirname.str());
|
||||
}
|
||||
|
||||
string Simulation::getTimeString() {
|
||||
|
||||
Reference in New Issue
Block a user