mirror of
https://github.com/ksherlock/mpw.git
synced 2024-06-14 11:29:28 +00:00
convert error_code to macos error.
This commit is contained in:
parent
9501601d7a
commit
2c22cac0ca
|
@ -917,6 +917,27 @@ namespace MacOS {
|
||||||
return macos_error_from_errno(errno);
|
return macos_error_from_errno(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
macos_error macos_error_from_errno(const std::error_code &ec) {
|
||||||
|
if (!ec) return noErr;
|
||||||
|
|
||||||
|
// generic_category is a posix errno.
|
||||||
|
// system_category is the native error (eg posix errno or windows error)
|
||||||
|
// but will default_error_condition() to a generic_category, if possible.
|
||||||
|
|
||||||
|
if (ec.category() == std::generic_category())
|
||||||
|
return macos_error_from_errno(ec.value());
|
||||||
|
|
||||||
|
if (ec.category() == macos_system_category()) return (macos_error)ec.value();
|
||||||
|
|
||||||
|
std::error_condition econd = ec.default_error_condition();
|
||||||
|
if (econd.category() == std::generic_category())
|
||||||
|
return macos_error_from_errno(econd.value());
|
||||||
|
|
||||||
|
return ioErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
macos_error macos_error_from_errno(int error)
|
macos_error macos_error_from_errno(int error)
|
||||||
{
|
{
|
||||||
switch(error)
|
switch(error)
|
||||||
|
@ -938,7 +959,9 @@ namespace MacOS {
|
||||||
case EBUSY: return fBsyErr;
|
case EBUSY: return fBsyErr;
|
||||||
case ENOTEMPTY: return fBsyErr;
|
case ENOTEMPTY: return fBsyErr;
|
||||||
|
|
||||||
|
#ifdef EDQUOT
|
||||||
case EDQUOT: return dskFulErr;
|
case EDQUOT: return dskFulErr;
|
||||||
|
#endif
|
||||||
case ENOSPC: return dskFulErr;
|
case ENOSPC: return dskFulErr;
|
||||||
case ENOMEM: return mFulErr;
|
case ENOMEM: return mFulErr;
|
||||||
case ENFILE: return tmfoErr;
|
case ENFILE: return tmfoErr;
|
||||||
|
|
|
@ -565,6 +565,8 @@ namespace MacOS {
|
||||||
macos_error macos_error_from_errno();
|
macos_error macos_error_from_errno();
|
||||||
macos_error macos_error_from_errno(int error);
|
macos_error macos_error_from_errno(int error);
|
||||||
|
|
||||||
|
macos_error macos_error_from_errno(const std::error_code &ec);
|
||||||
|
|
||||||
// c++11 error stuff
|
// c++11 error stuff
|
||||||
const std::error_category& macos_system_category();
|
const std::error_category& macos_system_category();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user