aboutsummaryrefslogtreecommitdiffstats
path: root/q3asm
diff options
context:
space:
mode:
authorludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-09-03 12:01:07 +0000
committerludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-09-03 12:01:07 +0000
commit9a4b5cfc85b42eeed9e18431a7d2aef9d4ccd944 (patch)
treec5143fd340a09e736ba7ff765327c6ce0133f3da /q3asm
parent7fe6ea40699dbdb5f57107c401e3aacea284265d (diff)
downloadioquake3-aero-9a4b5cfc85b42eeed9e18431a7d2aef9d4ccd944.tar.gz
ioquake3-aero-9a4b5cfc85b42eeed9e18431a7d2aef9d4ccd944.zip
convert backslashes to slashes
git-svn-id: svn://svn.icculus.org/quake3/trunk@71 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'q3asm')
-rw-r--r--q3asm/cmdlib.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/q3asm/cmdlib.c b/q3asm/cmdlib.c
index d6483f8..56c70c0 100644
--- a/q3asm/cmdlib.c
+++ b/q3asm/cmdlib.c
@@ -636,12 +636,28 @@ int Q_filelength (FILE *f)
return end;
}
+#ifndef MAXPATH
+#define MAX_PATH 4096
+#endif
+static FILE* myfopen(const char* filename, const char* mode)
+{
+ char* p;
+ char fn[MAX_PATH];
+
+ fn[0] = '\0';
+ strncat(fn, filename, sizeof(fn)-1);
+
+ for(p=fn;*p;++p) if(*p == '\\') *p = '/';
+
+ return fopen(fn, mode);
+}
+
FILE *SafeOpenWrite (const char *filename)
{
FILE *f;
- f = fopen(filename, "wb");
+ f = myfopen(filename, "wb");
if (!f)
Error ("Error opening %s: %s",filename,strerror(errno));
@@ -653,7 +669,7 @@ FILE *SafeOpenRead (const char *filename)
{
FILE *f;
- f = fopen(filename, "rb");
+ f = myfopen(filename, "rb");
if (!f)
Error ("Error opening %s: %s",filename,strerror(errno));
@@ -685,7 +701,7 @@ qboolean FileExists (const char *filename)
{
FILE *f;
- f = fopen (filename, "r");
+ f = myfopen (filename, "r");
if (!f)
return qfalse;
fclose (f);
@@ -761,7 +777,7 @@ int TryLoadFile (const char *filename, void **bufferptr)
*bufferptr = NULL;
- f = fopen (filename, "rb");
+ f = myfopen (filename, "rb");
if (!f)
return -1;
length = Q_filelength (f);