Commit 77756919 authored by Max Kellermann's avatar Max Kellermann

db/simple/Song: rename "uri" to "filename"

This attribute is not a URI; it is just the filename without its parent directory path. To avoid confusion, let's rename it to "filename", leaving the struct without a "uri" attribute.
parent a727150c
......@@ -51,7 +51,7 @@ range_save(BufferedOutputStream &os, unsigned start_ms, unsigned end_ms)
void
song_save(BufferedOutputStream &os, const Song &song)
{
os.Format(SONG_BEGIN "%s\n", song.uri.c_str());
os.Format(SONG_BEGIN "%s\n", song.filename.c_str());
range_save(os, song.start_time.ToMS(), song.end_time.ToMS());
......
......@@ -110,7 +110,7 @@ Song::UpdateFileInArchive(ArchiveFile &archive) noexcept
{
assert(parent.device == DEVICE_INARCHIVE);
std::string path_utf8(uri);
std::string path_utf8(filename);
for (const Directory *directory = &parent;
directory->parent != nullptr &&
......
......@@ -191,7 +191,7 @@ Directory::FindSong(const char *name_utf8) const noexcept
for (auto &song : songs) {
assert(&song.parent == this);
if (song.uri == name_utf8)
if (song.filename == name_utf8)
return &song;
}
......
......@@ -30,7 +30,7 @@ Song::Song(DetachedSong &&other, Directory &_parent) noexcept
mtime(other.GetLastModified()),
start_time(other.GetStartTime()),
end_time(other.GetEndTime()),
uri(other.GetURI())
filename(other.GetURI())
{
}
......@@ -38,17 +38,17 @@ std::string
Song::GetURI() const noexcept
{
if (parent.IsRoot())
return uri;
return filename;
else {
const char *path = parent.GetPath();
return PathTraitsUTF8::Build(path, uri.c_str());
return PathTraitsUTF8::Build(path, filename.c_str());
}
}
LightSong
Song::Export() const noexcept
{
LightSong dest(uri.c_str(), tag);
LightSong dest(filename.c_str(), tag);
if (!parent.IsRoot())
dest.directory = parent.GetPath();
dest.mtime = mtime;
......
......@@ -91,11 +91,11 @@ struct Song {
/**
* The file name.
*/
std::string uri;
std::string filename;
template<typename U>
Song(U &&_uri, Directory &_parent) noexcept
:parent(_parent), uri(std::forward<U>(_uri)) {}
template<typename F>
Song(F &&_filename, Directory &_parent) noexcept
:parent(_parent), filename(std::forward<F>(_filename)) {}
Song(DetachedSong &&other, Directory &_parent) noexcept;
......
......@@ -96,7 +96,7 @@ song_cmp(const Song &a, const Song &b) noexcept
return ret < 0;
/* still no difference? compare file name */
return IcuCollate(a.uri.c_str(), b.uri.c_str()) < 0;
return IcuCollate(a.filename.c_str(), b.filename.c_str()) < 0;
}
void
......
......@@ -76,7 +76,8 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
song->mtime = info.mtime;
FormatDefault(update_domain, "added %s/%s",
contdir->GetPath(), song->uri.c_str());
contdir->GetPath(),
song->filename.c_str());
{
const ScopeDatabaseLock protect;
......
......@@ -81,7 +81,7 @@ UpdateWalk::RemoveExcludedFromDirectory(Directory &directory,
directory.ForEachSongSafe([&](Song &song){
assert(&song.parent == &directory);
const auto name_fs = AllocatedPath::FromUTF8(song.uri.c_str());
const auto name_fs = AllocatedPath::FromUTF8(song.filename.c_str());
if (name_fs.IsNull() || exclude_list.Check(name_fs)) {
editor.DeleteSong(directory, &song);
modified = true;
......@@ -103,7 +103,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept
directory.ForEachSongSafe([&](Song &song){
if (!directory_child_is_regular(storage, directory,
song.uri.c_str())) {
song.filename.c_str())) {
editor.LockDeleteSong(directory, &song);
modified = true;
......
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