diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-17 22:30:53 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-17 22:30:53 +0000 |
commit | fdffefb8032922ce7ffe4c00816072a8ff2148fc (patch) | |
tree | bc7313151a429c45d8bab8ad8b9dd32f4e51335f /src/libstddjb/hiercopy_tmp.c | |
parent | a896ca2a8c617e5e00ffd5fc9e69331ad754e5b3 (diff) | |
download | skalibs-fdffefb8032922ce7ffe4c00816072a8ff2148fc.tar.xz |
More types changes
New disize
Add size_t to the autotypes list
Delete redundant and replace-libc files
dev_t/ino_t pass
Big size_t pass
More things missing, still not operational yet
Diffstat (limited to 'src/libstddjb/hiercopy_tmp.c')
-rw-r--r-- | src/libstddjb/hiercopy_tmp.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/libstddjb/hiercopy_tmp.c b/src/libstddjb/hiercopy_tmp.c index bcff2b2..ef76b57 100644 --- a/src/libstddjb/hiercopy_tmp.c +++ b/src/libstddjb/hiercopy_tmp.c @@ -2,10 +2,10 @@ #include <sys/types.h> #include <sys/stat.h> +#include <string.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> -#include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/direntry.h> @@ -13,22 +13,22 @@ static int dircopy (char const *src, char const *dst, mode_t mode, stralloc *tmp) { - unsigned int tmpbase = tmp->len ; - unsigned int maxlen = 0 ; + size_t tmpbase = tmp->len ; + size_t maxlen = 0 ; { DIR *dir = opendir(src) ; if (!dir) return 0 ; for (;;) { direntry *d ; - register unsigned int n ; + size_t n ; errno = 0 ; d = readdir(dir) ; if (!d) break ; if (d->d_name[0] == '.') if (((d->d_name[1] == '.') && !d->d_name[2]) || !d->d_name[1]) continue ; - n = str_len(d->d_name) ; + n = strlen(d->d_name) ; if (n > maxlen) maxlen = n ; if (!stralloc_catb(tmp, d->d_name, n+1)) break ; } @@ -50,20 +50,20 @@ static int dircopy (char const *src, char const *dst, mode_t mode, stralloc *tmp if (!S_ISDIR(st.st_mode)) { errno = ENOTDIR ; goto err ; } } { - unsigned int srclen = str_len(src) ; - unsigned int dstlen = str_len(dst) ; - unsigned int i = tmpbase ; + size_t srclen = strlen(src) ; + size_t dstlen = strlen(dst) ; + size_t i = tmpbase ; char srcbuf[srclen + maxlen + 2] ; char dstbuf[dstlen + maxlen + 2] ; - byte_copy(srcbuf, srclen, src) ; - byte_copy(dstbuf, dstlen, dst) ; + memcpy(srcbuf, src, srclen) ; + memcpy(dstbuf, dst, dstlen) ; srcbuf[srclen] = '/' ; dstbuf[dstlen] = '/' ; while (i < tmp->len) { - register unsigned int n = str_len(tmp->s + i) + 1 ; - byte_copy(srcbuf + srclen + 1, n, tmp->s + i) ; - byte_copy(dstbuf + dstlen + 1, n, tmp->s + i) ; + size_t n = strlen(tmp->s + i) + 1 ; + memcpy(srcbuf + srclen + 1, tmp->s + i, n) ; + memcpy(dstbuf + dstlen + 1, tmp->s + i, n) ; i += n ; hiercopy_tmp(srcbuf, dstbuf, tmp) ; } @@ -94,14 +94,9 @@ int hiercopy_tmp (char const *src, char const *dst, stralloc *tmp) } else if (S_ISLNK(st.st_mode)) { - unsigned int tmpbase = tmp->len ; + size_t tmpbase = tmp->len ; if (sareadlink(tmp, src) < 0) return 0 ; - if (!stralloc_0(tmp)) - { - tmp->len = tmpbase ; - return 0 ; - } - if (symlink(tmp->s + tmpbase, dst) < 0) + if (!stralloc_0(tmp) || symlink(tmp->s + tmpbase, dst) < 0) { tmp->len = tmpbase ; return 0 ; |