DetachedSong, db/LightSong, db/simple/Song: use std::chrono::system_clock::time_point
This commit is contained in:
@@ -24,8 +24,7 @@
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <time.h>
|
||||
#include <chrono>
|
||||
|
||||
struct Tag;
|
||||
|
||||
@@ -62,7 +61,11 @@ struct LightSong {
|
||||
*/
|
||||
const Tag *tag;
|
||||
|
||||
time_t mtime;
|
||||
/**
|
||||
* The time stamp of the last file modification. A negative
|
||||
* value means that this is unknown/unavailable.
|
||||
*/
|
||||
std::chrono::system_clock::time_point mtime;
|
||||
|
||||
/**
|
||||
* Start of this sub-song within the file.
|
||||
|
||||
@@ -197,7 +197,11 @@ ProxySong::ProxySong(const mpd_song *song)
|
||||
uri = mpd_song_get_uri(song);
|
||||
real_uri = nullptr;
|
||||
tag = &tag2;
|
||||
mtime = mpd_song_get_last_modified(song);
|
||||
|
||||
const auto _mtime = mpd_song_get_last_modified(song);
|
||||
mtime = _mtime > 0
|
||||
? std::chrono::system_clock::from_time_t(_mtime)
|
||||
: std::chrono::system_clock::time_point::min();
|
||||
|
||||
#if LIBMPDCLIENT_CHECK_VERSION(2,3,0)
|
||||
start_time = SongTime::FromS(mpd_song_get_start(song));
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <string.h>
|
||||
|
||||
inline Song::Song(const char *_uri, size_t uri_length, Directory &_parent)
|
||||
:parent(&_parent), mtime(0),
|
||||
:parent(&_parent), mtime(std::chrono::system_clock::time_point::min()),
|
||||
start_time(SongTime::zero()), end_time(SongTime::zero())
|
||||
{
|
||||
memcpy(uri, _uri, uri_length + 1);
|
||||
|
||||
@@ -70,7 +70,11 @@ struct Song {
|
||||
*/
|
||||
Directory *const parent;
|
||||
|
||||
time_t mtime;
|
||||
/**
|
||||
* The time stamp of the last file modification. A negative
|
||||
* value means that this is unknown/unavailable.
|
||||
*/
|
||||
std::chrono::system_clock::time_point mtime;
|
||||
|
||||
/**
|
||||
* Start of this sub-song within the file.
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
uri = uri2.c_str();
|
||||
real_uri = real_uri2.c_str();
|
||||
tag = &tag2;
|
||||
mtime = 0;
|
||||
mtime = std::chrono::system_clock::time_point::min();
|
||||
start_time = end_time = SongTime::zero();
|
||||
}
|
||||
};
|
||||
@@ -314,7 +314,7 @@ visitSong(const UPnPDirObject &meta, const char *path,
|
||||
song.uri = path;
|
||||
song.real_uri = meta.url.c_str();
|
||||
song.tag = &meta.tag;
|
||||
song.mtime = 0;
|
||||
song.mtime = std::chrono::system_clock::time_point::min();
|
||||
song.start_time = song.end_time = SongTime::zero();
|
||||
|
||||
if (selection.Match(song))
|
||||
|
||||
@@ -107,7 +107,7 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
|
||||
*contdir);
|
||||
|
||||
// shouldn't be necessary but it's there..
|
||||
song->mtime = std::chrono::system_clock::to_time_t(info.mtime);
|
||||
song->mtime = info.mtime;
|
||||
|
||||
FormatDefault(update_domain, "added %s/%s",
|
||||
contdir->GetPath(), song->uri);
|
||||
|
||||
@@ -51,9 +51,7 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(song != nullptr &&
|
||||
std::chrono::system_clock::to_time_t(info.mtime) == song->mtime &&
|
||||
!walk_discard) &&
|
||||
if (!(song != nullptr && info.mtime == song->mtime && !walk_discard) &&
|
||||
UpdateContainerFile(directory, name, suffix, info)) {
|
||||
if (song != nullptr)
|
||||
editor.LockDeleteSong(directory, song);
|
||||
@@ -80,7 +78,7 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
|
||||
modified = true;
|
||||
FormatDefault(update_domain, "added %s/%s",
|
||||
directory.GetPath(), name);
|
||||
} else if (std::chrono::system_clock::to_time_t(info.mtime) != song->mtime || walk_discard) {
|
||||
} else if (info.mtime != song->mtime || walk_discard) {
|
||||
FormatDefault(update_domain, "updating %s/%s",
|
||||
directory.GetPath(), name);
|
||||
if (!song->UpdateFile(storage)) {
|
||||
|
||||
Reference in New Issue
Block a user