Merge branch 'v0.19.x'
This commit is contained in:
@@ -266,22 +266,13 @@ CompositeStorage::FindStorage(const char *uri) const
|
||||
return result;
|
||||
}
|
||||
|
||||
CompositeStorage::FindResult
|
||||
CompositeStorage::FindStorage(const char *uri, Error &error) const
|
||||
{
|
||||
auto result = FindStorage(uri);
|
||||
if (result.directory == nullptr)
|
||||
error.Set(composite_domain, "No such directory");
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositeStorage::GetInfo(const char *uri, bool follow, StorageFileInfo &info,
|
||||
Error &error)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
|
||||
auto f = FindStorage(uri, error);
|
||||
auto f = FindStorage(uri);
|
||||
if (f.directory->storage != nullptr &&
|
||||
f.directory->storage->GetInfo(f.uri, follow, info, error))
|
||||
return true;
|
||||
@@ -296,6 +287,7 @@ CompositeStorage::GetInfo(const char *uri, bool follow, StorageFileInfo &info,
|
||||
return true;
|
||||
}
|
||||
|
||||
error.Set(composite_domain, "No such directory");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -305,13 +297,15 @@ CompositeStorage::OpenDirectory(const char *uri,
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
|
||||
auto f = FindStorage(uri, error);
|
||||
auto f = FindStorage(uri);
|
||||
const Directory *directory = f.directory->Find(f.uri);
|
||||
if (directory == nullptr || directory->children.empty()) {
|
||||
/* no virtual directories here */
|
||||
|
||||
if (f.directory->storage == nullptr)
|
||||
if (f.directory->storage == nullptr) {
|
||||
error.Set(composite_domain, "No such directory");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return f.directory->storage->OpenDirectory(f.uri, error);
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ class CompositeStorage final : public Storage {
|
||||
*/
|
||||
struct Directory {
|
||||
/**
|
||||
* The #Storage mounted n this virtual directory. All
|
||||
* The #Storage mounted in this virtual directory. All
|
||||
* "leaf" Directory instances must have a #Storage.
|
||||
* Other Directory instances may have one, and child
|
||||
* mounts will be "mixed" in.
|
||||
@@ -154,9 +154,16 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow the given URI path, and find the outermost directory
|
||||
* which is a #Storage mount point. If there are no mounts,
|
||||
* it returns the root directory (with a nullptr "storage"
|
||||
* attribute, of course). FindResult::uri contains the
|
||||
* remaining unused part of the URI (may be empty if all of
|
||||
* the URI was used).
|
||||
*/
|
||||
gcc_pure
|
||||
FindResult FindStorage(const char *uri) const;
|
||||
FindResult FindStorage(const char *uri, Error &error) const;
|
||||
|
||||
const char *MapToRelativeUTF8(const Directory &directory,
|
||||
const char *uri) const;
|
||||
|
Reference in New Issue
Block a user