diff options
| -rw-r--r-- | data.c | 14 | ||||
| -rw-r--r-- | snac.h | 3 |
2 files changed, 12 insertions, 5 deletions
| @@ -185,14 +185,20 @@ d_char *user_list(void) | |||
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | 187 | ||
| 188 | double mtime(const char *fn) | 188 | double mtime_nl(const char *fn, int *n_link) |
| 189 | /* returns the mtime of a file or directory, or 0.0 */ | 189 | /* returns the mtime and number of links of a file or directory, or 0.0 */ |
| 190 | { | 190 | { |
| 191 | struct stat st; | 191 | struct stat st; |
| 192 | double r = 0.0; | 192 | double r = 0.0; |
| 193 | int n = 0; | ||
| 194 | |||
| 195 | if (fn && stat(fn, &st) != -1) { | ||
| 196 | r = (double) st.st_mtim.tv_sec; | ||
| 197 | n = st.st_nlink; | ||
| 198 | } | ||
| 193 | 199 | ||
| 194 | if (fn && stat(fn, &st) != -1) | 200 | if (*n_link) |
| 195 | r = (double)st.st_mtim.tv_sec; | 201 | *n_link = n; |
| 196 | 202 | ||
| 197 | return r; | 203 | return r; |
| 198 | } | 204 | } |
| @@ -50,7 +50,8 @@ int check_password(char *uid, char *passwd, char *hash); | |||
| 50 | void srv_archive(char *direction, char *req, char *payload, int p_size, | 50 | void srv_archive(char *direction, char *req, char *payload, int p_size, |
| 51 | int status, char *headers, char *body, int b_size); | 51 | int status, char *headers, char *body, int b_size); |
| 52 | 52 | ||
| 53 | double mtime(const char *fn); | 53 | double mtime_nl(const char *fn, int *n_link); |
| 54 | #define mtime(fn) mtime_nl(fn, NULL) | ||
| 54 | 55 | ||
| 55 | int index_add(const char *fn, const char *md5); | 56 | int index_add(const char *fn, const char *md5); |
| 56 | int index_del(const char *fn, const char *md5); | 57 | int index_del(const char *fn, const char *md5); |