From 7a914ef872a436adcdb36d21ceddba6bb24eb993 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Sat, 3 Jul 2010 16:01:48 +0000 Subject: Yet another huge commit. Implemented new error reporting framework based on errno and custom error codes. Converted filesystem code, image and model managers, BSP loader to use the new framework and report errors more accurately. Replaced fileHandle_t with qhandle_t. Removed INVALID_LENGTH definition. Killed USE_LOADBUF code. Defined FS_FileExists(Ex) macro, implemented FS_EasyOpenFile and FS_WriteFile helper functions. When testing for free screenshot slots, open the file with O_EXCL flag to avoid race conditions (works only on glibc yet). Don't allow quake paths with high bits set. Don't tolerate any fatal errors encountered when searching for files and pass errors back to the caller. FS_Seek() now fails on files from packs instead of returning an invalid position. Fixed ‘mvdskip’ command not working properly. Avoid inefficient usage of MakeColor macro in image loading functions. Prevent memory leak in JPEG and PNG image functions after calling longjmp() by marking some local variables volatile. Added support for loading monochrome JPEG images. Fixed signed integer overflow in GetWavinfo(). Fixed missing return statement in BSP_LoadSurfEdges() causing out of range edge indices to be left uncaught. Fixed possible access to uninitialized memory in BSP_LoadLeafs() for maps with no leafs. Properly NUL terminate the buffer in SCR_ScoreDump_f(), also check for being in a level. Always free latched_string when cvar is set back to current value. Fixed a crash in ‘mvdplay’ command possible when demo file is invalid. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/sys_unix.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'source/sys_unix.c') diff --git a/source/sys_unix.c b/source/sys_unix.c index 0368a77..885a97b 100644 --- a/source/sys_unix.c +++ b/source/sys_unix.c @@ -35,7 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include -#include #include #include #include @@ -486,15 +485,15 @@ unsigned Sys_Milliseconds( void ) { Sys_GetPathInfo ================ */ -qboolean Sys_GetPathInfo( const char *path, file_info_t *info ) { +qerror_t Sys_GetPathInfo( const char *path, file_info_t *info ) { struct stat st; if( stat( path, &st ) == -1 ) { - return qfalse; + return Q_ERR(errno); } if( !S_ISREG( st.st_mode ) ) { - return qfalse; + return Q_ERR_ISDIR; } if( info ) { @@ -503,18 +502,18 @@ qboolean Sys_GetPathInfo( const char *path, file_info_t *info ) { info->mtime = st.st_mtime; } - return qtrue; + return Q_ERR_SUCCESS; } -qboolean Sys_GetFileInfo( FILE *fp, file_info_t *info ) { +qerror_t Sys_GetFileInfo( FILE *fp, file_info_t *info ) { struct stat st; if( fstat( fileno( fp ), &st ) == -1 ) { - return qfalse; + return Q_ERR(errno); } if( !S_ISREG( st.st_mode ) ) { - return qfalse; + return Q_ERR_ISDIR; } if( info ) { @@ -523,7 +522,7 @@ qboolean Sys_GetFileInfo( FILE *fp, file_info_t *info ) { info->mtime = st.st_mtime; } - return qtrue; + return Q_ERR_SUCCESS; } /* -- cgit v1.2.3