mirror of
https://github.com/decompals/wibo.git
synced 2025-10-16 07:05:11 +00:00
54 lines
1.0 KiB
C++
54 lines
1.0 KiB
C++
|
|
#include "errors.h"
|
|
|
|
#include <cerrno>
|
|
|
|
namespace wibo {
|
|
|
|
DWORD winErrorFromErrno(int err) {
|
|
switch (err) {
|
|
case 0:
|
|
return ERROR_SUCCESS;
|
|
case EACCES:
|
|
return ERROR_ACCESS_DENIED;
|
|
case EEXIST:
|
|
return ERROR_ALREADY_EXISTS;
|
|
case ENOENT:
|
|
return ERROR_FILE_NOT_FOUND;
|
|
case ENOTDIR:
|
|
return ERROR_PATH_NOT_FOUND;
|
|
case ENOMEM:
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
case EINVAL:
|
|
return ERROR_INVALID_PARAMETER;
|
|
case EINTR:
|
|
return ERROR_OPERATION_ABORTED;
|
|
case EIO:
|
|
return ERROR_READ_FAULT;
|
|
case EPIPE:
|
|
return ERROR_BROKEN_PIPE;
|
|
case ESPIPE:
|
|
return ERROR_INVALID_PARAMETER;
|
|
default:
|
|
DEBUG_LOG("Unhandled errno %d -> ERROR_NOT_SUPPORTED\n", err);
|
|
return ERROR_NOT_SUPPORTED;
|
|
}
|
|
}
|
|
|
|
NTSTATUS statusFromWinError(DWORD error) {
|
|
switch (error) {
|
|
case ERROR_SUCCESS:
|
|
return STATUS_SUCCESS;
|
|
case ERROR_INVALID_HANDLE:
|
|
return STATUS_INVALID_HANDLE;
|
|
case ERROR_INVALID_PARAMETER:
|
|
return STATUS_INVALID_PARAMETER;
|
|
case ERROR_HANDLE_EOF:
|
|
return STATUS_END_OF_FILE;
|
|
default:
|
|
return STATUS_UNEXPECTED_IO_ERROR;
|
|
}
|
|
}
|
|
|
|
} // namespace wibo
|