equal
deleted
inserted
replaced
5 #include "error.h" |
5 #include "error.h" |
6 #include "shared/util.h" |
6 #include "shared/util.h" |
7 #include "shared/log.h" |
7 #include "shared/log.h" |
8 |
8 |
9 #include <stdlib.h> |
9 #include <stdlib.h> |
|
10 #include <sys/stat.h> |
|
11 #include <unistd.h> |
10 #include <errno.h> |
12 #include <errno.h> |
11 |
13 |
12 #include <png.h> |
14 #include <png.h> |
13 |
15 |
14 static int pt_image_new (struct pt_image **image_ptr, struct pt_ctx *ctx, const char *path) |
16 static int pt_image_new (struct pt_image **image_ptr, struct pt_ctx *ctx, const char *path) |
202 return err; |
204 return err; |
203 } |
205 } |
204 |
206 |
205 int pt_image_info (struct pt_image *image, const struct pt_image_info **info_ptr) |
207 int pt_image_info (struct pt_image *image, const struct pt_image_info **info_ptr) |
206 { |
208 { |
|
209 struct stat st; |
207 int err; |
210 int err; |
208 |
211 |
209 // update info |
212 // update info |
210 if ((err = pt_cache_info(image->cache, &image->info))) |
213 if ((err = pt_cache_info(image->cache, &image->info))) |
211 return err; |
214 return err; |
|
215 |
|
216 // stat our info |
|
217 if (stat(image->path, &st) < 0) { |
|
218 // unknown |
|
219 image->info.image_mtime = 0; |
|
220 image->info.image_bytes = 0; |
|
221 |
|
222 } else { |
|
223 // store |
|
224 image->info.image_mtime = st.st_mtime; |
|
225 image->info.image_bytes = st.st_size; |
|
226 } |
212 |
227 |
213 // return pointer |
228 // return pointer |
214 *info_ptr = &image->info; |
229 *info_ptr = &image->info; |
215 |
230 |
216 return 0; |
231 return 0; |