mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-29 23:32:23 +00:00
convert backslashes to slashes
This commit is contained in:
parent
840ecd6483
commit
f48313563c
1 changed files with 20 additions and 4 deletions
|
@ -636,12 +636,28 @@ int Q_filelength (FILE *f)
|
||||||
return end;
|
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 *SafeOpenWrite (const char *filename)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fopen(filename, "wb");
|
f = myfopen(filename, "wb");
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
Error ("Error opening %s: %s",filename,strerror(errno));
|
Error ("Error opening %s: %s",filename,strerror(errno));
|
||||||
|
@ -653,7 +669,7 @@ FILE *SafeOpenRead (const char *filename)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fopen(filename, "rb");
|
f = myfopen(filename, "rb");
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
Error ("Error opening %s: %s",filename,strerror(errno));
|
Error ("Error opening %s: %s",filename,strerror(errno));
|
||||||
|
@ -685,7 +701,7 @@ qboolean FileExists (const char *filename)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fopen (filename, "r");
|
f = myfopen (filename, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
return qfalse;
|
return qfalse;
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
@ -761,7 +777,7 @@ int TryLoadFile (const char *filename, void **bufferptr)
|
||||||
|
|
||||||
*bufferptr = NULL;
|
*bufferptr = NULL;
|
||||||
|
|
||||||
f = fopen (filename, "rb");
|
f = myfopen (filename, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
return -1;
|
return -1;
|
||||||
length = Q_filelength (f);
|
length = Q_filelength (f);
|
||||||
|
|
Loading…
Reference in a new issue