| 7 | }; |
| 8 | |
| 9 | CFGParser::CFGParser(const char* path){ |
| 10 | cfgFile = fopen(path, "r"); |
| 11 | |
| 12 | if(!cfgFile){ |
| 13 | printf("CFGParser: Failed to open %s!\n", path); |
| 14 | return; |
| 15 | } |
| 16 | |
| 17 | fseek(cfgFile, 0, SEEK_END); |
| 18 | |
| 19 | size_t cfgSize = ftell(cfgFile); |
| 20 | |
| 21 | if(cfgSize <= 0x8000){ |
| 22 | cfgData.resize(cfgSize); |
| 23 | |
| 24 | fseek(cfgFile, 0, SEEK_SET); |
| 25 | |
| 26 | fread(cfgData.data(), cfgSize, 1, cfgFile); |
| 27 | } else { |
| 28 | char buf[512]; |
| 29 | while(fread(buf, 512, 1, cfgFile)){ |
| 30 | cfgData.insert(cfgData.end(), buf, buf + 512); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | CFGParser::~CFGParser(){ |
| 36 | if(cfgFile){ |