Crash log: Save config file in new crash save chunk

This commit is contained in:
Jonathan G Rennison
2020-04-21 18:17:13 +01:00
parent 850f860f2d
commit eef6ad7b2a
13 changed files with 90 additions and 10 deletions

View File

@@ -207,7 +207,7 @@ void IniLoadFile::RemoveGroup(const char *name)
* @param subdir the sub directory to load the file from.
* @pre nothing has been loaded yet.
*/
void IniLoadFile::LoadFromDisk(const char *filename, Subdirectory subdir)
void IniLoadFile::LoadFromDisk(const char *filename, Subdirectory subdir, std::string *save)
{
assert(this->last_group == &this->group);
@@ -222,10 +222,16 @@ void IniLoadFile::LoadFromDisk(const char *filename, Subdirectory subdir)
FILE *in = this->OpenFile(filename, subdir, &end);
if (in == nullptr) return;
if (save != nullptr) {
save->clear();
save->reserve(end);
}
end += ftell(in);
/* for each line in the file */
while ((size_t)ftell(in) < end && fgets(buffer, sizeof(buffer), in)) {
if (save != nullptr) *save += buffer;
char c, *s;
/* trim whitespace from the left side */
for (s = buffer; *s == ' ' || *s == '\t'; s++) {}