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.
This commit is contained in:
Max Kellermann
2019-09-04 11:20:18 +02:00
parent a727150c8d
commit 7775691965
8 changed files with 16 additions and 15 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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