use mpw_errno_from_errno()

This commit is contained in:
Kelvin Sherlock 2014-12-21 08:25:40 -05:00
parent 6929a374d0
commit 204332c4c9
5 changed files with 7 additions and 53 deletions

View File

@ -73,52 +73,7 @@ namespace MPW
bool Trace = false;
int errno_to_errno(int xerrno)
{
switch (xerrno)
{
case EPERM: return kEPERM;
case ENOENT: return kENOENT;
#ifdef ENORSRC
case ENORSRC: return kENORSRC;
#endif
case EINTR: return kEINTR;
case EIO: return kEIO;
case ENXIO: return kENXIO;
case E2BIG: return kE2BIG;
case ENOEXEC: return kENOEXEC;
case EBADF: return kEBADF;
case ECHILD: return kECHILD;
case EAGAIN: return kEAGAIN;
case ENOMEM: return kENOMEM;
case EACCES: return kEACCES;
case EFAULT: return kEFAULT;
case ENOTBLK: return kENOTBLK;
case EBUSY: return kEBUSY;
case EEXIST: return kEEXIST;
case EXDEV: return kEXDEV;
case ENODEV: return kENODEV;
case ENOTDIR: return kENOTDIR;
case EISDIR: return kEISDIR;
case EINVAL: return kEINVAL;
case ENFILE: return kENFILE;
case EMFILE: return kEMFILE;
case ENOTTY: return kENOTTY;
case ETXTBSY: return kETXTBSY;
case EFBIG: return kEFBIG;
case ENOSPC: return kENOSPC;
case ESPIPE: return kESPIPE;
case EROFS: return kEROFS;
case EMLINK: return kEMLINK;
case EPIPE: return kEPIPE;
case EDOM: return kEDOM;
case ERANGE: return kERANGE;
}
return kEINVAL;
}
static bool isdir(const std::string &path)
{

View File

@ -119,8 +119,6 @@ namespace MPW {
void ftrap_write(uint16_t trap);
void ftrap_ioctl(uint16_t trap);
// native errno to an MPW errno.
int errno_to_errno(int xerrno);
}
#endif

View File

@ -133,7 +133,7 @@ namespace MPW
Log(" delete(%s)\n", sname.c_str());
rv = ::unlink(sname.c_str());
if (rv < 0) return 0x40000000 | errno_to_errno(errno);
if (rv < 0) return 0x40000000 | mpw_errno_from_errno();
return 0;
}
@ -192,7 +192,7 @@ namespace MPW
if (fd < 0)
{
// return an errno.
d0 = 0x40000000 | errno_to_errno(errno);
d0 = 0x40000000 | mpw_errno_from_errno();
f.error = MacOS::ioErr;
f.cookie = 0;
}

View File

@ -26,6 +26,7 @@
#include "mpw.h"
#include "mpw_internal.h"
#include "mpw_errno.h"
#include <algorithm>
#include <memory>
@ -81,7 +82,7 @@ namespace MPW
{
//f.count = 0;
f.error = MacOS::ioErr; // ioErr
d0 = errno_to_errno(errno);
d0 = mpw_errno_from_errno();
}
else
{
@ -126,7 +127,7 @@ namespace MPW
{
//f.count = 0;
f.error = MacOS::ioErr; // ioErr
d0 = errno_to_errno(errno);
d0 = mpw_errno_from_errno();
}
else
{

View File

@ -335,7 +335,7 @@ namespace MPW
off_t rv = ::lseek(fd, offset, nativeWhence);
if (rv < 0)
{
d0 = errno_to_errno(errno);
d0 = mpw_errno_from_errno();
f.error = macos_error_from_errno();
//perror(NULL);
}
@ -376,7 +376,7 @@ namespace MPW
int ok = ftruncate(fd, arg);
if (ok == 0) return 0;
f.error = macos_error_from_errno();
return errno_to_errno(errno);
return (int)mpw_errno_from_errno();
},
[](int fd){
return kEINVAL;