From cf06cd68bc1def355dc45c54046f4c874375ca52 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 13 Mar 2010 00:08:33 +0000 Subject: [PATCH] - Changed FileExists() to use stat instead of fopen/fclose, which ought to be lower overhead for files that are present. SVN r2206 (trunk) --- src/cmdlib.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/cmdlib.cpp b/src/cmdlib.cpp index 9942d27fc..dd32cdb55 100644 --- a/src/cmdlib.cpp +++ b/src/cmdlib.cpp @@ -148,17 +148,13 @@ int Q_filelength (FILE *f) bool FileExists (const char *filename) { - FILE *f; + struct stat buff; // [RH] Empty filenames are never there if (filename == NULL || *filename == 0) return false; - f = fopen (filename, "r"); - if (!f) - return false; - fclose (f); - return true; + return stat(filename, &buff) == 0 && !(buff.st_mode & S_IFDIR); } //==========================================================================