diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-03-24 01:09:48 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-03-24 01:09:48 +0300 |
commit | 75906fbb296d2ed7cd9ca05e1b7bf0c92f84a30b (patch) | |
tree | 863208f0605c1b609cf00d1e0e418c923ed40724 /src/fs.c | |
parent | 9297781c79dbfe68a817474d0395001fd9746770 (diff) | |
download | revela-75906fbb296d2ed7cd9ca05e1b7bf0c92f84a30b.tar.gz revela-75906fbb296d2ed7cd9ca05e1b7bf0c92f84a30b.zip |
Switch from unja to roscha
Still a WIP, some bugs need to be fixed.
Also change the license to GPL from LGPL. It was always meant to be GPL,
not sure what brain fart caused this.
Diffstat (limited to 'src/fs.c')
-rw-r--r-- | src/fs.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -2,7 +2,9 @@ #include "log.h" #include "config.h" + #include "vector.h" +#include "slice.h" #include <fcntl.h> #include <stdio.h> @@ -37,7 +39,7 @@ static const char *img_extensions[] = { }; static void -hm_destroy_callback(const void *k, void *v) +hm_destroy_cb(const struct slice *k, void *v) { free(v); } @@ -199,7 +201,7 @@ error: } ssize_t -rmextra(const char *path, struct hashmap *preserved, preremove_fn cb, +rmextra(const char *path, struct hmap *preserved, preremove_fn cb, void *data, bool dry) { ssize_t removed = 0; @@ -212,7 +214,7 @@ rmextra(const char *path, struct hashmap *preserved, preremove_fn cb, continue; } - if (hashmap_get(preserved, ent->d_name) != NULL) continue; + if (hmap_get(preserved, ent->d_name) != NULL) continue; char target[PATH_MAX]; sprintf(target, "%s/%s", path, ent->d_name); @@ -232,7 +234,7 @@ rmextra(const char *path, struct hashmap *preserved, preremove_fn cb, bool filesync(const char *restrict srcpath, const char *restrict dstpath, - struct hashmap *preserved, bool dry) + struct hmap *preserved, bool dry) { int fdsrc; struct stat stsrc; @@ -271,9 +273,9 @@ filesync(const char *restrict srcpath, const char *restrict dstpath, if (cleanup) { if (preserved == NULL) { - preserved = hashmap_new(); + preserved = hmap_new(); } else { - own = vector_new(32); + own = vector_new_with_cap(32); } } @@ -293,7 +295,7 @@ filesync(const char *restrict srcpath, const char *restrict dstpath, sprintf(entdst, "%s/%s", dstpath, ent->d_name); if (cleanup) { char *name = strdup(ent->d_name); - hashmap_insert(preserved, name, name); + hmap_set(preserved, name, name); if (own) { vector_push(own, name); } @@ -307,12 +309,12 @@ filesync(const char *restrict srcpath, const char *restrict dstpath, if (cleanup) { rmextra(dstpath, preserved, NULL, NULL, dry); if (own) { - for (size_t i = 0; i < own->size; i++) { + for (size_t i = 0; i < own->len; i++) { free(own->values[i]); } vector_free(own); } else { - hashmap_destroy(preserved, hm_destroy_callback); + hmap_destroy(preserved, hm_destroy_cb); } } |