conftree: also use path_open() for writing instead of local eq. (no real change). Less verbosity

This commit is contained in:
Jean-Francois Dockes 2020-04-22 14:00:04 +02:00
parent 2b1553caa6
commit 8bdab8534c

View File

@ -242,8 +242,8 @@ ConfSimple::ConfSimple(const char *fname, int readonly, bool tildexp,
} }
fstream input = path_open(fname, mode); fstream input = path_open(fname, mode);
if (!input.is_open()) { if (!input.is_open()) {
LOGDEB("ConfSimple::ConfSimple: fstream(w)("<<fname<<", "<< mode << LOGDEB0("ConfSimple::ConfSimple: fstream(w)(" << fname << ", " << mode <<
") errno " << errno << "\n"); ") errno " << errno << "\n");
} }
if (!readonly && !input.is_open()) { if (!readonly && !input.is_open()) {
@ -255,8 +255,13 @@ ConfSimple::ConfSimple(const char *fname, int readonly, bool tildexp,
} }
if (!input.is_open()) { if (!input.is_open()) {
LOGERR("ConfSimple::ConfSimple: fstream("<<fname<<", "<<ios::in<< // Don't log ENOENT, this is common with some recoll config files
") errno" << errno << "\n"); string reason;
catstrerror(&reason, nullptr, errno);
if (errno != 2) {
LOGERR("ConfSimple::ConfSimple: fstream(" << fname << ", " <<
ios::in << ") " << reason << "\n");
}
status = STATUS_ERROR; status = STATUS_ERROR;
return; return;
} }
@ -578,16 +583,7 @@ bool ConfSimple::write()
return true; return true;
} }
if (m_filename.length()) { if (m_filename.length()) {
fstream output; fstream output = path_open(m_filename, ios::out | ios::trunc);
#if (defined(BUILDING_RECOLL) && defined(_MSC_VER))
// msc has support for using wide chars for opening files. We may
// need this if, e.g. the user name/home directory is not ascii
wchar_t wfname[MAX_PATH + 1];
utf8towchar(m_filename, wfname, MAX_PATH);
output = fstream(wfname, ios::out | ios::trunc);
#else
output = fstream(m_filename, ios::out | ios::trunc);
#endif
if (!output.is_open()) { if (!output.is_open()) {
return 0; return 0;
} }