31:59cdf7b7316f | 32:c9d37bb97ea8 |
---|---|
32 #include <errno.h> | 32 #include <errno.h> |
33 #include <unistd.h> | 33 #include <unistd.h> |
34 #include <time.h> | 34 #include <time.h> |
35 #include <libxml/xmlerror.h> | 35 #include <libxml/xmlerror.h> |
36 #include <sys/types.h> | 36 #include <sys/types.h> |
37 #include <sys/stat.h> | |
38 #include <ucx/string.h> | 37 #include <ucx/string.h> |
39 #include <dirent.h> | 38 #include <dirent.h> |
40 | 39 |
41 | 40 |
42 #include "utils.h" | 41 #include "utils.h" |
278 | 277 |
279 static char* ls_date_str(time_t tm) { | 278 static char* ls_date_str(time_t tm) { |
280 struct tm t; | 279 struct tm t; |
281 struct tm n; | 280 struct tm n; |
282 time_t now = time(NULL); | 281 time_t now = time(NULL); |
282 #ifdef _WIN32 | |
283 memcpy(&t, localtime(&tm), sizeof(struct tm)); | |
284 memcpy(&n, localtime(&now), sizeof(struct tm)); | |
285 #else | |
283 localtime_r(&tm, &t); | 286 localtime_r(&tm, &t); |
284 localtime_r(&now, &n); | 287 localtime_r(&now, &n); |
288 #endif /* _WIN32 */ | |
285 char *str = malloc(16); | 289 char *str = malloc(16); |
286 if(t.tm_year == n.tm_year) { | 290 if(t.tm_year == n.tm_year) { |
287 strftime(str, 16, "%b %d %H:%M", &t); | 291 strftime(str, 16, "%b %d %H:%M", &t); |
288 } else { | 292 } else { |
289 strftime(str, 16, "%b %d %Y", &t); | 293 strftime(str, 16, "%b %d %Y", &t); |
519 | 523 |
520 if(res->iscollection) { | 524 if(res->iscollection) { |
521 // create directory | 525 // create directory |
522 if(outlen != 0) { | 526 if(outlen != 0) { |
523 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; | 527 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; |
524 int ret = mkdir(out, mode); | 528 int ret = util_mkdir(out, mode); |
525 if(ret != 0 && errno != EEXIST) { | 529 if(ret != 0 && errno != EEXIST) { |
526 return 1; | 530 return 1; |
527 } | 531 } |
528 } | 532 } |
529 | 533 |