577:f49964cf7228 | 578:bb1e60fada74 |
---|---|
30 #include <stdlib.h> | 30 #include <stdlib.h> |
31 #include <string.h> | 31 #include <string.h> |
32 #include <dirent.h> | 32 #include <dirent.h> |
33 #include <sys/stat.h> | 33 #include <sys/stat.h> |
34 #include <sys/types.h> | 34 #include <sys/types.h> |
35 #include <errno.h> | |
35 | 36 |
36 #ifndef _WIN32 | 37 #ifndef _WIN32 |
37 #include <unistd.h> | 38 #include <unistd.h> |
38 #endif | 39 #endif |
39 | 40 |
107 return mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); | 108 return mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); |
108 } | 109 } |
109 | 110 |
110 ssize_t sys_readlink(const char *path, char *buffer, size_t size) { | 111 ssize_t sys_readlink(const char *path, char *buffer, size_t size) { |
111 return readlink(path, buffer, size); | 112 return readlink(path, buffer, size); |
113 } | |
114 | |
115 int sys_symlink(const char *target, const char *linkpath) { | |
116 int err = symlink(target, linkpath); | |
117 if(err && errno == EEXIST) { | |
118 if(unlink(linkpath)) { | |
119 return 1; | |
120 } | |
121 return sys_symlink(target, linkpath); | |
122 } | |
123 return err; | |
112 } | 124 } |
113 | 125 |
114 #else | 126 #else |
115 /* ---------- Windows implementation ---------- */ | 127 /* ---------- Windows implementation ---------- */ |
116 | 128 |
292 // TODO | 304 // TODO |
293 fprintf(stderr, "sys_readlink: implement me\n"); | 305 fprintf(stderr, "sys_readlink: implement me\n"); |
294 return 1; | 306 return 1; |
295 } | 307 } |
296 | 308 |
309 int sys_symlink(const char *target, const char *linkpath) { | |
310 // TODO | |
311 fprintf(stderr, "sys_symlink: implement me\n"); | |
312 return 1; | |
313 } | |
314 | |
297 #endif | 315 #endif |