}
size_t size;
- if (args.contains("size")) {
- // If user passed 'size' parameter, we need to read at most 'size' bytes.
- double size_double = args.get("size").get<double>();
- if (std::string::npos <= static_cast<unsigned long long>(size_double)) {
- LogAndReportError(InvalidValuesException("Invalid size was given"), out);
- return;
- }
- size = static_cast<size_t>(size_double);
- }
-
// We need to check how many bytes is it possible to read until the EOF.
try {
// We need to read from file exactly the minimum value of 'size' given by user and the
- // 'possible_bytes_to_read' to avoid returning array with redundant data
- // (which would be equal to 0).
- size_t possible_bytes_to_read = file_bytes_to_eof(fh->second->file_handle);
- size = std::min(size, possible_bytes_to_read);
+ // 'size ' to avoid returning array with redundant data (which would be equal to 0).
+ size = file_bytes_to_eof(fh->second->file_handle);
+ if (args.contains("size")) {
+ // If user passed 'size' parameter, we need to read at most 'size' bytes.
+ double size_double = args.get("size").get<double>();
+ if (std::string::npos <= static_cast<unsigned long long>(size_double)) {
+ LogAndReportError(InvalidValuesException("Invalid size was given"), out);
+ return;
+ }
+ size = std::min(static_cast<size_t>(size_double), size);
+ }
} catch (const std::system_error& e) {
LogAndReportError(IOException(e.what()), out);
return;