dav/system.c

changeset 789
378b5ab86f77
parent 747
efbd59642577
equal deleted inserted replaced
788:9b9420041d8e 789:378b5ab86f77
29 #include <libidav/utils.h> 29 #include <libidav/utils.h>
30 30
31 #include <stdio.h> 31 #include <stdio.h>
32 #include <stdlib.h> 32 #include <stdlib.h>
33 #include <string.h> 33 #include <string.h>
34 #include <dirent.h>
35 #include <sys/stat.h> 34 #include <sys/stat.h>
36 #include <sys/types.h> 35 #include <sys/types.h>
37 #include <errno.h> 36 #include <errno.h>
38 37
39 #include <cx/string.h> 38 #include <cx/string.h>
161 return 1; 160 return 1;
162 } 161 }
163 return sys_symlink(target, linkpath); 162 return sys_symlink(target, linkpath);
164 } 163 }
165 return err; 164 return err;
165 }
166
167 int sys_truncate(const char* path, off_t length) {
168 return truncate(path, length);
166 } 169 }
167 170
168 #else 171 #else
169 /* ---------- Windows implementation ---------- */ 172 /* ---------- Windows implementation ---------- */
170 173
505 free(wlinkpath); 508 free(wlinkpath);
506 509
507 return ret; 510 return ret;
508 } 511 }
509 512
513 int sys_truncate(const char* path, off_t length) {
514 wchar_t* wpath = path2winpath(path, FALSE, NULL);
515 if (!wpath) {
516 fprintf(stderr, "sys_truncate: cannot convert path\n");
517 return -1;
518 }
519
520 FILE* file = _wfopen(wpath, L"wb");
521 int ret = 1;
522 if (file) {
523 ret = _chsize(fileno(file), length);
524 fclose(file);
525 }
526
527 free(wpath);
528 return ret;
529 }
530
510 #endif 531 #endif

mercurial