aboutsummaryrefslogtreecommitdiff
path: root/source/10-common/Utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/10-common/Utils.cpp')
-rw-r--r--source/10-common/Utils.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/10-common/Utils.cpp b/source/10-common/Utils.cpp
index dc76b0a..f0ff76d 100644
--- a/source/10-common/Utils.cpp
+++ b/source/10-common/Utils.cpp
@@ -77,6 +77,29 @@ std::string Utils::ReadFileAsString(const fs::path& path) {
return result;
}
+bool Utils::ReadCstdioLine(FILE* file, std::string& buffer) {
+ buffer.clear();
+ while (true) {
+ int c = fgetc(file);
+ if (c == EOF) {
+ if (buffer.empty() || buffer.back() != '\n') {
+ buffer += '\n';
+ }
+ return false;
+ } else if (c == '\n') {
+ buffer += '\n';
+ return true;
+ } else {
+ buffer += c;
+ }
+ }
+}
+
+bool Utils::ReadCstdioLine(FILE* file, char* buffer, size_t bufferSize, size_t* outLineLength) {
+ // TODO
+ assert(false && "Unimplemented");
+}
+
bool Utils::InRangeInclusive(int n, int lower, int upper) {
if (lower > upper) {
std::swap(lower, upper);