Commit d5fd3094 authored by Max Kellermann's avatar Max Kellermann

db/update/IO: pass std::string_view to directory_child_is_regular()

parent 6197b29a
...@@ -66,7 +66,7 @@ DirectoryExists(Storage &storage, const Directory &directory) noexcept ...@@ -66,7 +66,7 @@ DirectoryExists(Storage &storage, const Directory &directory) noexcept
static StorageFileInfo static StorageFileInfo
GetDirectoryChildInfo(Storage &storage, const Directory &directory, GetDirectoryChildInfo(Storage &storage, const Directory &directory,
const char *name_utf8) std::string_view name_utf8)
{ {
const auto uri_utf8 = PathTraitsUTF8::Build(directory.GetPath(), const auto uri_utf8 = PathTraitsUTF8::Build(directory.GetPath(),
name_utf8); name_utf8);
...@@ -75,7 +75,7 @@ GetDirectoryChildInfo(Storage &storage, const Directory &directory, ...@@ -75,7 +75,7 @@ GetDirectoryChildInfo(Storage &storage, const Directory &directory,
bool bool
directory_child_is_regular(Storage &storage, const Directory &directory, directory_child_is_regular(Storage &storage, const Directory &directory,
const char *name_utf8) noexcept std::string_view name_utf8) noexcept
try { try {
return GetDirectoryChildInfo(storage, directory, name_utf8) return GetDirectoryChildInfo(storage, directory, name_utf8)
.IsRegular(); .IsRegular();
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "util/Compiler.h" #include "util/Compiler.h"
#include <string_view>
struct Directory; struct Directory;
struct StorageFileInfo; struct StorageFileInfo;
class Storage; class Storage;
...@@ -48,7 +50,7 @@ DirectoryExists(Storage &storage, const Directory &directory) noexcept; ...@@ -48,7 +50,7 @@ DirectoryExists(Storage &storage, const Directory &directory) noexcept;
gcc_pure gcc_pure
bool bool
directory_child_is_regular(Storage &storage, const Directory &directory, directory_child_is_regular(Storage &storage, const Directory &directory,
const char *name_utf8) noexcept; std::string_view name_utf8) noexcept;
/** /**
* Checks if the given permissions on the mapped file are given. * Checks if the given permissions on the mapped file are given.
......
...@@ -103,7 +103,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept ...@@ -103,7 +103,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept
directory.ForEachSongSafe([&](Song &song){ directory.ForEachSongSafe([&](Song &song){
if (!directory_child_is_regular(storage, directory, if (!directory_child_is_regular(storage, directory,
song.filename.c_str())) { song.filename)) {
editor.LockDeleteSong(directory, &song); editor.LockDeleteSong(directory, &song);
modified = true; modified = true;
...@@ -113,8 +113,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept ...@@ -113,8 +113,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept
for (auto i = directory.playlists.begin(), for (auto i = directory.playlists.begin(),
end = directory.playlists.end(); end = directory.playlists.end();
i != end;) { i != end;) {
if (!directory_child_is_regular(storage, directory, if (!directory_child_is_regular(storage, directory, i->name)) {
i->name.c_str())) {
const ScopeDatabaseLock protect; const ScopeDatabaseLock protect;
i = directory.playlists.erase(i); i = directory.playlists.erase(i);
} else } else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment