diff --git a/src/browser.cpp b/src/browser.cpp index b36644e8..ecb16555 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -498,7 +498,10 @@ void Browser::GetLocalDirectory(MPD::ItemList &v, const std::string &directory, item.song = std::shared_ptr(s); # ifdef HAVE_TAGLIB_H if (!recursively) + { + s->setMTime(fs::last_write_time(e.path())); Tags::read(*s); + } # endif // HAVE_TAGLIB_H v.push_back(item); } diff --git a/src/mutable_song.cpp b/src/mutable_song.cpp index cdbb8877..3c3cc7c0 100644 --- a/src/mutable_song.cpp +++ b/src/mutable_song.cpp @@ -160,12 +160,24 @@ unsigned MutableSong::getDuration() const return Song::getDuration(); } +time_t MutableSong::getMTime() const +{ + if (m_mtime > 0) + return m_mtime; + else + return Song::getMTime(); +} void MutableSong::setDuration(unsigned int duration) { m_duration = duration; } +void MutableSong::setMTime(time_t mtime) +{ + m_mtime = mtime; +} + void MutableSong::setTags(SetFunction set, const std::string &value, const std::string &delimiter) { std::vector tags; diff --git a/src/mutable_song.h b/src/mutable_song.h index 9879afe3..f9672786 100644 --- a/src/mutable_song.h +++ b/src/mutable_song.h @@ -30,8 +30,8 @@ struct MutableSong : public Song { typedef void (MutableSong::*SetFunction)(const std::string &, unsigned); - MutableSong() : m_duration(0) { } - MutableSong(Song s) : Song(s), m_duration(0) { } + MutableSong() : m_mtime(0), m_duration(0) { } + MutableSong(Song s) : Song(s), m_mtime(0), m_duration(0) { } virtual std::string getArtist(unsigned idx = 0) const; virtual std::string getTitle(unsigned idx = 0) const; @@ -61,7 +61,9 @@ struct MutableSong : public Song void setNewURI(const std::string &value); virtual unsigned getDuration() const; + virtual time_t getMTime() const; void setDuration(unsigned duration); + void setMTime(time_t mtime); void setTags(SetFunction set, const std::string &value, const std::string &delimiter); @@ -103,6 +105,7 @@ private: } std::string m_uri; + time_t m_mtime; unsigned m_duration; std::map m_tags; };