| 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 | { |