summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.c14
-rw-r--r--snac.h3
2 files changed, 12 insertions, 5 deletions
diff --git a/data.c b/data.c
index 1febf7a..bb31096 100644
--- a/data.c
+++ b/data.c
@@ -185,14 +185,20 @@ d_char *user_list(void)
185} 185}
186 186
187 187
188double mtime(const char *fn) 188double 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}
diff --git a/snac.h b/snac.h
index aad4697..a9c8606 100644
--- a/snac.h
+++ b/snac.h
@@ -50,7 +50,8 @@ int check_password(char *uid, char *passwd, char *hash);
50void srv_archive(char *direction, char *req, char *payload, int p_size, 50void 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
53double mtime(const char *fn); 53double mtime_nl(const char *fn, int *n_link);
54#define mtime(fn) mtime_nl(fn, NULL)
54 55
55int index_add(const char *fn, const char *md5); 56int index_add(const char *fn, const char *md5);
56int index_del(const char *fn, const char *md5); 57int index_del(const char *fn, const char *md5);