mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-22 01:45:19 +01:00
filesystem: fix updating gameinfo.txt from rodir
This commit is contained in:
parent
3f724b6b17
commit
9994c57796
@ -1078,29 +1078,39 @@ static qboolean FS_ParseGameInfo( const char *gamedir, gameinfo_t *GameInfo )
|
|||||||
roGameInfoTime = FS_SysFileTime( gameinfo_ro );
|
roGameInfoTime = FS_SysFileTime( gameinfo_ro );
|
||||||
rwGameInfoTime = FS_SysFileTime( gameinfo_path );
|
rwGameInfoTime = FS_SysFileTime( gameinfo_path );
|
||||||
|
|
||||||
|
// if rodir's liblist.gam newer than rwdir's gameinfo.txt, then convert it
|
||||||
if( roLibListTime > rwGameInfoTime )
|
if( roLibListTime > rwGameInfoTime )
|
||||||
{
|
{
|
||||||
haveUpdate = FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_ro );
|
haveUpdate = FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_ro );
|
||||||
}
|
}
|
||||||
|
// if rodir's gameinfo.txt newer than rwdir's gameinfo.txt, just copy the file
|
||||||
else if( roGameInfoTime > rwGameInfoTime )
|
else if( roGameInfoTime > rwGameInfoTime )
|
||||||
{
|
{
|
||||||
fs_offset_t len;
|
file_t *ro, *rw;
|
||||||
char *afile_ro = (char *)FS_LoadDirectFile( gameinfo_ro, &len );
|
fs_offset_t ro_size;
|
||||||
|
|
||||||
if( afile_ro )
|
// read & write as binary to copy the exact file
|
||||||
{
|
ro = FS_SysOpen( gameinfo_ro, "rb" );
|
||||||
Con_DPrintf( "Copy rodir %s to rwdir %s\n", gameinfo_ro, gameinfo_path );
|
rw = FS_SysOpen( gameinfo_path, "wb" );
|
||||||
haveUpdate = true;
|
|
||||||
FS_WriteFile( gameinfo_path, afile_ro, len );
|
FS_Seek( ro, 0, SEEK_END );
|
||||||
Mem_Free( afile_ro );
|
ro_size = FS_Tell( ro );
|
||||||
}
|
FS_Seek( ro, 0, SEEK_SET );
|
||||||
|
|
||||||
|
FS_FileCopy( rw, ro, ro_size );
|
||||||
|
|
||||||
|
FS_Close( rw );
|
||||||
|
FS_Close( ro );
|
||||||
|
|
||||||
|
haveUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FS_AllowDirectPaths( false );
|
FS_AllowDirectPaths( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do not update gameinfo.txt, if it was just copied from rodir's
|
||||||
// if user change liblist.gam update the gameinfo.txt
|
// if user change liblist.gam update the gameinfo.txt
|
||||||
if( FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false ))
|
if( !haveUpdate && FS_FileTime( liblist_path, false ) > FS_FileTime( gameinfo_path, false ))
|
||||||
FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_path );
|
FS_ConvertGameInfo( gamedir, gameinfo_path, liblist_path );
|
||||||
|
|
||||||
// force to create gameinfo for specified game if missing
|
// force to create gameinfo for specified game if missing
|
||||||
|
Loading…
Reference in New Issue
Block a user