diff options
| author | 2022-11-25 13:33:13 +0100 | |
|---|---|---|
| committer | 2022-11-25 13:33:13 +0100 | |
| commit | 2d7c327cbf08a7ebc12df2818289af5d923c48de (patch) | |
| tree | 600f9ea61567e392fa8fde749a98c58b94af963e /data.c | |
| parent | Also call object_del() on a renewed actor in actor_request(). (diff) | |
| download | snac2-2d7c327cbf08a7ebc12df2818289af5d923c48de.tar.gz snac2-2d7c327cbf08a7ebc12df2818289af5d923c48de.tar.xz snac2-2d7c327cbf08a7ebc12df2818289af5d923c48de.zip | |
New function mtime_nl().
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 14 |
1 files changed, 10 insertions, 4 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 | } |