mirror of
https://github.com/1dot13/source.git
synced 2026-08-19 14:20:30 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user