diff --git a/zip_file.hpp b/zip_file.hpp index c324f70..3d02b8e 100644 --- a/zip_file.hpp +++ b/zip_file.hpp @@ -5183,7 +5183,10 @@ class zip_file void load(std::istream &stream) { reset(); - buffer_.assign(std::istreambuf_iterator(stream), std::istreambuf_iterator()); + stream.seekg(0, std::ios::end); + buffer_.resize(stream.tellg()); + stream.seekg(0); + stream.read(buffer_.data(), buffer_.size()); remove_comment(); start_read(); } @@ -5621,7 +5624,7 @@ class zip_file { if(!comment.empty()) { - auto comment_length = std::min(static_cast(comment.length()), std::numeric_limits::max()); + auto comment_length = (std::min)(static_cast(comment.length()), (std::numeric_limits::max)()); buffer_[buffer_.size() - 2] = static_cast(comment_length); buffer_[buffer_.size() - 1] = static_cast(comment_length >> 8); std::copy(comment.begin(), comment.end(), std::back_inserter(buffer_));