src/lib/cache.c
changeset 54 4a25113cb2a4
parent 53 8a3165c604f8
child 55 a3542e78ecd8
--- a/src/lib/cache.c	Sun Jan 24 23:04:55 2010 +0200
+++ b/src/lib/cache.c	Sun Jan 24 23:17:10 2010 +0200
@@ -69,6 +69,7 @@
 
 int pt_cache_info (struct pt_cache *cache, struct pt_image_info *info)
 {
+    struct stat st;
     int err;
 
     // ensure open
@@ -78,6 +79,20 @@
     info->width = cache->header->width;
     info->height = cache->header->height;
 
+    // stat
+    if (stat(cache->path, &st) < 0) {
+        // unknown
+        info->cache_mtime = 0;
+        info->cache_bytes = 0;
+        info->cache_blocks = 0;
+
+    } else {
+        // store
+        info->cache_mtime = st.st_mtime;
+        info->cache_bytes = st.st_size;
+        info->cache_blocks = st.st_blocks;
+    }
+
     return 0;
 }