MCPcopy Create free account
hub / github.com/ZDoom/Raze / WriteConfigFile

Method WriteConfigFile

source/common/utility/configfile.cpp:781–827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

779//====================================================================
780
781bool FConfigFile::WriteConfigFile () const
782{
783 if (!OkayToWrite && FileExisted)
784 { // Pretend it was written anyway so that the user doesn't get
785 // any "config not written" notifications, but only if the file
786 // already existed. Otherwise, let it write out a default one.
787 return true;
788 }
789
790 FileWriter *file = FileWriter::Open (PathName.GetChars());
791 FConfigSection *section;
792 FConfigEntry *entry;
793
794 if (file == NULL)
795 return false;
796
797 WriteCommentHeader (file);
798
799 section = Sections;
800 while (section != NULL)
801 {
802 entry = section->RootEntry;
803 if (section->Note.IsNotEmpty())
804 {
805 file->Write (section->Note.GetChars(), section->Note.Len());
806 }
807 file->Printf ("[%s]\n", section->SectionName.GetChars());
808 while (entry != NULL)
809 {
810 if (strpbrk(entry->Value, "\r\n") == NULL)
811 { // Single-line value
812 file->Printf ("%s=%s\n", entry->Key, entry->Value);
813 }
814 else
815 { // Multi-line value
816 const char *endtag = GenerateEndTag(entry->Value);
817 file->Printf ("%s=<<<%s\n%s\n>>>%s\n", entry->Key,
818 endtag, entry->Value, endtag);
819 }
820 entry = entry->Next;
821 }
822 section = section->Next;
823 file->Write ("\n", 1);
824 }
825 delete file;
826 return true;
827}
828
829//====================================================================
830//

Callers 2

G_SaveConfigFunction · 0.80
SaveGainsFunction · 0.80

Calls 6

OpenFunction · 0.85
IsNotEmptyMethod · 0.80
LenMethod · 0.80
PrintfMethod · 0.80
GetCharsMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected