added ifdef for non glibc (Solaris)
This commit is contained in:
@@ -8,6 +8,9 @@
|
|||||||
@license LGPL, see file <a href="license.html">COPYING</a>
|
@license LGPL, see file <a href="license.html">COPYING</a>
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.3 2005/02/28 07:29:18 marc
|
||||||
|
added ifdef for non glibc (Solaris)
|
||||||
|
|
||||||
Revision 1.2 2005/02/18 15:53:07 marc
|
Revision 1.2 2005/02/18 15:53:07 marc
|
||||||
I'm so stupid, there's strerror for mapping errno to a string...
|
I'm so stupid, there's strerror for mapping errno to a string...
|
||||||
|
|
||||||
@@ -23,15 +26,28 @@
|
|||||||
#include <mrw/string.hpp>
|
#include <mrw/string.hpp>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __GLIBC__
|
||||||
|
#include <mrw/stdext.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
mrw::Errno::Errno() throw(): _errno(errno) {}
|
mrw::Errno::Errno() throw(): _errno(errno) {}
|
||||||
|
|
||||||
mrw::Errno::operator std::string() const throw(std::bad_exception) {
|
mrw::Errno::operator std::string() const throw(std::bad_exception) {
|
||||||
|
#ifdef __GLIBC__
|
||||||
char error[1024];
|
char error[1024];
|
||||||
return strerror_r(_errno, error, 1024) ? error : std::string("errno=")+_errno;
|
return !strerror_r(_errno, error, 1024) ?
|
||||||
|
error : std::string("errno=")+_errno;
|
||||||
|
#else
|
||||||
|
return mrw::ifelse(strerror(_errno), (std::string("errno=")+_errno).c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string mrw::Errno::string() const throw(std::bad_exception) {
|
std::string mrw::Errno::string() const throw(std::bad_exception) {
|
||||||
|
#ifdef __GLIBC__
|
||||||
char error[1024];
|
char error[1024];
|
||||||
return strerror_r(_errno, error, 1024) ? error : std::string("errno=")+_errno;
|
return !strerror_r(_errno, error, 1024) ?
|
||||||
|
error : std::string("errno=")+_errno;
|
||||||
|
#else
|
||||||
|
return mrw::ifelse(strerror(_errno), (std::string("errno=")+_errno).c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user