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