Skip to content

Commit b81f179

Browse files
committed
XDG home directory support
1 parent fb7b58f commit b81f179

File tree

18 files changed

+470
-137
lines changed

18 files changed

+470
-137
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,8 @@ binary must not detect any original quake3 game pak files. If this
471471
condition is met, the game will set com_standalone to 1 and is then running
472472
in stand alone mode.
473473

474-
If you want the engine to use a different directory in your homepath than
475-
e.g. "Quake3" on Windows or ".q3a" on Linux, then set a new name at startup
476-
by adding
474+
If you want the engine to use a different directory in your homepaths than
475+
"Quake3" then set a new name at startup by adding
477476

478477
+set com_homepath <homedirname>
479478

@@ -487,7 +486,7 @@ matching game name.
487486

488487
Example line:
489488

490-
+set com_basegame basefoo +set com_homepath .foo
489+
+set com_basegame basefoo +set com_homepath foo
491490
+set com_gamename foo
492491

493492
If you really changed parts that would make vanilla ioquake3 incompatible with

code/botlib/l_log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void Log_Open(char *filename)
7171
botimport.Print(PRT_ERROR, "log file %s is already opened\n", logfile.filename);
7272
return;
7373
} //end if
74-
ospath = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), Cvar_VariableString("fs_game"), filename);
74+
ospath = FS_BuildOSPath(Cvar_VariableString("fs_homestatepath"), Cvar_VariableString("fs_game"), filename);
7575
logfile.fp = fopen(ospath, "wb");
7676
if (!logfile.fp)
7777
{

code/client/cl_avi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,10 @@ qboolean CL_OpenAVIForWriting( const char *fileName )
335335
return qfalse;
336336
}
337337

338-
if( ( afd.f = FS_FOpenFileWrite( fileName ) ) <= 0 )
338+
if( ( afd.f = FS_FOpenFileWrite_HomeData( fileName ) ) <= 0 )
339339
return qfalse;
340340

341-
if( ( afd.idxF = FS_FOpenFileWrite(
341+
if( ( afd.idxF = FS_FOpenFileWrite_HomeData(
342342
va( "%s" INDEX_FILE_EXTENSION, fileName ) ) ) <= 0 )
343343
{
344344
FS_FCloseFile( afd.f );
@@ -635,7 +635,7 @@ qboolean CL_CloseAVI( void )
635635
FS_FCloseFile( afd.idxF );
636636

637637
// Remove temp index file
638-
FS_HomeRemove( idxFileName );
638+
FS_Remove_HomeData( idxFileName );
639639

640640
// Write the real header
641641
FS_Seek( afd.f, 0, FS_SEEK_SET );

code/client/cl_console.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void Con_Dump_f (void)
201201
return;
202202
}
203203

204-
f = FS_FOpenFileWrite( filename );
204+
f = FS_FOpenFileWrite_HomeData( filename );
205205
if (!f)
206206
{
207207
Com_Printf ("ERROR: couldn't open %s.\n", filename);

code/client/cl_keys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ void CL_SaveConsoleHistory( void )
15771577

15781578
consoleSaveBufferSize = strlen( consoleSaveBuffer );
15791579

1580-
f = FS_FOpenFileWrite( CONSOLE_HISTORY_FILE );
1580+
f = FS_FOpenFileWrite_HomeState( CONSOLE_HISTORY_FILE );
15811581
if( !f )
15821582
{
15831583
Com_Printf( "Couldn't write %s.\n", CONSOLE_HISTORY_FILE );

code/client/cl_main.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -742,15 +742,15 @@ void CL_Record_f( void ) {
742742
#endif
743743
Com_sprintf(name, sizeof(name), "demos/%s.%s%d", demoName, DEMOEXT, com_protocol->integer);
744744

745-
if (!FS_FileExists(name))
745+
if (!FS_FileExists_HomeData(name))
746746
break; // file doesn't exist
747747
}
748748
}
749749

750750
// open the demo file
751751

752752
Com_Printf ("recording to %s.\n", name);
753-
clc.demofile = FS_FOpenFileWrite( name );
753+
clc.demofile = FS_FOpenFileWrite_HomeData( name );
754754
if ( !clc.demofile ) {
755755
Com_Printf ("ERROR: couldn't open.\n");
756756
return;
@@ -903,7 +903,7 @@ void CL_DemoCompleted( void )
903903
else
904904
numFrames = clc.timeDemoFrames - 1;
905905

906-
f = FS_FOpenFileWrite( cl_timedemoLog->string );
906+
f = FS_FOpenFileWrite_HomeData( cl_timedemoLog->string );
907907
if( f )
908908
{
909909
FS_Printf( f, "# %s", buffer );
@@ -2197,7 +2197,7 @@ static void CL_BeginHttpDownload( const char *remoteURL ) {
21972197
CL_HTTP_BeginDownload(remoteURL);
21982198
Q_strncpyz(clc.downloadURL, remoteURL, sizeof(clc.downloadURL));
21992199

2200-
clc.download = FS_BaseDir_FOpenFileWrite(clc.downloadTempName);
2200+
clc.download = FS_BaseDir_FOpenFileWrite_HomeData(clc.downloadTempName);
22012201
if(!clc.download) {
22022202
Com_Error(ERR_DROP, "CL_BeginHTTPDownload: failed to open "
22032203
"%s for writing", clc.downloadTempName);
@@ -2233,7 +2233,7 @@ void CL_NextDownload(void)
22332233
// A download has finished, check whether this matches a referenced checksum
22342234
if(*clc.downloadName)
22352235
{
2236-
char *zippath = FS_BaseDir_BuildOSPath(Cvar_VariableString("fs_homepath"), clc.downloadName);
2236+
char *zippath = FS_BaseDir_BuildOSPath(Cvar_VariableString("fs_homedatapath"), clc.downloadName);
22372237

22382238
if(!FS_CompareZipChecksum(zippath))
22392239
Com_Error(ERR_DROP, "Incorrect checksum for file: %s", clc.downloadName);
@@ -2977,7 +2977,7 @@ void CL_Frame ( int msec ) {
29772977
clc.download = 0;
29782978
}
29792979

2980-
FS_BaseDir_Rename(clc.downloadTempName, clc.downloadName, qfalse);
2980+
FS_BaseDir_Rename_HomeData(clc.downloadTempName, clc.downloadName, qfalse);
29812981
clc.downloadRestart = qtrue;
29822982
CL_NextDownload();
29832983
}
@@ -3307,7 +3307,7 @@ void CL_InitRef( void ) {
33073307
ri.FS_FreeFileList = FS_FreeFileList;
33083308
ri.FS_ListFiles = FS_ListFiles;
33093309
ri.FS_FileIsInPAK = FS_FileIsInPAK;
3310-
ri.FS_FileExists = FS_FileExists;
3310+
ri.FS_FileExists = FS_FileExists_HomeData;
33113311
ri.Cvar_Get = Cvar_Get;
33123312
ri.Cvar_Set = Cvar_Set;
33133313
ri.Cvar_SetValue = Cvar_SetValue;
@@ -3418,7 +3418,7 @@ void CL_Video_f( void )
34183418
Com_sprintf( filename, MAX_OSPATH, "videos/video%d%d%d%d.avi",
34193419
a, b, c, d );
34203420

3421-
if( !FS_FileExists( filename ) )
3421+
if( !FS_FileExists_HomeData( filename ) )
34223422
break; // file doesn't exist
34233423
}
34243424

@@ -3471,7 +3471,7 @@ static void CL_GenerateQKey(void)
34713471
Com_Printf( "QKEY building random string\n" );
34723472
Com_RandomBytes( buff, sizeof(buff) );
34733473

3474-
f = FS_BaseDir_FOpenFileWrite( QKEY_FILE );
3474+
f = FS_BaseDir_FOpenFileWrite_HomeState( QKEY_FILE );
34753475
if( !f ) {
34763476
Com_Printf( "QKEY could not open %s for write\n",
34773477
QKEY_FILE );

code/client/cl_parse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ void CL_ParseDownload ( msg_t *msg ) {
608608
// open the file if not opened yet
609609
if (!clc.download)
610610
{
611-
clc.download = FS_BaseDir_FOpenFileWrite( clc.downloadTempName );
611+
clc.download = FS_BaseDir_FOpenFileWrite_HomeData( clc.downloadTempName );
612612

613613
if (!clc.download) {
614614
Com_Printf( "Could not create %s\n", clc.downloadTempName );
@@ -635,7 +635,7 @@ void CL_ParseDownload ( msg_t *msg ) {
635635
clc.download = 0;
636636

637637
// rename the file
638-
FS_BaseDir_Rename ( clc.downloadTempName, clc.downloadName, qfalse );
638+
FS_BaseDir_Rename_HomeData ( clc.downloadTempName, clc.downloadName, qfalse );
639639
}
640640

641641
// send intentions now

code/client/cl_ui.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ LAN_SaveServersToCache
7474
*/
7575
void LAN_SaveServersToCache( void ) {
7676
int size;
77-
fileHandle_t fileOut = FS_BaseDir_FOpenFileWrite("servercache.dat");
77+
fileHandle_t fileOut = FS_BaseDir_FOpenFileWrite_HomeState("servercache.dat");
7878
FS_Write(&cls.numglobalservers, sizeof(int), fileOut);
7979
FS_Write(&cls.numfavoriteservers, sizeof(int), fileOut);
8080
size = sizeof(cls.globalServers) + sizeof(cls.favoriteServers);

code/qcommon/common.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void QDECL Com_Printf( const char *fmt, ... ) {
205205
time( &aclock );
206206
newtime = localtime( &aclock );
207207

208-
logfile = FS_FOpenFileWrite( "qconsole.log" );
208+
logfile = FS_FOpenFileWrite_HomeData( "qconsole.log" );
209209

210210
if(logfile)
211211
{
@@ -1917,8 +1917,8 @@ void Com_InitJournaling( void ) {
19171917

19181918
if ( com_journal->integer == 1 ) {
19191919
Com_Printf( "Journaling events\n");
1920-
com_journalFile = FS_FOpenFileWrite( "journal.dat" );
1921-
com_journalDataFile = FS_FOpenFileWrite( "journaldata.dat" );
1920+
com_journalFile = FS_FOpenFileWrite_HomeState( "journal.dat" );
1921+
com_journalDataFile = FS_FOpenFileWrite_HomeState( "journaldata.dat" );
19221922
} else if ( com_journal->integer == 2 ) {
19231923
Com_Printf( "Replaying journaled events\n");
19241924
FS_FOpenFileRead( "journal.dat", &com_journalFile, qtrue );
@@ -2543,7 +2543,7 @@ static void Com_WriteCDKey( const char *filename, const char *ikey ) {
25432543
#ifndef _WIN32
25442544
savedumask = umask(0077);
25452545
#endif
2546-
f = FS_BaseDir_FOpenFileWrite( fbuffer );
2546+
f = FS_BaseDir_FOpenFileWrite_HomeState( fbuffer );
25472547
if ( !f ) {
25482548
Com_Printf ("Couldn't write CD key to %s.\n", fbuffer );
25492549
goto out;
@@ -2917,7 +2917,7 @@ void Com_ReadFromPipe( void )
29172917
void Com_WriteConfigToFile( const char *filename ) {
29182918
fileHandle_t f;
29192919

2920-
f = FS_FOpenFileWrite( filename );
2920+
f = FS_FOpenFileWrite_HomeConfig( filename );
29212921
if ( !f ) {
29222922
Com_Printf ("Couldn't write %s.\n", filename );
29232923
return;
@@ -3289,7 +3289,7 @@ void Com_Shutdown (void) {
32893289

32903290
if( pipefile ) {
32913291
FS_FCloseFile( pipefile );
3292-
FS_HomeRemove( com_pipefile->string );
3292+
FS_Remove_HomeData( com_pipefile->string );
32933293
}
32943294

32953295
}

0 commit comments

Comments
 (0)