storage/Interface: wrap StorageDirectoryReader in std::unique_ptr
This commit is contained in:
@@ -60,7 +60,7 @@ public:
|
||||
/* virtual methods from class Storage */
|
||||
StorageFileInfo GetInfo(const char *uri_utf8, bool follow) override;
|
||||
|
||||
StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override;
|
||||
std::unique_ptr<StorageDirectoryReader> OpenDirectory(const char *uri_utf8) override;
|
||||
|
||||
std::string MapUTF8(const char *uri_utf8) const noexcept override;
|
||||
|
||||
@@ -474,14 +474,14 @@ public:
|
||||
:PropfindOperation(curl, uri, 1),
|
||||
base_path(UriPathOrSlash(uri)) {}
|
||||
|
||||
StorageDirectoryReader *Perform() {
|
||||
std::unique_ptr<StorageDirectoryReader> Perform() {
|
||||
Wait();
|
||||
return ToReader();
|
||||
}
|
||||
|
||||
private:
|
||||
StorageDirectoryReader *ToReader() {
|
||||
return new MemoryStorageDirectoryReader(std::move(entries));
|
||||
std::unique_ptr<StorageDirectoryReader> ToReader() {
|
||||
return std::make_unique<MemoryStorageDirectoryReader>(std::move(entries));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -534,7 +534,7 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
StorageDirectoryReader *
|
||||
std::unique_ptr<StorageDirectoryReader>
|
||||
CurlStorage::OpenDirectory(const char *uri_utf8)
|
||||
{
|
||||
// TODO: escape the given URI
|
||||
|
@@ -59,7 +59,7 @@ public:
|
||||
/* virtual methods from class Storage */
|
||||
StorageFileInfo GetInfo(const char *uri_utf8, bool follow) override;
|
||||
|
||||
StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override;
|
||||
std::unique_ptr<StorageDirectoryReader> OpenDirectory(const char *uri_utf8) override;
|
||||
|
||||
std::string MapUTF8(const char *uri_utf8) const noexcept override;
|
||||
|
||||
@@ -140,10 +140,10 @@ LocalStorage::GetInfo(const char *uri_utf8, bool follow)
|
||||
return Stat(MapFSOrThrow(uri_utf8), follow);
|
||||
}
|
||||
|
||||
StorageDirectoryReader *
|
||||
std::unique_ptr<StorageDirectoryReader>
|
||||
LocalStorage::OpenDirectory(const char *uri_utf8)
|
||||
{
|
||||
return new LocalDirectoryReader(MapFSOrThrow(uri_utf8));
|
||||
return std::make_unique<LocalDirectoryReader>(MapFSOrThrow(uri_utf8));
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
|
@@ -88,7 +88,7 @@ public:
|
||||
/* virtual methods from class Storage */
|
||||
StorageFileInfo GetInfo(const char *uri_utf8, bool follow) override;
|
||||
|
||||
StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override;
|
||||
std::unique_ptr<StorageDirectoryReader> OpenDirectory(const char *uri_utf8) override;
|
||||
|
||||
std::string MapUTF8(const char *uri_utf8) const noexcept override;
|
||||
|
||||
@@ -334,8 +334,8 @@ public:
|
||||
const char *_path)
|
||||
:BlockingNfsOperation(_connection), path(_path) {}
|
||||
|
||||
StorageDirectoryReader *ToReader() {
|
||||
return new MemoryStorageDirectoryReader(std::move(entries));
|
||||
std::unique_ptr<StorageDirectoryReader> ToReader() {
|
||||
return std::make_unique<MemoryStorageDirectoryReader>(std::move(entries));
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -377,7 +377,7 @@ NfsListDirectoryOperation::CollectEntries(struct nfsdir *dir)
|
||||
}
|
||||
}
|
||||
|
||||
StorageDirectoryReader *
|
||||
std::unique_ptr<StorageDirectoryReader>
|
||||
NfsStorage::OpenDirectory(const char *uri_utf8)
|
||||
{
|
||||
const std::string path = UriToNfsPath(uri_utf8);
|
||||
|
@@ -67,7 +67,7 @@ public:
|
||||
/* virtual methods from class Storage */
|
||||
StorageFileInfo GetInfo(const char *uri_utf8, bool follow) override;
|
||||
|
||||
StorageDirectoryReader *OpenDirectory(const char *uri_utf8) override;
|
||||
std::unique_ptr<StorageDirectoryReader> OpenDirectory(const char *uri_utf8) override;
|
||||
|
||||
std::string MapUTF8(const char *uri_utf8) const noexcept override;
|
||||
|
||||
@@ -124,7 +124,7 @@ SmbclientStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow)
|
||||
return ::GetInfo(mapped.c_str());
|
||||
}
|
||||
|
||||
StorageDirectoryReader *
|
||||
std::unique_ptr<StorageDirectoryReader>
|
||||
SmbclientStorage::OpenDirectory(const char *uri_utf8)
|
||||
{
|
||||
std::string mapped = MapUTF8(uri_utf8);
|
||||
@@ -138,7 +138,8 @@ SmbclientStorage::OpenDirectory(const char *uri_utf8)
|
||||
throw MakeErrno("Failed to open directory");
|
||||
}
|
||||
|
||||
return new SmbclientDirectoryReader(std::move(mapped.c_str()), handle);
|
||||
return std::make_unique<SmbclientDirectoryReader>(std::move(mapped.c_str()),
|
||||
handle);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
|
Reference in New Issue
Block a user