summaryrefslogtreecommitdiff
path: root/src/archive/plugins/Iso9660ArchivePlugin.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/archive/plugins/Iso9660ArchivePlugin.cxx')
-rw-r--r--src/archive/plugins/Iso9660ArchivePlugin.cxx35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/archive/plugins/Iso9660ArchivePlugin.cxx b/src/archive/plugins/Iso9660ArchivePlugin.cxx
index 6cb307bd4..ddf81aa2d 100644
--- a/src/archive/plugins/Iso9660ArchivePlugin.cxx
+++ b/src/archive/plugins/Iso9660ArchivePlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2020 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -35,7 +35,13 @@
#include <stdlib.h>
#include <string.h>
-#define CEILING(x, y) ((x+(y-1))/y)
+#include <utility>
+
+static constexpr size_t
+CEILING(size_t x, size_t y) noexcept
+{
+ return (x + y - 1) / y;
+}
struct Iso9660 {
iso9660_t *const iso;
@@ -63,7 +69,7 @@ class Iso9660ArchiveFile final : public ArchiveFile {
std::shared_ptr<Iso9660> iso;
public:
- Iso9660ArchiveFile(std::shared_ptr<Iso9660> &&_iso)
+ explicit Iso9660ArchiveFile(std::shared_ptr<Iso9660> &&_iso)
:iso(std::move(_iso)) {}
/**
@@ -72,7 +78,7 @@ public:
void Visit(char *path, size_t length, size_t capacity,
ArchiveVisitor &visitor);
- virtual void Visit(ArchiveVisitor &visitor) override;
+ void Visit(ArchiveVisitor &visitor) override;
InputStreamPtr OpenStream(const char *path,
Mutex &mutex) override;
@@ -145,23 +151,29 @@ class Iso9660InputStream final : public InputStream {
iso9660_stat_t *statbuf;
public:
- Iso9660InputStream(const std::shared_ptr<Iso9660> &_iso,
+ Iso9660InputStream(std::shared_ptr<Iso9660> _iso,
const char *_uri,
Mutex &_mutex,
iso9660_stat_t *_statbuf)
:InputStream(_uri, _mutex),
- iso(_iso), statbuf(_statbuf) {
+ iso(std::move(_iso)), statbuf(_statbuf) {
size = statbuf->size;
+ seekable = true;
SetReady();
}
- ~Iso9660InputStream() {
+ ~Iso9660InputStream() override {
free(statbuf);
}
/* virtual methods from InputStream */
- bool IsEOF() noexcept override;
- size_t Read(void *ptr, size_t size) override;
+ bool IsEOF() const noexcept override;
+ size_t Read(std::unique_lock<Mutex> &lock,
+ void *ptr, size_t size) override;
+
+ void Seek(std::unique_lock<Mutex> &, offset_type new_offset) override {
+ offset = new_offset;
+ }
};
InputStreamPtr
@@ -178,7 +190,8 @@ Iso9660ArchiveFile::OpenStream(const char *pathname,
}
size_t
-Iso9660InputStream::Read(void *ptr, size_t read_size)
+Iso9660InputStream::Read(std::unique_lock<Mutex> &,
+ void *ptr, size_t read_size)
{
const ScopeUnlock unlock(mutex);
@@ -212,7 +225,7 @@ Iso9660InputStream::Read(void *ptr, size_t read_size)
}
bool
-Iso9660InputStream::IsEOF() noexcept
+Iso9660InputStream::IsEOF() const noexcept
{
return offset == size;
}