started working on ini parser
This commit is contained in:
49
tests/ini/main.cpp
Normal file
49
tests/ini/main.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#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"));
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user