Additional Laptop files (by sun_alf).

Example file: https://github.com/sun-alf/BRAINMOD-o/blob/master/Data-BRAINMOD/TableData/Laptop/AdditionalFiles.xml

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9363 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2022-04-13 10:43:49 +00:00
parent 186a722519
commit 67d5aeadb0
11 changed files with 503 additions and 143 deletions
+35
View File
@@ -57,6 +57,7 @@ using namespace std;
#ifdef USE_VFS
#include <vfs/Core/vfs_file_raii.h>
#include <vfs/Tools/vfs_parser_tools.h>
#include <map>
struct SOperation
@@ -780,6 +781,40 @@ BOOLEAN FileRead( HWFILE hFile, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiByte
#endif
}
BOOLEAN FileReadLine( HWFILE hFile, std::string* pDest )
{
#ifdef USE_VFS
vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile;
if ( pFile && FileCheckEndOfFile( hFile ) == FALSE && (s_mapFiles[pFile].op == SOperation::READ) )
{
vfs::tReadableFile *pRF = vfs::tReadableFile::cast( pFile );
if ( pRF && pDest )
{
vfs::CReadLine rl( *pRF, false );
rl.getLine( *pDest );
return TRUE;
}
}
#endif // ifdef USE_VFS
return FALSE;
}
BOOLEAN FileReadLine( HWFILE hFile, STR8 pDest, UINT32 uiDestSize, UINT32 *puiBytesRead )
{
std::string sBuffer;
BOOLEAN result = (pDest != NULL) && FileReadLine( hFile, &sBuffer );
if ( result )
{
if ( puiBytesRead )
*puiBytesRead = sBuffer.length();
UINT32 uiCountToCopy = min( sBuffer.length(), uiDestSize - 1 );
sBuffer.copy( pDest, uiCountToCopy );
pDest[uiCountToCopy] = '\0'; // method copy() does not put a null-terminator
}
return result;
}
//**************************************************************************
//
// FileWrite