Files
funnygame/tests/ini/main.cpp
2025-08-20 01:27:25 +03:00

50 lines
1.0 KiB
C++

#include "tier0/lib.h"
#include "tier0/mem.h"
#include "tier1/utlbuffer.h"
#include "tier1/commandline.h"
#include "tier2/fileformats/ini.h"
#include "tier2/ifilesystem.h"
int main( int argc, char **argv )
{
const char *szFileName;
IFileHandle *pHandle = NULL;
size_t nSize = 0;
CUtlBuffer<char> szData;
CommandLine()->CreateCommandLine(argc, argv);
filesystem->Init();
// Get file
szFileName = CommandLine()->ParamValue("-f");
if (!szFileName)
return 0;
// Load it
pHandle = filesystem->Open(szFileName, FILEMODE_READ);
if (!pHandle)
return 0;
// Get size
pHandle->Seek(SEEKMODE_RELATIVE_END, 0);
nSize = pHandle->Tell();
pHandle->Seek(SEEKMODE_RELATIVE_START, 0);
// Read it
szData = CUtlBuffer<char>(nSize+1);
pHandle->Read(szData, nSize);
pHandle->Close();
szData[nSize] = 0;
IINIFile *pIniFile = INIManager()->ReadString(szData);
if (!pIniFile)
return 0;
IINISection *pTestValues = pIniFile->GetSection("Test_Values");
if (!pTestValues)
return 0;
V_printf("%s\n",pTestValues->GetStringValue("abc3d"));
};