diff --git a/mpw/mpw.cpp b/mpw/mpw.cpp index 7670252..7b3cbdc 100644 --- a/mpw/mpw.cpp +++ b/mpw/mpw.cpp @@ -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) { diff --git a/mpw/mpw.h b/mpw/mpw.h index 94b0a6d..742765a 100644 --- a/mpw/mpw.h +++ b/mpw/mpw.h @@ -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 \ No newline at end of file diff --git a/mpw/mpw_access.cpp b/mpw/mpw_access.cpp index f5a8f60..b7de0c2 100644 --- a/mpw/mpw_access.cpp +++ b/mpw/mpw_access.cpp @@ -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; } diff --git a/mpw/mpw_io.cpp b/mpw/mpw_io.cpp index 1b5d00b..e48df99 100644 --- a/mpw/mpw_io.cpp +++ b/mpw/mpw_io.cpp @@ -26,6 +26,7 @@ #include "mpw.h" #include "mpw_internal.h" +#include "mpw_errno.h" #include #include @@ -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 { diff --git a/mpw/mpw_ioctl.cpp b/mpw/mpw_ioctl.cpp index ac13fe6..19ee9e6 100644 --- a/mpw/mpw_ioctl.cpp +++ b/mpw/mpw_ioctl.cpp @@ -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;