Changeset 1124 for cpp/common/util-file.cpp
- Timestamp:
- 04/11/21 02:08:46 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/util-file.cpp
r888 r1124 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 15Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 87 87 return writeCompleteFile(filename, s, warn_on_fail); 88 88 } 89 90 // Just like fgets(), but string length is unlimited and does not store trailing \r \n 91 string readUntilEOL(VirtFILE *f) 92 { 93 char buf[100]; 94 char* line; 95 std::string ret; 96 bool endofline; 97 while ((line = f->Vgets(buf, sizeof(buf)))) 98 { 99 char* end = line + strlen(line); 100 endofline = false; 101 while (end > line) 102 if ((end[-1] == '\n') || (end[-1] == '\r')) 103 { 104 endofline = true; 105 end--; 106 } 107 else 108 break; 109 ret += std::string(line, end - line); 110 if (endofline) break; 111 } 112 return ret; 113 }
Note: See TracChangeset
for help on using the changeset viewer.