r6079 - trunk/data/qcsrc/common

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Mar 8 07:43:39 EDT 2009


Author: div0
Date: 2009-03-08 07:43:39 -0400 (Sun, 08 Mar 2009)
New Revision: 6079

Modified:
   trunk/data/qcsrc/common/gamecommand.qc
Log:
a new "fexists" rpn command to just check if a file exists and print no error if not


Modified: trunk/data/qcsrc/common/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/common/gamecommand.qc	2009-03-08 10:51:02 UTC (rev 6078)
+++ trunk/data/qcsrc/common/gamecommand.qc	2009-03-08 11:43:39 UTC (rev 6079)
@@ -602,7 +602,7 @@
 						s = substring(s, 1, 99999);
 					rpn_set(s);
 					tokenize_sane(command);
-					} else if(rpncmd == "fexists_assert") {
+				} else if(rpncmd == "fexists_assert") {
 					s = rpn_pop();
 					if(!rpn_error)
 					{
@@ -614,6 +614,18 @@
 							rpn_error = TRUE;
 						}
 					}
+				} else if(rpncmd == "fexists") {
+					s = rpn_get();
+					if(!rpn_error)
+					{
+						f = fopen(s, FILE_READ);
+						if(f != -1) {
+							fclose(f);
+							rpn_setf(1);
+						} else {
+							rpn_setf(0);
+						}
+					}
 				} else if(rpncmd == "localtime") {
 					rpn_set(strftime(TRUE, rpn_get()));
 				} else if(rpncmd == "gmtime") {




More information about the nexuiz-commits mailing list