MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / WriteFile

Method WriteFile

lib/mdflib/mdflib/src/ixmlfile.cpp:69–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69bool IXmlFile::WriteFile() {
70 if (filename_.empty()) {
71 MDF_ERROR() << "No file name defined";
72 return false;
73 }
74 try {
75 std::ofstream file(fs::u8path(filename_),
76 std::ofstream::out | std::ofstream::trunc);
77 if (!file.is_open()) {
78 MDF_ERROR() << "Couldn't open file for writing. File: " << filename_;
79 return false;
80 }
81
82 // Start with byte order characters if the encoding is UTF-8
83 if (Platform::stricmp(encoding_.c_str(), "UTF-8") == 0) {
84 file << "\xEF\xBB\xBF";
85 }
86 WriteRoot(file, false);
87
88 file.close();
89
90 } catch (const std::exception &err) {
91 MDF_ERROR() << "Failed to write the file. Error: " << err.what()
92 << ", File: " << FileName();
93 return false;
94 }
95 return true;
96}
97
98std::string IXmlFile::WriteString(bool skip_header) {
99 std::ostringstream temp;

Callers

nothing calls this directly

Calls 4

stricmpFunction · 0.85
emptyMethod · 0.80
is_openMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected