Natural language #defines and build system support.

This commit is contained in:
Ryan C. Gordon 2002-07-28 21:03:27 +00:00
parent 2086e0ed9c
commit 42be0046aa
9 changed files with 264 additions and 283 deletions

View File

@ -49,7 +49,7 @@ static void DIR_dirClose(DirHandle *h);
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR = const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
{ {
"", "",
"non-archive directory I/O", DIR_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>", "Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/", "http://icculus.org/physfs/",
}; };

View File

@ -93,7 +93,7 @@ static FileHandle *GRP_openRead(DirHandle *h, const char *name);
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP = const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP =
{ {
"GRP", "GRP",
"Build engine Groupfile format", GRP_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>", "Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/", "http://icculus.org/physfs/",
}; };

View File

@ -147,7 +147,7 @@ static int zip_resolve(void *in, ZIPinfo *info, ZIPentry *entry);
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP = const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP =
{ {
"ZIP", "ZIP",
"PkZip/WinZip/Info-Zip compatible", ZIP_ARCHIVE_DESCRIPTION,
"Ryan C. Gordon <icculus@clutteredmind.org>", "Ryan C. Gordon <icculus@clutteredmind.org>",
"http://icculus.org/physfs/", "http://icculus.org/physfs/",
}; };
@ -183,46 +183,33 @@ const DirFunctions __PHYSFS_DirFunctions_ZIP =
}; };
static const char *zlib_error_string(int rc)
{
switch (rc)
{
case Z_OK: return(NULL); /* not an error. */
case Z_STREAM_END: return(NULL); /* not an error. */
case Z_ERRNO: return(strerror(errno));
case Z_NEED_DICT: return(ERR_ZLIB_NEED_DICT);
case Z_DATA_ERROR: return(ERR_ZLIB_DATA_ERROR);
case Z_MEM_ERROR: return(ERR_ZLIB_MEMORY_ERROR);
case Z_BUF_ERROR: return(ERR_ZLIB_BUFFER_ERROR);
case Z_VERSION_ERROR: return(ERR_ZLIB_VERSION_ERROR);
default: return(ERR_ZLIB_UNKNOWN_ERROR);
} /* switch */
return(NULL);
} /* zlib_error_string */
/* /*
* Wrap all zlib calls in this, so the physfs error state is set appropriately. * Wrap all zlib calls in this, so the physfs error state is set appropriately.
*/ */
static int zlib_err(int rc) static int zlib_err(int rc)
{ {
const char *err = NULL; const char *str = zlib_error_string(rc);
if (str != NULL)
switch (rc) __PHYSFS_setError(str);
{
case Z_OK:
case Z_STREAM_END:
break; /* not errors. */
case Z_ERRNO:
err = strerror(errno);
break;
case Z_NEED_DICT:
err = "zlib: need dictionary";
break;
case Z_DATA_ERROR:
err = "zlib: need dictionary";
break;
case Z_MEM_ERROR:
err = "zlib: memory error";
break;
case Z_BUF_ERROR:
err = "zlib: buffer error";
break;
case Z_VERSION_ERROR:
err = "zlib: version error";
break;
default:
err = "unknown zlib error";
break;
} /* switch */
if (err != NULL)
__PHYSFS_setError(err);
return(rc); return(rc);
} /* zlib_err */ } /* zlib_err */

View File

@ -229,9 +229,36 @@ if test x$enable_cdrom = xyes; then
fi fi
fi fi
dnl determine language.
physfslang=english
AC_ARG_ENABLE(language,
[ --enable-language=lang English, currently. [default=english]],
physfslang=`echo $enable_language |tr A-Z a-z`)
AC_MSG_CHECKING([if language choice is supported])
physfs_valid_lang=no
if test x$physfslang = xenglish; then
physfs_valid_lang=yes
AC_DEFINE([PHYSFS_LANG], PHYSFS_LANG_ENGLISH, [define desired natural language])
fi
dnl Add other language checks here...
AC_MSG_RESULT([$physfs_valid_lang])
if test x$physfs_valid_lang = xno; then
AC_MSG_WARN([***])
AC_MSG_WARN([*** You've asked for "$physfslang" language support...])
AC_MSG_WARN([*** ...but we don't support that.])
AC_MSG_WARN([*** You could choose another language,])
AC_MSG_WARN([*** but is this what you REALLY wanted?])
AC_MSG_WARN([*** Please see the LANG section of physfs_internal.h])
AC_MSG_WARN([*** for info on writing a translation.])
AC_MSG_WARN([***])
AC_MSG_ERROR([*** unsupported language. stop.])
fi
have_non_posix_threads=no have_non_posix_threads=no
dnl AC_CHECK_HEADER(be/kernel/OS.h, this_is_beos=yes)
AC_MSG_CHECKING([if this is BeOS]) AC_MSG_CHECKING([if this is BeOS])
if test x$build_os = xbeos; then if test x$build_os = xbeos; then
this_is_beos=yes this_is_beos=yes

View File

@ -824,7 +824,7 @@ int PHYSFS_setSaneConfig(const char *organization, const char *appName,
/* Root out archives, and add them to search path... */ /* Root out archives, and add them to search path... */
if (archiveExt != NULL) if (archiveExt != NULL)
{ {
char **rc = PHYSFS_enumerateFiles(""); char **rc = PHYSFS_enumerateFiles("/");
char **i; char **i;
size_t extlen = strlen(archiveExt); size_t extlen = strlen(archiveExt);
char *ext; char *ext;

View File

@ -20,6 +20,117 @@
extern "C" { extern "C" {
#endif #endif
/* The LANG section. */
/* please send questions/translations to Ryan: icculus@clutteredmind.org. */
#if (!defined PHYSFS_LANG)
# define PHYSFS_LANG PHYSFS_LANG_ENGLISH
#endif
#define PHYSFS_LANG_ENGLISH 1 /* English text by Ryan C. Gordon */
#if (PHYSFS_LANG == PHYSFS_LANG_ENGLISH)
#define DIR_ARCHIVE_DESCRIPTION "Non-archive, direct filesystem I/O"
#define GRP_ARCHIVE_DESCRIPTION "Build engine Groupfile format"
#define ZIP_ARCHIVE_DESCRIPTION "PkZip/WinZip/Info-Zip compatible"
#define ERR_IS_INITIALIZED "Already initialized"
#define ERR_NOT_INITIALIZED "Not initialized"
#define ERR_INVALID_ARGUMENT "Invalid argument"
#define ERR_FILES_STILL_OPEN "Files still open"
#define ERR_NO_DIR_CREATE "Failed to create directories"
#define ERR_OUT_OF_MEMORY "Out of memory"
#define ERR_NOT_IN_SEARCH_PATH "No such entry in search path"
#define ERR_NOT_SUPPORTED "Operation not supported"
#define ERR_UNSUPPORTED_ARCHIVE "Archive type unsupported"
#define ERR_NOT_A_HANDLE "Not a file handle"
#define ERR_INSECURE_FNAME "Insecure filename"
#define ERR_SYMLINK_DISALLOWED "Symbolic links are disabled"
#define ERR_NO_WRITE_DIR "Write directory is not set"
#define ERR_NO_SUCH_FILE "File not found"
#define ERR_NO_SUCH_PATH "Path not found"
#define ERR_NO_SUCH_VOLUME "Volume not found"
#define ERR_PAST_EOF "Past end of file"
#define ERR_ARC_IS_READ_ONLY "Archive is read-only"
#define ERR_IO_ERROR "I/O error"
#define ERR_CANT_SET_WRITE_DIR "Can't set write directory"
#define ERR_SYMLINK_LOOP "Infinite symbolic link loop"
#define ERR_COMPRESSION "(De)compression error"
#define ERR_NOT_IMPLEMENTED "Not implemented"
#define ERR_OS_ERROR "Operating system reported error"
#define ERR_FILE_EXISTS "File already exists"
#define ERR_NOT_A_FILE "Not a file"
#define ERR_NOT_A_DIR "Not a directory"
#define ERR_NOT_AN_ARCHIVE "Not an archive"
#define ERR_CORRUPTED "Corrupted archive"
#define ERR_SEEK_OUT_OF_RANGE "Seek out of range"
#define ERR_BAD_FILENAME "Bad filename"
#define ERR_PHYSFS_BAD_OS_CALL "(BUG) PhysicsFS made a bad system call"
#define ERR_ARGV0_IS_NULL "argv0 is NULL"
#define ERR_ZLIB_NEED_DICT "zlib: need dictionary"
#define ERR_ZLIB_DATA_ERROR "zlib: data error"
#define ERR_ZLIB_MEMORY_ERROR "zlib: memory error"
#define ERR_ZLIB_BUFFER_ERROR "zlib: buffer error"
#define ERR_ZLIB_VERSION_ERROR "zlib: version error"
#define ERR_ZLIB_UNKNOWN_ERROR "zlib: unknown error"
#define ERR_SEARCHPATH_TRUNC "Search path was truncated"
#define ERR_GETMODFN_TRUNC "GetModuleFileName() was truncated"
#define ERR_GETMODFN_NO_DIR "GetModuleFileName() had no dir"
#define ERR_DISK_FULL "Disk is full"
#define ERR_DIRECTORY_FULL "Directory full"
#define ERR_MACOS_GENERIC "MacOS reported error (%d)"
#define ERR_OS2_GENERIC "OS/2 reported error (%d)"
#define ERR_VOL_LOCKED_HW "Volume is locked through hardware"
#define ERR_VOL_LOCKED_SW "Volume is locked through software"
#define ERR_FILE_LOCKED "File is locked"
#define ERR_FILE_OR_DIR_BUSY "File/directory is busy"
#define ERR_FILE_ALREADY_OPEN_W "File already open for writing"
#define ERR_FILE_ALREADY_OPEN_R "File already open for reading"
#define ERR_INVALID_REFNUM "Invalid reference number"
#define ERR_GETTING_FILE_POS "Error getting file position"
#define ERR_VOLUME_OFFLINE "Volume is offline"
#define ERR_PERMISSION_DENIED "Permission denied"
#define ERR_VOL_ALREADY_ONLINE "Volume already online"
#define ERR_NO_SUCH_DRIVE "No such drive"
#define ERR_NOT_MAC_DISK "Not a Macintosh disk"
#define ERR_VOL_EXTERNAL_FS "Volume belongs to an external filesystem"
#define ERR_PROBLEM_RENAME "Problem during rename"
#define ERR_BAD_MASTER_BLOCK "Bad master directory block"
#define ERR_CANT_MOVE_FORBIDDEN "Attempt to move forbidden"
#define ERR_WRONG_VOL_TYPE "Wrong volume type"
#define ERR_SERVER_VOL_LOST "Server volume has been disconnected"
#define ERR_FILE_ID_NOT_FOUND "File ID not found"
#define ERR_FILE_ID_EXISTS "File ID already exists"
#define ERR_SERVER_NO_RESPOND "Server not responding"
#define ERR_USER_AUTH_FAILED "User authentication failed"
#define ERR_PWORD_EXPIRED "Password has expired on server"
#define ERR_ACCESS_DENIED "Access denied"
#define ERR_NOT_A_DOS_DISK "Not a DOS disk"
#define ERR_SHARING_VIOLATION "Sharing violation"
#define ERR_CANNOT_MAKE "Cannot make"
#define ERR_DEV_IN_USE "Device already in use"
#define ERR_OPEN_FAILED "Open failed"
#define ERR_PIPE_BUSY "Pipe is busy"
#define ERR_SHARING_BUF_EXCEEDED "Sharing buffer exceeded"
#define ERR_TOO_MANY_HANDLES "Too many open handles"
#define ERR_SEEK_ERROR "Seek error"
#define ERR_DEL_CWD "Trying to delete current working directory"
#define ERR_WRITE_PROTECT_ERROR "Write protect error"
#define ERR_WRITE_FAULT "Write fault"
#define ERR_LOCK_VIOLATION "Lock violation"
#define ERR_GEN_FAILURE "General failure"
#define ERR_UNCERTAIN_MEDIA "Uncertain media"
#define ERR_PROT_VIOLATION "Protection violation"
#define ERR_BROKEN_PIPE "Broken pipe"
#else
#error Please define PHYSFS_LANG.
#endif
/* end LANG section. */
struct __PHYSFS_DIRHANDLE__; struct __PHYSFS_DIRHANDLE__;
struct __PHYSFS_FILEFUNCTIONS__; struct __PHYSFS_FILEFUNCTIONS__;
@ -252,38 +363,6 @@ typedef struct __PHYSFS_DIRFUNCTIONS__
} DirFunctions; } DirFunctions;
/* error messages... */
#define ERR_IS_INITIALIZED "Already initialized"
#define ERR_NOT_INITIALIZED "Not initialized"
#define ERR_INVALID_ARGUMENT "Invalid argument"
#define ERR_FILES_STILL_OPEN "Files still open"
#define ERR_NO_DIR_CREATE "Failed to create directories"
#define ERR_OUT_OF_MEMORY "Out of memory"
#define ERR_NOT_IN_SEARCH_PATH "No such entry in search path"
#define ERR_NOT_SUPPORTED "Operation not supported"
#define ERR_UNSUPPORTED_ARCHIVE "Archive type unsupported"
#define ERR_NOT_A_HANDLE "Not a file handle"
#define ERR_INSECURE_FNAME "Insecure filename"
#define ERR_SYMLINK_DISALLOWED "Symbolic links are disabled"
#define ERR_NO_WRITE_DIR "Write directory is not set"
#define ERR_NO_SUCH_FILE "No such file"
#define ERR_PAST_EOF "Past end of file"
#define ERR_ARC_IS_READ_ONLY "Archive is read-only"
#define ERR_IO_ERROR "I/O error"
#define ERR_CANT_SET_WRITE_DIR "Can't set write directory"
#define ERR_SYMLINK_LOOP "Infinite symbolic link loop"
#define ERR_COMPRESSION "(De)compression error"
#define ERR_NOT_IMPLEMENTED "Not implemented"
#define ERR_OS_ERROR "Operating system reported error"
#define ERR_FILE_EXISTS "File already exists"
#define ERR_NOT_A_DIR "Not a directory"
#define ERR_FILE_NOT_FOUND "File not found"
#define ERR_NOT_AN_ARCHIVE "Not an archive"
#define ERR_CORRUPTED "Corrupted archive"
#define ERR_SEEK_OUT_OF_RANGE "Seek out of range"
#define ERR_BAD_FILENAME "Bad filename"
/* /*
* Call this to set the message returned by PHYSFS_getLastError(). * Call this to set the message returned by PHYSFS_getLastError().
* Please only use the ERR_* constants above, or add new constants to the * Please only use the ERR_* constants above, or add new constants to the

View File

@ -61,56 +61,56 @@
const char *__PHYSFS_platformDirSeparator = ":"; const char *__PHYSFS_platformDirSeparator = ":";
static const char *get_os_error_string(OSErr err) static const char *get_macos_error_string(OSErr err)
{ {
if (err == noErr) if (err == noErr)
return(NULL); return(NULL);
switch (err) switch (err)
{ {
case fnfErr: return("File not found"); case fnfErr: return(ERR_NO_SUCH_FILE);
case notOpenErr: return("Volume not found"); case notOpenErr: return(ERR_NO_SUCH_VOLUME);
case dirFulErr: return("Directory full"); case dirFulErr: return(ERR_DIRECTORY_FULL);
case dskFulErr: return("Disk full"); case dskFulErr: return(ERR_DISK_FULL);
case nsvErr: return("Volume not found"); case nsvErr: return(ERR_NO_SUCH_VOLUME);
case ioErr: return(ERR_IO_ERROR); case ioErr: return(ERR_IO_ERROR);
case bdNamErr: return(ERR_BAD_FILENAME); case bdNamErr: return(ERR_BAD_FILENAME);
case fnOpnErr: return(ERR_NOT_A_HANDLE); case fnOpnErr: return(ERR_NOT_A_HANDLE);
case eofErr: return(ERR_PAST_EOF); case eofErr: return(ERR_PAST_EOF);
case posErr: return(ERR_SEEK_OUT_OF_RANGE); case posErr: return(ERR_SEEK_OUT_OF_RANGE);
case tmfoErr: return("Too many files open"); case tmfoErr: return(ERR_TOO_MANY_HANDLES);
case wPrErr: return("Volume is locked through hardware"); case wPrErr: return(ERR_VOL_LOCKED_HW);
case fLckdErr: return("File is locked"); case fLckdErr: return(ERR_FILE_LOCKED);
case vLckdErr: return("Volume is locked through software"); case vLckdErr: return(ERR_VOL_LOCKED_SW);
case fBsyErr: return("File/directory is busy"); case fBsyErr: return(ERR_FILE_OR_DIR_BUSY);
case dupFNErr: return(FILE_ALREADY_EXISTS); case dupFNErr: return(ERR_FILE_ALREADY_EXISTS);
case opWrErr: return("File already open for writing"); case opWrErr: return(ERR_FILE_ALREADY_OPEN_W);
case rfNumErr: return("Invalid reference number"); case rfNumErr: return(ERR_INVALID_REFNUM);
case gfpErr: return("Error getting file position"); case gfpErr: return(ERR_GETTING_FILE_POS);
case volOffLinErr: return("Volume is offline"); case volOffLinErr: return(ERR_VOLUME_OFFLINE);
case permErr: return("Permission denied"); case permErr: return(ERR_PERMISSION_DENIED);
case volOnLinErr: return("Volume already online"); case volOnLinErr: return(ERR_VOL_ALREADY_ONLINE);
case nsDrvErr: return("No such drive"); case nsDrvErr: return(ERR_NO_SUCH_DRIVE);
case noMacDskErr: return("Not a Macintosh disk"); case noMacDskErr: return(ERR_NOT_MAC_DISK);
case extFSErr: return("Volume belongs to an external file system"); case extFSErr: return(ERR_VOL_EXTERNAL_FS);
case fsRnErr: return("Problem during rename"); case fsRnErr: return(ERR_PROBLEM_RENAME);
case badMDBErr: return("Bad master directory block"); case badMDBErr: return(ERR_BAD_MASTER_BLOCK);
case wrPermErr: return("Write permission denied"); case wrPermErr: return(ERR_PERMISSION_DENIED);
case memFullErr: return(ERR_OUT_OF_MEMORY); case memFullErr: return(ERR_OUT_OF_MEMORY);
case dirNFErr: return("Directory not found or incomplete pathname"); case dirNFErr: return(ERR_NO_SUCH_PATH);
case tmwdoErr: return("Too many working directories open"); case tmwdoErr: return(ERR_TOO_MANY_HANDLES);
case badMovErr: return("Attempt to move forbidden"); case badMovErr: return(ERR_CANT_MOVE_FORBIDDEN);
case wrgVolTypErr: return("Wrong volume type"); case wrgVolTypErr: return(ERR_WRONG_VOL_TYPE);
case volGoneErr: return("Server volume has been disconnected"); case volGoneErr: return(ERR_SERVER_VOL_LOST);
case errFSNameTooLong: return(ERR_BAD_FILENAME); case errFSNameTooLong: return(ERR_BAD_FILENAME);
case errFSNotAFolder: return("Not a folder"); case errFSNotAFolder: return(ERR_NOT_A_DIR);
case errFSNotAFile: return("Not a file"); case errFSNotAFile: return(ERR_NOT_A_FILE);
case fidNotFound: return("File ID not found"); case fidNotFound: return(ERR_FILE_ID_NOT_FOUND);
case fidExists: return("File ID already exists"); case fidExists: return(ERR_FILE_ID_EXISTS);
case afpAccessDenied: return("Access denied"); case afpAccessDenied: return(ERR_ACCESS_DENIED);
case afpNoServer: return("Server not responding"); case afpNoServer: return(ERR_SERVER_NO_RESPOND);
case afpUserNotAuth: return("User authentication failed"); case afpUserNotAuth: return(ERR_USER_AUTH_FAILED);
case afpPwdExpiredErr: return("Password has expired on server"); case afpPwdExpiredErr: return(ERR_PWORD_EXPIRED);
case paramErr: case paramErr:
case errFSBadFSRef: case errFSBadFSRef:
@ -121,29 +121,29 @@ static const char *get_os_error_string(OSErr err)
case errFSBadItemCount case errFSBadItemCount
case errFSBadSearchParams case errFSBadSearchParams
case afpDenyConflict case afpDenyConflict
return("(BUG) PhysicsFS gave wrong params to the OS."); return(ERR_PHYSFS_BAD_OS_CALL);
default: return(ERR_OS_ERROR); default: return(ERR_MACOS_GENERIC);
} /* switch */ } /* switch */
return(NULL); return(NULL);
} /* get_os_error_string */ } /* get_macos_error_string */
static OSErr oserr(OSErr err) static OSErr oserr(OSErr retval)
{ {
char buf[128]; char buf[128];
const char *errstr = get_os_error_string(err); const char *errstr = get_macos_error_string(retval);
if (err == ERR_OS_ERROR) if (errstr == ERR_MACOS_GENERIC)
{ {
snprintf(buf, "MacOS reported error (%d)", (int) err); snprintf(buf, ERR_MACOS_GENERIC, (int) retval);
errstr = buf; errstr = buf;
} /* if */ } /* if */
if (errstr != NULL) if (errstr != NULL)
__PHYSFS_SetError(errstr); __PHYSFS_setError(errstr);
return(err); return(retval);
} /* oserr */ } /* oserr */

View File

@ -36,116 +36,40 @@
const char *__PHYSFS_platformDirSeparator = "\\"; const char *__PHYSFS_platformDirSeparator = "\\";
static APIRET os2err(APIRET retval) static const char *get_os2_error_string(APIRET rc)
{ {
const char *err = NULL; switch (rc)
/*
* The ones that say "OS/2 reported" are more for PhysicsFS developer
* debugging. We give more generic messages for ones that are likely to
* fall through to an application.
*/
switch (retval)
{ {
case NO_ERROR: /* Don't set the PhysicsFS error message for these... */ case NO_ERROR: return(NULL); /* not an error. */
case ERROR_INTERRUPT: case ERROR_INTERRUPT: return(NULL); /* not an error. */
case ERROR_TIMEOUT: case ERROR_TIMEOUT: return(NULL); /* not an error. */
break; case ERROR_NOT_ENOUGH_MEMORY: return(ERR_OUT_OF_MEMORY);
case ERROR_FILE_NOT_FOUND: return(ERR_NO_SUCH_FILE);
case ERROR_NOT_ENOUGH_MEMORY: case ERROR_PATH_NOT_FOUND: return(ERR_NO_SUCH_PATH);
err = ERR_OUT_OF_MEMORY; case ERROR_ACCESS_DENIED: return(ERR_ACCESS_DENIED);
break; case ERROR_NOT_DOS_DISK: return(ERR_NOT_A_DOS_DISK);
case ERROR_SHARING_VIOLATION: return(ERR_SHARING_VIOLATION);
case ERROR_FILE_NOT_FOUND: case ERROR_CANNOT_MAKE: return(ERR_CANNOT_MAKE);
err = "File not found"; case ERROR_DEVICE_IN_USE: return(ERR_DEV_IN_USE);
break; case ERROR_OPEN_FAILED: return(ERR_OPEN_FAILED);
case ERROR_DISK_FULL: return(ERR_DISK_FULL);
case ERROR_PATH_NOT_FOUND: case ERROR_PIPE_BUSY: return(ERR_PIPE_BUSY);
err = "Path not found"; case ERROR_SHARING_BUFFER_EXCEEDED: return(ERR_SHARING_BUF_EXCEEDED);
break; case ERROR_FILENAME_EXCED_RANGE: return(ERR_BAD_FILENAME);
case ERROR_META_EXPANSION_TOO_LONG: return(ERR_BAD_FILENAME);
case ERROR_ACCESS_DENIED: case ERROR_TOO_MANY_HANDLES: return(ERR_TOO_MANY_HANDLES);
err = "Access denied"; case ERROR_TOO_MANY_OPEN_FILES: return(ERR_TOO_MANY_HANDLES);
break; case ERROR_NO_MORE_SEARCH_HANDLES: return(ERR_TOO_MANY_HANDLES);
case ERROR_SEEK_ON_DEVICE: return(ERR_SEEK_ERROR);
case ERROR_NOT_DOS_DISK: case ERROR_NEGATIVE_SEEK: return(ERR_SEEK_OUT_OF_RANGE);
err = "Not a DOS disk"; case ERROR_DEL_CURRENT_DIRECTORY: return(ERR_DEL_CWD);
break; case ERROR_WRITE_PROTECT: return(ERR_WRITE_PROTECT_ERROR);
case ERROR_WRITE_FAULT: return(ERR_WRITE_FAULT);
case ERROR_SHARING_VIOLATION: case ERROR_LOCK_VIOLATION: return(ERR_LOCK_VIOLATION);
err = "Sharing violation"; case ERROR_GEN_FAILURE: return(ERR_GENERAL_FAILURE);
break; case ERROR_UNCERTAIN_MEDIA: return(ERR_UNCERTAIN_MEDIA);
case ERROR_PROTECTION_VIOLATION: return(ERR_PROT_VIOLATION);
case ERROR_CANNOT_MAKE: case ERROR_BROKEN_PIPE: return(ERR_BROKEN_PIPE);
err = "Cannot make";
break;
case ERROR_DEVICE_IN_USE:
err = "Device already in use";
break;
case ERROR_OPEN_FAILED:
err = "Open failed";
break;
case ERROR_DISK_FULL:
err = "Disk is full";
break;
case ERROR_PIPE_BUSY:
err = "Pipe busy";
break;
case ERROR_SHARING_BUFFER_EXCEEDED:
err = "Sharing buffer exceeded";
break;
case ERROR_FILENAME_EXCED_RANGE:
case ERROR_META_EXPANSION_TOO_LONG:
err = "Filename too big";
break;
case ERROR_TOO_MANY_HANDLES:
case ERROR_TOO_MANY_OPEN_FILES:
case ERROR_NO_MORE_SEARCH_HANDLES:
err = "Too many open handles";
break;
case ERROR_SEEK_ON_DEVICE:
err = "Seek error"; /* Is that what this error means? */
break;
case ERROR_NEGATIVE_SEEK:
err = "Seek past start of file";
break;
case ERROR_CURRENT_DIRECTORY:
err = "Trying to delete current working directory";
break;
case ERROR_WRITE_PROTECT:
err = "Write protect error";
break;
case ERROR_WRITE_FAULT:
err = "Write fault";
break;
case ERROR_LOCK_VIOLATION:
err = "Lock violation";
break;
case ERROR_GEN_FAILURE:
err = "General failure";
break;
case ERROR_UNCERTAIN_MEDIA:
err = "Uncertain media";
break;
case ERROR_PROTECTION_VIOLATION:
err = "Protection violation";
break;
case ERROR_INVALID_PARAMETER: case ERROR_INVALID_PARAMETER:
case ERROR_INVALID_NAME: case ERROR_INVALID_NAME:
@ -159,66 +83,30 @@ static APIRET os2err(APIRET retval)
case ERROR_BAD_LENGTH: case ERROR_BAD_LENGTH:
case ERROR_BAD_DRIVER_LEVEL: case ERROR_BAD_DRIVER_LEVEL:
case ERROR_DIRECT_ACCESS_HANDLE: case ERROR_DIRECT_ACCESS_HANDLE:
err = "OS/2 reported an invalid parameter to an API function";
break;
case ERROR_NO_VOLUME_LABEL:
err = "OS/2 reported no volume label";
break;
case ERROR_NO_MORE_FILES:
err = "OS/2 reported no more files";
break;
case ERROR_MONITORS_NOT_SUPPORTED:
err = "OS/2 reported monitors not supported";
break;
case ERROR_BROKEN_PIPE:
err = "OS/2 reported a broken pipe";
break;
case ERROR_MORE_DATA:
err = "OS/2 reported \"more data\" (?)";
break;
case ERROR_EAS_DIDNT_FIT:
err = "OS/2 reported Extended Attributes didn't fit";
break;
case ERROR_INVALID_EA_NAME:
err = "OS/2 reported an invalid Extended Attribute name";
break;
case ERROR_EA_LIST_INCONSISTENT:
err = "OS/2 reported an inconsistent Extended Attribute list";
break;
case ERROR_SEM_OWNER_DIED:
err = "OS/2 reported that semaphore owner died";
break;
case ERROR_TOO_MANY_SEM_REQUESTS:
err = "OS/2 reported too many semaphore requests";
break;
case ERROR_SEM_BUSY:
err = "OS/2 reported a blocked semaphore";
break;
case ERROR_NOT_OWNER: case ERROR_NOT_OWNER:
err = "OS/2 reported that we used a resource we don't own."; return(ERR_PHYSFS_BAD_OS_CALL);
break;
default: default: return(ERR_OS2_GENERIC);
err = "OS/2 reported back with unrecognized error code";
break;
} /* switch */ } /* switch */
return(NULL);
} /* get_os2_error_string */
static APIRET os2err(APIRET retval)
{
char buf[128];
const char *err = get_os2_error_string(retval);
if (err == ERR_OS2_GENERIC)
{
snprintf(buf, ERR_OS2_GENERIC, (int) retval);
err = buf;
} /* if */
if (err != NULL) if (err != NULL)
__PHYSFS_setError(err); __PHYSFS_setError(err);
return(retval); return(err);
} /* os2err */ } /* os2err */

View File

@ -125,12 +125,12 @@ static char *getExePath(const char *argv0)
/* make sure the string was not truncated. */ /* make sure the string was not truncated. */
if (__PHYSFS_platformStricmp(&retval[buflen - 4], ".exe") != 0) if (__PHYSFS_platformStricmp(&retval[buflen - 4], ".exe") != 0)
__PHYSFS_setError("WIN32: GetModuleFileName() got truncated."); __PHYSFS_setError(ERR_GOTMODFN_TRUNC);
else else
{ {
ptr = strrchr(retval, '\\'); ptr = strrchr(retval, '\\');
if (ptr == NULL) if (ptr == NULL)
__PHYSFS_setError("WIN32: GetModuleFileName() had no dir."); __PHYSFS_setError(ERR_GETMODFN_NO_DIR);
else else
{ {
*(ptr + 1) = '\0'; /* chop off filename. */ *(ptr + 1) = '\0'; /* chop off filename. */
@ -144,14 +144,14 @@ static char *getExePath(const char *argv0)
if (!success) if (!success)
{ {
if (argv0 == NULL) if (argv0 == NULL)
__PHYSFS_setError("WIN32: argv0 is NULL."); __PHYSFS_setError(ERR_ARGV0_IS_NULL);
else else
{ {
buflen = SearchPath(NULL, argv0, NULL, MAX_PATH+1, retval, &ptr); buflen = SearchPath(NULL, argv0, NULL, MAX_PATH+1, retval, &ptr);
if (buflen == 0) if (buflen == 0)
__PHYSFS_setError(win32strerror()); __PHYSFS_setError(win32strerror());
else if (buflen > MAX_PATH) else if (buflen > MAX_PATH)
__PHYSFS_setError("Win32: SearchPath() got truncated."); __PHYSFS_setError(ERR_SEARCHPATH_TRUNC);
else else
success = 1; success = 1;
} /* else */ } /* else */