MCPcopy Create free account
hub / github.com/cuberite/cuberite / WriteFile

Method WriteFile

lib/inifile/iniFile.cpp:188–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186
187
188bool cIniFile::WriteFile(const AString & a_FileName) const
189{
190 // Normally you would use ofstream, but the SGI CC compiler has
191 // a few bugs with ofstream. So ... fstream used.
192 fstream f;
193
194 f.open((FILE_IO_PREFIX + a_FileName).c_str(), ios::out);
195 if (f.fail())
196 {
197 return false;
198 }
199
200 // Write header comments.
201 size_t NumComments = comments.size();
202 for (size_t commentID = 0; commentID < NumComments; ++commentID)
203 {
204 f << ';' << comments[commentID] << iniEOL;
205 }
206 if (NumComments > 0)
207 {
208 f << iniEOL;
209 }
210
211 // Write keys and values.
212 for (size_t keyID = 0; keyID < keys.size(); ++keyID)
213 {
214 f << '[' << names[keyID] << ']' << iniEOL;
215
216 // Comments.
217 for (size_t commentID = 0; commentID < keys[keyID].comments.size(); ++commentID)
218 {
219 f << ';' << keys[keyID].comments[commentID] << iniEOL;
220 }
221
222 // Values.
223 for (size_t valueID = 0; valueID < keys[keyID].names.size(); ++valueID)
224 {
225 f << keys[keyID].names[valueID] << '=' << keys[keyID].values[valueID] << iniEOL;
226 }
227 f << iniEOL;
228 }
229 f.close();
230
231 return true;
232}
233
234
235

Callers 7

StartMethod · 0.80
LoadGroupsMethod · 0.80
InitMethod · 0.80
InitializeSpawnMethod · 0.80
StartMethod · 0.80
InitBiomeViewMethod · 0.80

Calls 2

c_strMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected