Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy and extend Utils::MapLastError() #37

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,25 @@ TInt Utils::MapLastError()

#ifdef __amigaos__

LONG Result;
int Error = IoErr();

Result = IoErr();

if (Result == ERROR_OBJECT_EXISTS)
if (Error == ERROR_OBJECT_EXISTS)
{
RetVal = KErrAlreadyExists;
}
else if (Result == ERROR_OBJECT_NOT_FOUND)
else if (Error == ERROR_DIR_NOT_FOUND)
{
RetVal = KErrPathNotFound;
}
else if (Error == ERROR_OBJECT_NOT_FOUND)
{
RetVal = KErrNotFound;
}
else if (Result == ERROR_DIR_NOT_FOUND)
else if (Error == ERROR_OBJECT_WRONG_TYPE)
{
RetVal = KErrPathNotFound;
RetVal = KErrCorrupt;
}
else if ((Result == ERROR_DIRECTORY_NOT_EMPTY) || (Result == ERROR_OBJECT_IN_USE))
else if ((Error == ERROR_DIRECTORY_NOT_EMPTY) || (Error == ERROR_OBJECT_IN_USE))
{
RetVal = KErrInUse;
}
Expand All @@ -202,15 +204,17 @@ TInt Utils::MapLastError()

#elif defined(__unix__)

if (errno == EEXIST)
int Error = errno;

if (Error == EEXIST)
{
RetVal = KErrAlreadyExists;
}
else if (errno == ENOENT)
else if (Error == ENOENT)
{
RetVal = KErrNotFound;
}
else if ((errno == ENOTEMPTY) || (errno == EBUSY) || (errno == ETXTBSY))
else if ((Error == ENOTEMPTY) || (Error == EBUSY) || (Error == ETXTBSY))
{
RetVal = KErrInUse;
}
Expand All @@ -221,21 +225,23 @@ TInt Utils::MapLastError()

#else /* ! __unix__ */

DWORD Error;

Error = GetLastError();
DWORD Error = GetLastError();

if (Error == ERROR_FILE_EXISTS)
{
RetVal = KErrAlreadyExists;
}
else if (Error == ERROR_PATH_NOT_FOUND)
{
RetVal = KErrPathNotFound;
}
else if ((Error == ERROR_FILE_NOT_FOUND) || (Error == ERROR_INVALID_NAME))
{
RetVal = KErrNotFound;
}
else if (Error == ERROR_PATH_NOT_FOUND)
else if (Error == ERROR_BAD_EXE_FORMAT)
{
RetVal = KErrPathNotFound;
RetVal = KErrCorrupt;
}
else if ((Error == ERROR_DIR_NOT_EMPTY) || (Error == ERROR_SHARING_VIOLATION))
{
Expand Down Expand Up @@ -281,6 +287,7 @@ TInt Utils::MapLastFileError(const char *a_pccFileName)
/* See what the last error was */

RetVal = Utils::MapLastError();
printf("RetVal = %d\n", RetVal);

#ifdef WIN32

Expand Down