int pakfire_mkdir(const char* path, mode_t mode);
FILE* pakfire_mktemp(char* path, const mode_t mode);
char* pakfire_mkdtemp(char* path);
+int pakfire_symlink(struct pakfire_ctx* ctx, const char* target, const char* linkpath);
int pakfire_rmtree(const char* path, int flags);
#define pakfire_which(pakfire, path, what) \
return mkdtemp(path);
}
+int pakfire_symlink(struct pakfire_ctx* ctx, const char* target, const char* linkpath) {
+ char path[PATH_MAX];
+ int r;
+
+ // Find the dirname of the target
+ r = pakfire_path_dirname(path, target);
+ if (r)
+ return r;
+
+ // Make the symlink relative
+ r = pakfire_path_relative(path, path, linkpath);
+ if (r)
+ return r;
+
+ CTX_DEBUG(ctx, "Creating symlink %s -> %s (%s)\n", target, linkpath, path);
+
+ // Create the symlink
+ r = symlink(target, path);
+ if (r) {
+ CTX_ERROR(ctx, "Could not create symlink %s (%s)\n", target, path);
+ return r;
+ }
+
+ return 0;
+}
+
static int _unlink(const char* path, const struct stat* stat,
const int type, struct FTW* ftwbuf) {
// Delete directories using rmdir()