Logo Search packages:      
Sourcecode: pwlib version File versions

BOOL PChannel::ConvertOSError ( int  libcReturnValue,
Errors lastError,
int &  osError 
) [static, inherited]

Convert an operating system error into platform independent error. This will set the lastError and osError member variables for access by GetErrorCode() and GetErrorNumber().

Returns:
TRUE if there was no error.

Definition at line 1093 of file win32.cxx.

References PChannel::AccessDenied, PChannel::BadParameter, PChannel::BufferTooSmall, PChannel::DiskFull, PChannel::FileExists, PChannel::Interrupted, PChannel::Miscellaneous, PChannel::NoMemory, PChannel::NotFound, PChannel::NotOpen, and PChannel::Timeout.

Referenced by PFile::Access(), PIPSocket::Connect(), PChannel::ConvertOSError(), PFile::Copy(), PPipeChannel::Execute(), PFile::GetInfo(), PIPXSocket::GetLocalAddress(), PIPSocket::GetLocalAddress(), PSocket::GetOption(), PIPXSocket::GetPacketType(), PIPXSocket::GetPeerAddress(), PIPSocket::GetPeerAddress(), PPipeChannel::Kill(), PSPXSocket::Listen(), PIPXSocket::Listen(), PIPSocket::Listen(), PFile::Open(), PTCPSocket::Read(), PEthSocket::Read(), PPipeChannel::Read(), PPipeChannel::ReadStandardError(), PFile::Remove(), PSocket::Select(), PFile::SetLength(), PSocket::SetOption(), PIPXSocket::SetPacketType(), PFile::SetPermissions(), PSocket::Shutdown(), PPipeChannel::WaitForTermination(), PEthSocket::Write(), and PPipeChannel::Write().

{
  if (status >= 0) {
    lastError = NoError;
    osError = 0;
    return TRUE;
  }

  if (status != -2)
    osError = errno;
  else {
    osError = GetLastError();
    switch (osError) {
      case ERROR_INVALID_HANDLE :
      case WSAEBADF :
        osError = EBADF;
        break;
      case ERROR_INVALID_PARAMETER :
      case WSAEINVAL :
        osError = EINVAL;
        break;
      case ERROR_ACCESS_DENIED :
      case WSAEACCES :
        osError = EACCES;
        break;
      case ERROR_NOT_ENOUGH_MEMORY :
        osError = ENOMEM;
        break;
      case WSAEINTR :
        osError = EINTR;
        break;
      case WSAEMSGSIZE :
        osError |= PWIN32ErrorFlag;
        lastError = BufferTooSmall;
        return FALSE;
      case WSAEWOULDBLOCK :
      case WSAETIMEDOUT :
        osError |= PWIN32ErrorFlag;
        lastError = Timeout;
        return FALSE;
      default :
        osError |= PWIN32ErrorFlag;
    }
  }

  switch (osError) {
    case 0 :
      lastError = NoError;
      return TRUE;
    case ENOENT :
      lastError = NotFound;
      break;
    case EEXIST :
      lastError = FileExists;
      break;
    case EACCES :
      lastError = AccessDenied;
      break;
    case ENOMEM :
      lastError = NoMemory;
      break;
    case ENOSPC :
      lastError = DiskFull;
      break;
    case EINVAL :
      lastError = BadParameter;
      break;
    case EBADF :
      lastError = NotOpen;
      break;
    case EAGAIN :
      lastError = Timeout;
      break;
    case EINTR :
      lastError = Interrupted;
      break;
    default :
      lastError = Miscellaneous;
  }

  return FALSE;
}


Generated by  Doxygen 1.6.0   Back to index