_current_path = p;
_current_file = fopen_boost (_paths[_current_path], "rb");
if (_current_file == 0) {
- throw OpenFileError (_paths[_current_path], errno, true);
+ throw OpenFileError (_paths[_current_path], errno, OpenFileError::READ);
}
}
if (sub_pos < int64_t (len)) {
break;
}
- sub_pos -= len;
++i;
+ if (i < _paths.size()) {
+ /* If we've run out of files we need to seek off the end of the last file */
+ sub_pos -= len;
+ }
}
if (i == _paths.size ()) {
- return -1;
+ /* Seeking too far isn't an error; we'll seek too far in the last file which
+ * will "pass on" fseek()'s behaviour to our caller.
+ */
+ i--;
}
ensure_open_path (i);