Merge branch 'v0.21.x' into master

This commit is contained in:
Max Kellermann
2020-09-04 18:35:21 +02:00
17 changed files with 185 additions and 110 deletions

View File

@@ -148,24 +148,22 @@ Iso9660ArchiveFile::Visit(ArchiveVisitor &visitor)
class Iso9660InputStream final : public InputStream {
std::shared_ptr<Iso9660> iso;
iso9660_stat_t *statbuf;
const lsn_t lsn;
public:
Iso9660InputStream(std::shared_ptr<Iso9660> _iso,
const char *_uri,
Mutex &_mutex,
iso9660_stat_t *_statbuf)
lsn_t _lsn, offset_type _size)
:InputStream(_uri, _mutex),
iso(std::move(_iso)), statbuf(_statbuf) {
size = statbuf->size;
iso(std::move(_iso)),
lsn(_lsn)
{
size = _size;
seekable = true;
SetReady();
}
~Iso9660InputStream() override {
free(statbuf);
}
/* virtual methods from InputStream */
[[nodiscard]] bool IsEOF() const noexcept override;
size_t Read(std::unique_lock<Mutex> &lock,
@@ -185,8 +183,12 @@ Iso9660ArchiveFile::OpenStream(const char *pathname,
throw FormatRuntimeError("not found in the ISO file: %s",
pathname);
const lsn_t lsn = statbuf->lsn;
const offset_type size = statbuf->size;
free(statbuf);
return std::make_unique<Iso9660InputStream>(iso, pathname, mutex,
statbuf);
lsn, size);
}
size_t
@@ -197,7 +199,7 @@ Iso9660InputStream::Read(std::unique_lock<Mutex> &,
int readed = 0;
int no_blocks, cur_block;
size_t left_bytes = statbuf->size - offset;
size_t left_bytes = size - offset;
if (left_bytes < read_size) {
no_blocks = CEILING(left_bytes, ISO_BLOCKSIZE);
@@ -210,7 +212,7 @@ Iso9660InputStream::Read(std::unique_lock<Mutex> &,
cur_block = offset / ISO_BLOCKSIZE;
readed = iso->SeekRead(ptr, statbuf->lsn + cur_block, no_blocks);
readed = iso->SeekRead(ptr, lsn + cur_block, no_blocks);
if (readed != no_blocks * ISO_BLOCKSIZE)
throw FormatRuntimeError("error reading ISO file at lsn %lu",