db/update/Walk: add "noexcept"
This commit is contained in:
@@ -39,21 +39,21 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static Directory *
|
static Directory *
|
||||||
LockFindChild(Directory &directory, const char *name)
|
LockFindChild(Directory &directory, const char *name) noexcept
|
||||||
{
|
{
|
||||||
const ScopeDatabaseLock protect;
|
const ScopeDatabaseLock protect;
|
||||||
return directory.FindChild(name);
|
return directory.FindChild(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Directory *
|
static Directory *
|
||||||
LockMakeChild(Directory &directory, const char *name)
|
LockMakeChild(Directory &directory, const char *name) noexcept
|
||||||
{
|
{
|
||||||
const ScopeDatabaseLock protect;
|
const ScopeDatabaseLock protect;
|
||||||
return directory.MakeChild(name);
|
return directory.MakeChild(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Song *
|
static Song *
|
||||||
LockFindSong(Directory &directory, const char *name)
|
LockFindSong(Directory &directory, const char *name) noexcept
|
||||||
{
|
{
|
||||||
const ScopeDatabaseLock protect;
|
const ScopeDatabaseLock protect;
|
||||||
return directory.FindSong(name);
|
return directory.FindSong(name);
|
||||||
@@ -61,7 +61,7 @@ LockFindSong(Directory &directory, const char *name)
|
|||||||
|
|
||||||
void
|
void
|
||||||
UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory,
|
UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory,
|
||||||
const char *name)
|
const char *name) noexcept
|
||||||
{
|
{
|
||||||
const char *tmp = strchr(name, '/');
|
const char *tmp = strchr(name, '/');
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
@@ -112,7 +112,7 @@ class UpdateArchiveVisitor final : public ArchiveVisitor {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
UpdateArchiveVisitor(UpdateWalk &_walk, ArchiveFile &_archive,
|
UpdateArchiveVisitor(UpdateWalk &_walk, ArchiveFile &_archive,
|
||||||
Directory *_directory)
|
Directory *_directory) noexcept
|
||||||
:walk(_walk), archive(_archive), directory(_directory) {}
|
:walk(_walk), archive(_archive), directory(_directory) {}
|
||||||
|
|
||||||
virtual void VisitArchiveEntry(const char *path_utf8) override {
|
virtual void VisitArchiveEntry(const char *path_utf8) override {
|
||||||
@@ -133,7 +133,7 @@ class UpdateArchiveVisitor final : public ArchiveVisitor {
|
|||||||
void
|
void
|
||||||
UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
|
UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
|
||||||
const StorageFileInfo &info,
|
const StorageFileInfo &info,
|
||||||
const ArchivePlugin &plugin)
|
const ArchivePlugin &plugin) noexcept
|
||||||
{
|
{
|
||||||
Directory *directory = LockFindChild(parent, name);
|
Directory *directory = LockFindChild(parent, name);
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
|
|||||||
bool
|
bool
|
||||||
UpdateWalk::UpdateArchiveFile(Directory &directory,
|
UpdateWalk::UpdateArchiveFile(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info)
|
const StorageFileInfo &info) noexcept
|
||||||
{
|
{
|
||||||
const ArchivePlugin *plugin = archive_plugin_from_suffix(suffix);
|
const ArchivePlugin *plugin = archive_plugin_from_suffix(suffix);
|
||||||
if (plugin == nullptr)
|
if (plugin == nullptr)
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
Directory *
|
Directory *
|
||||||
UpdateWalk::MakeDirectoryIfModified(Directory &parent, const char *name,
|
UpdateWalk::MakeDirectoryIfModified(Directory &parent, const char *name,
|
||||||
const StorageFileInfo &info)
|
const StorageFileInfo &info) noexcept
|
||||||
{
|
{
|
||||||
Directory *directory = parent.FindChild(name);
|
Directory *directory = parent.FindChild(name);
|
||||||
|
|
||||||
@@ -57,7 +57,8 @@ UpdateWalk::MakeDirectoryIfModified(Directory &parent, const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
SupportsContainerSuffix(const DecoderPlugin &plugin, const char *suffix)
|
SupportsContainerSuffix(const DecoderPlugin &plugin,
|
||||||
|
const char *suffix) noexcept
|
||||||
{
|
{
|
||||||
return plugin.container_scan != nullptr &&
|
return plugin.container_scan != nullptr &&
|
||||||
plugin.SupportsSuffix(suffix);
|
plugin.SupportsSuffix(suffix);
|
||||||
@@ -66,7 +67,7 @@ SupportsContainerSuffix(const DecoderPlugin &plugin, const char *suffix)
|
|||||||
bool
|
bool
|
||||||
UpdateWalk::UpdateContainerFile(Directory &directory,
|
UpdateWalk::UpdateContainerFile(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info)
|
const StorageFileInfo &info) noexcept
|
||||||
{
|
{
|
||||||
const DecoderPlugin *_plugin = decoder_plugins_find([suffix](const DecoderPlugin &plugin){
|
const DecoderPlugin *_plugin = decoder_plugins_find([suffix](const DecoderPlugin &plugin){
|
||||||
return SupportsContainerSuffix(plugin, suffix);
|
return SupportsContainerSuffix(plugin, suffix);
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
inline void
|
inline void
|
||||||
UpdateWalk::UpdateSongFile2(Directory &directory,
|
UpdateWalk::UpdateSongFile2(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info)
|
const StorageFileInfo &info) noexcept
|
||||||
{
|
{
|
||||||
Song *song;
|
Song *song;
|
||||||
{
|
{
|
||||||
@@ -95,7 +95,7 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
|
|||||||
bool
|
bool
|
||||||
UpdateWalk::UpdateSongFile(Directory &directory,
|
UpdateWalk::UpdateSongFile(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info)
|
const StorageFileInfo &info) noexcept
|
||||||
{
|
{
|
||||||
if (!decoder_plugins_supports_suffix(suffix))
|
if (!decoder_plugins_supports_suffix(suffix))
|
||||||
return false;
|
return false;
|
||||||
|
@@ -50,7 +50,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
UpdateWalk::UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
|
UpdateWalk::UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
|
||||||
Storage &_storage)
|
Storage &_storage) noexcept
|
||||||
:cancel(false),
|
:cancel(false),
|
||||||
storage(_storage),
|
storage(_storage),
|
||||||
editor(_loop, _listener)
|
editor(_loop, _listener)
|
||||||
@@ -75,7 +75,7 @@ directory_set_stat(Directory &dir, const StorageFileInfo &info)
|
|||||||
|
|
||||||
inline void
|
inline void
|
||||||
UpdateWalk::RemoveExcludedFromDirectory(Directory &directory,
|
UpdateWalk::RemoveExcludedFromDirectory(Directory &directory,
|
||||||
const ExcludeList &exclude_list)
|
const ExcludeList &exclude_list) noexcept
|
||||||
{
|
{
|
||||||
const ScopeDatabaseLock protect;
|
const ScopeDatabaseLock protect;
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ UpdateWalk::RemoveExcludedFromDirectory(Directory &directory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
UpdateWalk::PurgeDeletedFromDirectory(Directory &directory)
|
UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept
|
||||||
{
|
{
|
||||||
directory.ForEachChildSafe([&](Directory &child){
|
directory.ForEachChildSafe([&](Directory &child){
|
||||||
if (child.IsMount() || DirectoryExists(storage, child))
|
if (child.IsMount() || DirectoryExists(storage, child))
|
||||||
@@ -135,7 +135,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory)
|
|||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static bool
|
static bool
|
||||||
update_directory_stat(Storage &storage, Directory &directory)
|
update_directory_stat(Storage &storage, Directory &directory) noexcept
|
||||||
{
|
{
|
||||||
StorageFileInfo info;
|
StorageFileInfo info;
|
||||||
if (!GetInfo(storage, directory.GetPath(), info))
|
if (!GetInfo(storage, directory.GetPath(), info))
|
||||||
@@ -154,7 +154,7 @@ update_directory_stat(Storage &storage, Directory &directory)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
FindAncestorLoop(Storage &storage, Directory *parent,
|
FindAncestorLoop(Storage &storage, Directory *parent,
|
||||||
unsigned inode, unsigned device)
|
unsigned inode, unsigned device) noexcept
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (device == 0 && inode == 0)
|
if (device == 0 && inode == 0)
|
||||||
@@ -187,7 +187,7 @@ FindAncestorLoop(Storage &storage, Directory *parent,
|
|||||||
inline bool
|
inline bool
|
||||||
UpdateWalk::UpdatePlaylistFile(Directory &directory,
|
UpdateWalk::UpdatePlaylistFile(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info)
|
const StorageFileInfo &info) noexcept
|
||||||
{
|
{
|
||||||
if (!playlist_suffix_supported(suffix))
|
if (!playlist_suffix_supported(suffix))
|
||||||
return false;
|
return false;
|
||||||
@@ -202,7 +202,8 @@ UpdateWalk::UpdatePlaylistFile(Directory &directory,
|
|||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
UpdateWalk::UpdateRegularFile(Directory &directory,
|
UpdateWalk::UpdateRegularFile(Directory &directory,
|
||||||
const char *name, const StorageFileInfo &info)
|
const char *name,
|
||||||
|
const StorageFileInfo &info) noexcept
|
||||||
{
|
{
|
||||||
const char *suffix = uri_get_suffix(name);
|
const char *suffix = uri_get_suffix(name);
|
||||||
if (suffix == nullptr)
|
if (suffix == nullptr)
|
||||||
@@ -216,7 +217,7 @@ UpdateWalk::UpdateRegularFile(Directory &directory,
|
|||||||
void
|
void
|
||||||
UpdateWalk::UpdateDirectoryChild(Directory &directory,
|
UpdateWalk::UpdateDirectoryChild(Directory &directory,
|
||||||
const ExcludeList &exclude_list,
|
const ExcludeList &exclude_list,
|
||||||
const char *name, const StorageFileInfo &info)
|
const char *name, const StorageFileInfo &info) noexcept
|
||||||
try {
|
try {
|
||||||
assert(strchr(name, '/') == nullptr);
|
assert(strchr(name, '/') == nullptr);
|
||||||
|
|
||||||
@@ -328,7 +329,7 @@ UpdateWalk::SkipSymlink(const Directory *directory,
|
|||||||
bool
|
bool
|
||||||
UpdateWalk::UpdateDirectory(Directory &directory,
|
UpdateWalk::UpdateDirectory(Directory &directory,
|
||||||
const ExcludeList &exclude_list,
|
const ExcludeList &exclude_list,
|
||||||
const StorageFileInfo &info)
|
const StorageFileInfo &info) noexcept
|
||||||
{
|
{
|
||||||
assert(info.IsDirectory());
|
assert(info.IsDirectory());
|
||||||
|
|
||||||
@@ -390,7 +391,7 @@ UpdateWalk::UpdateDirectory(Directory &directory,
|
|||||||
inline Directory *
|
inline Directory *
|
||||||
UpdateWalk::DirectoryMakeChildChecked(Directory &parent,
|
UpdateWalk::DirectoryMakeChildChecked(Directory &parent,
|
||||||
const char *uri_utf8,
|
const char *uri_utf8,
|
||||||
const char *name_utf8)
|
const char *name_utf8) noexcept
|
||||||
{
|
{
|
||||||
Directory *directory;
|
Directory *directory;
|
||||||
{
|
{
|
||||||
@@ -429,7 +430,8 @@ UpdateWalk::DirectoryMakeChildChecked(Directory &parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Directory *
|
inline Directory *
|
||||||
UpdateWalk::DirectoryMakeUriParentChecked(Directory &root, const char *uri)
|
UpdateWalk::DirectoryMakeUriParentChecked(Directory &root,
|
||||||
|
const char *uri) noexcept
|
||||||
{
|
{
|
||||||
Directory *directory = &root;
|
Directory *directory = &root;
|
||||||
char *duplicated = xstrdup(uri);
|
char *duplicated = xstrdup(uri);
|
||||||
@@ -455,7 +457,7 @@ UpdateWalk::DirectoryMakeUriParentChecked(Directory &root, const char *uri)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
UpdateWalk::UpdateUri(Directory &root, const char *uri)
|
UpdateWalk::UpdateUri(Directory &root, const char *uri) noexcept
|
||||||
try {
|
try {
|
||||||
Directory *parent = DirectoryMakeUriParentChecked(root, uri);
|
Directory *parent = DirectoryMakeUriParentChecked(root, uri);
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
@@ -482,7 +484,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
UpdateWalk::Walk(Directory &root, const char *path, bool discard)
|
UpdateWalk::Walk(Directory &root, const char *path, bool discard) noexcept
|
||||||
{
|
{
|
||||||
walk_discard = discard;
|
walk_discard = discard;
|
||||||
modified = false;
|
modified = false;
|
||||||
|
@@ -62,20 +62,20 @@ class UpdateWalk final {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
|
UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
|
||||||
Storage &_storage);
|
Storage &_storage) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel the current update and quit the Walk() method as
|
* Cancel the current update and quit the Walk() method as
|
||||||
* soon as possible.
|
* soon as possible.
|
||||||
*/
|
*/
|
||||||
void Cancel() {
|
void Cancel() noexcept {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the database was modified.
|
* Returns true if the database was modified.
|
||||||
*/
|
*/
|
||||||
bool Walk(Directory &root, const char *path, bool discard);
|
bool Walk(Directory &root, const char *path, bool discard) noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gcc_pure
|
gcc_pure
|
||||||
@@ -83,60 +83,60 @@ private:
|
|||||||
const char *utf8_name) const noexcept;
|
const char *utf8_name) const noexcept;
|
||||||
|
|
||||||
void RemoveExcludedFromDirectory(Directory &directory,
|
void RemoveExcludedFromDirectory(Directory &directory,
|
||||||
const ExcludeList &exclude_list);
|
const ExcludeList &exclude_list) noexcept;
|
||||||
|
|
||||||
void PurgeDeletedFromDirectory(Directory &directory);
|
void PurgeDeletedFromDirectory(Directory &directory) noexcept;
|
||||||
|
|
||||||
void UpdateSongFile2(Directory &directory,
|
void UpdateSongFile2(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info);
|
const StorageFileInfo &info) noexcept;
|
||||||
|
|
||||||
bool UpdateSongFile(Directory &directory,
|
bool UpdateSongFile(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info);
|
const StorageFileInfo &info) noexcept;
|
||||||
|
|
||||||
bool UpdateContainerFile(Directory &directory,
|
bool UpdateContainerFile(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info);
|
const StorageFileInfo &info) noexcept;
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
void UpdateArchiveTree(ArchiveFile &archive, Directory &parent,
|
void UpdateArchiveTree(ArchiveFile &archive, Directory &parent,
|
||||||
const char *name);
|
const char *name) noexcept;
|
||||||
|
|
||||||
bool UpdateArchiveFile(Directory &directory,
|
bool UpdateArchiveFile(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info);
|
const StorageFileInfo &info) noexcept;
|
||||||
|
|
||||||
void UpdateArchiveFile(Directory &directory, const char *name,
|
void UpdateArchiveFile(Directory &directory, const char *name,
|
||||||
const StorageFileInfo &info,
|
const StorageFileInfo &info,
|
||||||
const ArchivePlugin &plugin);
|
const ArchivePlugin &plugin) noexcept;
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
bool UpdateArchiveFile(gcc_unused Directory &directory,
|
bool UpdateArchiveFile(gcc_unused Directory &directory,
|
||||||
gcc_unused const char *name,
|
gcc_unused const char *name,
|
||||||
gcc_unused const char *suffix,
|
gcc_unused const char *suffix,
|
||||||
gcc_unused const StorageFileInfo &info) {
|
gcc_unused const StorageFileInfo &info) noexcept {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool UpdatePlaylistFile(Directory &directory,
|
bool UpdatePlaylistFile(Directory &directory,
|
||||||
const char *name, const char *suffix,
|
const char *name, const char *suffix,
|
||||||
const StorageFileInfo &info);
|
const StorageFileInfo &info) noexcept;
|
||||||
|
|
||||||
bool UpdateRegularFile(Directory &directory,
|
bool UpdateRegularFile(Directory &directory,
|
||||||
const char *name, const StorageFileInfo &info);
|
const char *name, const StorageFileInfo &info) noexcept;
|
||||||
|
|
||||||
void UpdateDirectoryChild(Directory &directory,
|
void UpdateDirectoryChild(Directory &directory,
|
||||||
const ExcludeList &exclude_list,
|
const ExcludeList &exclude_list,
|
||||||
const char *name,
|
const char *name,
|
||||||
const StorageFileInfo &info);
|
const StorageFileInfo &info) noexcept;
|
||||||
|
|
||||||
bool UpdateDirectory(Directory &directory,
|
bool UpdateDirectory(Directory &directory,
|
||||||
const ExcludeList &exclude_list,
|
const ExcludeList &exclude_list,
|
||||||
const StorageFileInfo &info);
|
const StorageFileInfo &info) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the specified directory object if it does not exist
|
* Create the specified directory object if it does not exist
|
||||||
@@ -147,16 +147,16 @@ private:
|
|||||||
* The caller must lock the database.
|
* The caller must lock the database.
|
||||||
*/
|
*/
|
||||||
Directory *MakeDirectoryIfModified(Directory &parent, const char *name,
|
Directory *MakeDirectoryIfModified(Directory &parent, const char *name,
|
||||||
const StorageFileInfo &info);
|
const StorageFileInfo &info) noexcept;
|
||||||
|
|
||||||
Directory *DirectoryMakeChildChecked(Directory &parent,
|
Directory *DirectoryMakeChildChecked(Directory &parent,
|
||||||
const char *uri_utf8,
|
const char *uri_utf8,
|
||||||
const char *name_utf8);
|
const char *name_utf8) noexcept;
|
||||||
|
|
||||||
Directory *DirectoryMakeUriParentChecked(Directory &root,
|
Directory *DirectoryMakeUriParentChecked(Directory &root,
|
||||||
const char *uri);
|
const char *uri) noexcept;
|
||||||
|
|
||||||
void UpdateUri(Directory &root, const char *uri);
|
void UpdateUri(Directory &root, const char *uri) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user