Renamed path_open() -> path_streamopen()
This commit is contained in:
@@ -235,7 +235,7 @@ ConfSimple::ConfSimple(const char *fname, int readonly, bool tildexp,
|
||||
mode |= ios::trunc;
|
||||
}
|
||||
fstream input;
|
||||
path_open(fname, mode, input);
|
||||
path_streamopen(fname, mode, input);
|
||||
if (!input.is_open()) {
|
||||
LOGDEB0("ConfSimple::ConfSimple: fstream(w)(" << fname << ", " << mode <<
|
||||
") errno " << errno << "\n");
|
||||
@@ -246,7 +246,7 @@ ConfSimple::ConfSimple(const char *fname, int readonly, bool tildexp,
|
||||
input.clear();
|
||||
status = STATUS_RO;
|
||||
// open readonly
|
||||
path_open(fname, ios::in, input);
|
||||
path_streamopen(fname, ios::in, input);
|
||||
}
|
||||
|
||||
if (!input.is_open()) {
|
||||
@@ -579,7 +579,7 @@ bool ConfSimple::write()
|
||||
}
|
||||
if (m_filename.length()) {
|
||||
fstream output;
|
||||
path_open(m_filename, ios::out | ios::trunc, output);
|
||||
path_streamopen(m_filename, ios::out | ios::trunc, output);
|
||||
if (!output.is_open()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+5
-28
@@ -879,29 +879,7 @@ bool path_rmdir(const std::string& path)
|
||||
return RMDIR(syspath) == 0;
|
||||
}
|
||||
|
||||
#if !defined(__GNUC__) || __GNUC__ > 4 || defined(__clang__)
|
||||
// Not sure what g++ version supports fstream assignment but 4.9
|
||||
// (jessie) certainly does not
|
||||
std::fstream path_open(const std::string& path, int mode)
|
||||
{
|
||||
#if defined(_WIN32) && defined (_MSC_VER)
|
||||
// MSC STL has support for using wide chars in fstream
|
||||
// constructor. We need this if, e.g. the user name/home directory
|
||||
// is not ASCII. Actually don't know how to do this with gcc
|
||||
wchar_t wpath[MAX_PATH + 1];
|
||||
utf8towchar(path, wpath, MAX_PATH);
|
||||
std::fstream ret(wpath, std::ios_base::openmode(mode));
|
||||
if (!ret.is_open()) {
|
||||
LOGERR("path_open("<< path << ", "<< mode <<") errno " << errno <<"\n");
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
return std::fstream(path, std::ios_base::openmode(mode));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
bool path_open(const std::string& path, int mode, std::fstream& outstream)
|
||||
bool path_streamopen(const std::string& path, int mode, std::fstream& outstream)
|
||||
{
|
||||
#if defined(_WIN32) && defined (_MSC_VER)
|
||||
// MSC STL has support for using wide chars in fstream
|
||||
@@ -910,15 +888,14 @@ bool path_open(const std::string& path, int mode, std::fstream& outstream)
|
||||
wchar_t wpath[MAX_PATH + 1];
|
||||
utf8towchar(path, wpath, MAX_PATH);
|
||||
outstream.open(wpath, std::ios_base::openmode(mode));
|
||||
#else
|
||||
outstream.open(path, std::ios_base::openmode(mode));
|
||||
#endif
|
||||
if (!outstream.is_open()) {
|
||||
LOGERR("path_open("<< path << ", "<< mode <<") errno " << errno <<"\n");
|
||||
LOGERR("path_streamopen("<<path<< ", "<<mode<<") errno "<<errno<<"\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
outstream.open(path, std::ios_base::openmode(mode));
|
||||
return outstream.is_open();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool path_isdir(const string& path, bool follow)
|
||||
|
||||
+1
-2
@@ -181,8 +181,7 @@ bool path_rmdir(const std::string& path);
|
||||
*
|
||||
* @param path an utf-8 file path.
|
||||
* @param mode is an std::fstream mode (ios::in etc.) */
|
||||
extern std::fstream path_open(const std::string& path, int mode);
|
||||
extern bool path_open(
|
||||
extern bool path_streamopen(
|
||||
const std::string& path, int mode, std::fstream& outstream);
|
||||
|
||||
/// Encode according to rfc 1738
|
||||
|
||||
@@ -491,7 +491,7 @@ TempFile::Internal::Internal(const string& suffix)
|
||||
}
|
||||
m_filename += suffix;
|
||||
std::fstream fout;
|
||||
if (!path_open(m_filename, ios::out|ios::trunc, fout)) {
|
||||
if (!path_streamopen(m_filename, ios::out|ios::trunc, fout)) {
|
||||
m_reason = string("Open/create error. errno : ") +
|
||||
lltodecstr(errno) + " file name: " + m_filename;
|
||||
LOGSYSERR("Tempfile::Internal::Internal", "open/create", m_filename);
|
||||
|
||||
Reference in New Issue
Block a user