diff --git a/Jupiter/File.cpp b/Jupiter/File.cpp index b672130..d077b27 100644 --- a/Jupiter/File.cpp +++ b/Jupiter/File.cpp @@ -131,13 +131,38 @@ bool Jupiter::File::load(const Jupiter::ReadableString &file) bool Jupiter::File::load(FILE *file) { - bool success = false; - char buffer[defaultBufferSize]; - - while (!feof(file)) - success |= Jupiter::File::addData(Jupiter::ReferenceString(buffer, fread(buffer, sizeof(char), sizeof(buffer), file))); - - return success; + Jupiter::String buffer(defaultBufferSize); + int c; + + for (;;) + { + c = fgetc(file); + if (c == EOF) + return false; + if (containsSymbol(ENDL, static_cast(c))) + { + Jupiter::File::data_->lines.add(new Jupiter::StringS(buffer)); + buffer.truncate(buffer.size()); + break; + } + else + buffer.concat(static_cast(c)); + } + for (;;) + { + c = fgetc(file); + if (c == EOF) + return true; + if (containsSymbol(ENDL, static_cast(c))) + { + Jupiter::File::data_->lines.add(new Jupiter::StringS(buffer)); + buffer.truncate(buffer.size()); + } + else + buffer.concat(static_cast(c)); + } + + return false; } void Jupiter::File::unload() diff --git a/Release/Jupiter.lib b/Release/Jupiter.lib index 810108f..f9f589f 100644 Binary files a/Release/Jupiter.lib and b/Release/Jupiter.lib differ