// LordHavoc: was 2048, increased to 16384 and changed info[MAX_PACK_FILES] to a temporary malloc to avoid stack overflows
#define MAX_FILES_IN_PACK 16384
-char com_cachedir[MAX_OSPATH];
-char com_gamedir[MAX_OSPATH];
+#if CACHEENABLE
+char com_cachedir[MAX_OSPATH];
+#endif
+char com_gamedir[MAX_OSPATH];
typedef struct searchpath_s
{
}
}
+/*
+============
+COM_CreatePath
+
+LordHavoc: Previously only used for CopyFile, now also used for COM_WriteFile.
+============
+*/
+void COM_CreatePath (char *path)
+{
+ char *ofs, save;
+
+ for (ofs = path+1 ; *ofs ; ofs++)
+ {
+ if (*ofs == '/' || *ofs == '\\' || *ofs == ':')
+ { // create the directory
+ save = *ofs;
+ *ofs = 0;
+ Sys_mkdir (path);
+ *ofs = save;
+ }
+ }
+}
+
+
/*
============
COM_WriteFile
sprintf (name, "%s/%s", com_gamedir, filename);
+ // LordHavoc: added this
+ COM_CreatePath (name); // create directories up to the file
+
handle = Sys_FileOpenWrite (name);
if (handle == -1)
{
}
-/*
-============
-COM_CreatePath
-
-Only used for CopyFile
-============
-*/
-void COM_CreatePath (char *path)
-{
- char *ofs;
-
- for (ofs = path+1 ; *ofs ; ofs++)
- {
- if (*ofs == '/')
- { // create the directory
- *ofs = 0;
- Sys_mkdir (path);
- *ofs = '/';
- }
- }
-}
-
-
/*
===========
COM_CopyFile
*/
int COM_FindFile (char *filename, int *handle, FILE **file, qboolean quiet)
{
- searchpath_t *search;
- char netpath[MAX_OSPATH];
- char cachepath[MAX_OSPATH];
- pack_t *pak;
- int i;
- int findtime, cachetime;
+ searchpath_t *search;
+ char netpath[MAX_OSPATH];
+#if CACHEENABLE
+ char cachepath[MAX_OSPATH];
+ int cachetime;
+#endif
+ pack_t *pak;
+ int i;
+ int findtime;
if (file && handle)
Sys_Error ("COM_FindFile: both handle and file set");
if (findtime == -1)
continue;
- // see if the file needs to be updated in the cache
- if (!com_cachedir[0])
- strcpy (cachepath, netpath);
- else
+#if CACHEENABLE
+ // see if the file needs to be updated in the cache
+ if (com_cachedir[0])
{
#if defined(_WIN32)
if ((strlen(netpath) < 2) || (netpath[1] != ':'))
COM_CopyFile (netpath, cachepath);
strcpy (netpath, cachepath);
}
+#endif
if (!quiet)
Sys_Printf ("FindFile: %s\n",netpath);
COM_LoadFile
Filename are reletive to the quake directory.
-Allways appends a 0 byte.
+Always appends a 0 byte.
============
*/
cache_user_t *loadcache;
basedir[j-1] = 0;
}
+#if CACHEENABLE
//
// -cachedir <path>
// Overrides the system supplied cache directory (NULL or /qcache)
strcpy (com_cachedir, host_parms.cachedir);
else
com_cachedir[0] = 0;
+#endif
//
// start up with GAMENAME by default (id1)