aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory_save.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-28 14:02:00 +0100
committerMax Kellermann <max@duempel.org>2009-02-28 14:02:00 +0100
commit2aebbf84606fa6fa5a014ac288eef9bc5d63402e (patch)
tree84d7e8071fe6e8f76e587e31d470d2a2b6b1b686 /src/directory_save.c
parent3d6e6416e50a05d937ae770f255b53aa2dc5201f (diff)
downloadmpd-2aebbf84606fa6fa5a014ac288eef9bc5d63402e.tar.gz
mpd-2aebbf84606fa6fa5a014ac288eef9bc5d63402e.tar.xz
mpd-2aebbf84606fa6fa5a014ac288eef9bc5d63402e.zip
directory: added "mtime" property
Remember the modification time of each directory. This is important for archives (which are virtual directories right now), but may also be useful for an automatic update mechanism.
Diffstat (limited to 'src/directory_save.c')
-rw-r--r--src/directory_save.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/directory_save.c b/src/directory_save.c
index 7b2668bc7..b009b1ef5 100644
--- a/src/directory_save.c
+++ b/src/directory_save.c
@@ -28,7 +28,7 @@
#include <assert.h>
#include <string.h>
-#define DIRECTORY_MTIME "mtime: " /* DEPRECATED, noop-read-only */
+#define DIRECTORY_MTIME "mtime: "
#define DIRECTORY_BEGIN "begin: "
#define DIRECTORY_END "end: "
@@ -41,6 +41,9 @@ directory_save(FILE *fp, struct directory *directory)
int retv;
if (!directory_is_root(directory)) {
+ fprintf(fp, DIRECTORY_MTIME "%lu\n",
+ (unsigned long)directory->mtime);
+
retv = fprintf(fp, "%s%s\n", DIRECTORY_BEGIN,
directory_get_path(directory));
if (retv < 0)
@@ -84,8 +87,12 @@ directory_load(FILE *fp, struct directory *directory)
strcpy(key, &(buffer[strlen(DIRECTORY_DIR)]));
if (!fgets(buffer, sizeof(buffer), fp))
FATAL("Error reading db, fgets\n");
- /* for compatibility with db's prior to 0.11 */
+
if (g_str_has_prefix(buffer, DIRECTORY_MTIME)) {
+ directory->mtime =
+ g_ascii_strtoull(buffer + sizeof(DIRECTORY_MTIME) - 1,
+ NULL, 10);
+
if (!fgets(buffer, sizeof(buffer), fp))
FATAL("Error reading db, fgets\n");
}