Logdir: Change requested by 0xxon, no problem

Suggestion from 0xxon to look at Input Framework inspired this change
This commit is contained in:
Henrik Kramselund Jereminsen 2021-05-15 09:53:51 +02:00 committed by Johanna Amann
parent 6bde33aca7
commit 74561e922f
2 changed files with 11 additions and 4 deletions

View file

@ -457,10 +457,17 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const threading::Fiel
ext += gzip_file_extension.empty() ? "gz" : gzip_file_extension;
}
if ( ! logdir.empty() )
if ( fname.front() != '/' && ! logdir.empty() )
{
fname = logdir.empty() ? fname : logdir + "/" + fname;
}
string path = logdir;
std::size_t last = path.find_last_not_of('/');
if ( last == string::npos ) // Nothing but slashes -- weird but ok...
path = "/";
else
path.erase(last + 1);
fname = path + "/" + fname;
}
fname += ext;