MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / store

Method store

src/openms/source/FORMAT/TextFile.cpp:61–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 }
60
61 void TextFile::store(const String& filename)
62 {
63 ofstream os;
64 // stream not opened in binary mode, thus "\n" will be evaluated platform dependent (e.g. resolve to \r\n on Windows)
65 os.open(filename.c_str(), ofstream::out);
66
67 if (!os)
68 {
69 throw Exception::UnableToCreateFile(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename);
70 }
71
72 for (const String& it : buffer_)
73 {
74 if (it.hasSuffix("\n"))
75 {
76 if (it.hasSuffix("\r\n"))
77 {
78 os << it.chop(2) << "\n";
79 }
80 else
81 {
82 os << it;
83 }
84 }
85 else
86 {
87 os << it << "\n";
88 }
89 }
90 os.close();
91 }
92
93 std::istream& TextFile::getLine(std::istream& is, std::string& t)
94 {

Callers

nothing calls this directly

Calls 4

chopMethod · 0.80
openMethod · 0.45
hasSuffixMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected