diff options
Diffstat (limited to 'src/fetch_pwd.c')
| -rw-r--r-- | src/fetch_pwd.c | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/src/fetch_pwd.c b/src/fetch_pwd.c deleted file mode 100644 index 32edd79..0000000 --- a/src/fetch_pwd.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - - pkgit - package it! - - Copyright (C) 2026 dacctal - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - -*/ - -#include <stdio.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <ftw.h> -#include <unistd.h> - -#include "fetch_pwd.h" -#include "vars.h" - -static const char *pwd_dst; - -static int copy_entry( - const char *fpath, const struct stat *sb, - int typeflag, struct FTW *ftwbuf -) { - (void)ftwbuf; - const char *rel = fpath; - if (rel[0] == '.' && rel[1] == '/') rel += 2; - if (rel[0] == '\0') return 0; - - char dst[MAX_PATH_LEN]; - snprintf(dst, sizeof(dst), "%s/%s", pwd_dst, rel); - - if (typeflag == FTW_D) { - mkdir(dst, 0755); - } else if (typeflag == FTW_F) { - int src_fd = open(fpath, O_RDONLY); - if (src_fd < 0) return -1; - - int dst_fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, sb->st_mode & 07777); - if (dst_fd < 0) { close(src_fd); return -1; } - - char buf[8192]; - ssize_t n; - while ((n = read(src_fd, buf, sizeof(buf))) > 0) { - ssize_t written = 0; - while (written < n) { - ssize_t ret = write(dst_fd, buf + written, n - written); - if (ret < 0) { close(src_fd); close(dst_fd); return -1; } - written += ret; - } - } - - close(src_fd); - close(dst_fd); - } - return 0; -} - -void fetch_pwd(Pkg pkg) { - pwd_dst = pkg.src; - nftw(".", copy_entry, 64, FTW_PHYS); -}
\ No newline at end of file |
