Make global strerr() functions in llfile.cpp static member functions of LLFile.

This is the cleanest way to make them available to the rest of the
viewer as exported functions.

This change is needed for / use by AIMultiGrid.
This commit is contained in:
Aleric Inglewood
2013-11-01 00:47:47 +01:00
parent 198840f839
commit 66a43ea537
2 changed files with 10 additions and 4 deletions

View File

@@ -49,7 +49,8 @@ static std::string empty;
#if LL_WINDOWS #if LL_WINDOWS
// On Windows, use strerror_s(). // On Windows, use strerror_s().
std::string strerr(int errn) //static
std::string LLFile::strerr(int errn)
{ {
char buffer[256]; char buffer[256];
strerror_s(buffer, errn); // infers sizeof(buffer) -- love it! strerror_s(buffer, errn); // infers sizeof(buffer) -- love it!
@@ -98,7 +99,8 @@ std::string message_from(int orig_errno, const char* buffer, size_t bufflen,
<< " (error " << stre_errno << ')'); << " (error " << stre_errno << ')');
} }
std::string strerr(int errn) //static
std::string LLFile::strerr(int errn)
{ {
char buffer[256]; char buffer[256];
// Select message_from() function matching the strerror_r() we have on hand. // Select message_from() function matching the strerror_r() we have on hand.
@@ -108,7 +110,8 @@ std::string strerr(int errn)
#endif // ! LL_WINDOWS #endif // ! LL_WINDOWS
// On either system, shorthand call just infers global 'errno'. // On either system, shorthand call just infers global 'errno'.
std::string strerr() //static
std::string LLFile::strerr()
{ {
return strerr(errno); return strerr(errno);
} }
@@ -125,7 +128,7 @@ int warnif(const std::string& desc, const std::string& filename, int rc, int acc
if (errn != accept) if (errn != accept)
{ {
LL_WARNS("LLFile") << "Couldn't " << desc << " '" << filename LL_WARNS("LLFile") << "Couldn't " << desc << " '" << filename
<< "' (errno " << errn << "): " << strerr(errn) << LL_ENDL; << "' (errno " << errn << "): " << LLFile::strerr(errn) << LL_ENDL;
} }
#if 0 && LL_WINDOWS // turn on to debug file-locking problems #if 0 && LL_WINDOWS // turn on to debug file-locking problems
// If the problem is "Permission denied," maybe it's because another // If the problem is "Permission denied," maybe it's because another

View File

@@ -82,6 +82,9 @@ public:
std::ios::openmode mode); std::ios::openmode mode);
static const char * tmpdir(); static const char * tmpdir();
static std::string strerr(int errn);
static std::string strerr();
}; };
/** /**