Crash log: Save config file in new crash save chunk
This commit is contained in:
@@ -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++) {}
|
||||
|
Reference in New Issue
Block a user