diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-14 21:43:02 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-14 21:43:02 -0400 |
commit | e735ad6710a82604a206ad29f6cbcdd7dc4b024c (patch) | |
tree | 5fe8eebbb7a2bff20bb71bd2368955356979e0a2 /command/cp.c | |
parent | sync (diff) | |
download | lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.tar.gz lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.tar.bz2 lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.zip |
refactor and add su
Diffstat (limited to 'command/cp.c')
-rw-r--r-- | command/cp.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/command/cp.c b/command/cp.c index ca80f69..47a4ff0 100644 --- a/command/cp.c +++ b/command/cp.c @@ -2,12 +2,12 @@ #include "lslib.h" #include <dirent.h> -#include <errno.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> +#include <errno.h> #include <unistd.h> static struct { @@ -81,7 +81,7 @@ static bool copy_file(char* from, char* to) { static bool symlink_file(char* from, char* to) { if (symlink(from, to) < 0) { - error_s("failed to symlink '%s': %s", from, strerror(errno)); + error_s("failed to symlink '%s'", from); return false; } else if (flags.verbose) { output("symlinked '%s'", from); @@ -91,7 +91,7 @@ static bool symlink_file(char* from, char* to) { static bool hardlink_file(char* from, char* to) { if (link(from, to) < 0) { - error_s("failed to hardlink '%s': %s", from, strerror(errno)); + error_s("failed to hardlink '%s'", from); return false; } else if (flags.verbose) { output("hardlinked '%s'", from); @@ -117,12 +117,12 @@ static void run_copy(struct stat* s) { if (!flags.preserve) return; if (chmod(to, s->st_mode) < 0) { - error_s("cannot chmod '%s': %s", to, strerror(errno)); + error_s("cannot chmod '%s'", to); return; } if (chown(to, s->st_uid, s->st_gid) < 0) { - error_s("cannot chown '%s': %s", to, strerror(errno)); + error_s("cannot chown '%s'", to); return; } } @@ -140,14 +140,14 @@ static void cp_directory(struct stat* s) { } if (mkdir(get_path_buffer_2(), s->st_mode) < 0 && errno != EEXIST) { - error_s("cannot create directory '%s': %s", get_path_buffer_2(), strerror(errno)); + error_s("cannot create directory '%s'", get_path_buffer_2()); return; } d = opendir(get_path_buffer()); if (d == NULL) { - error_s("cannot open directory '%s': %s", get_path_buffer(), strerror(errno)); + error_s("cannot open directory '%s'", get_path_buffer()); return; } @@ -183,7 +183,7 @@ static void cp_file(char* path) { struct stat s; if (lstat(get_path_buffer(), &s) < 0) { pop_path_buffer(save); - error_s("cannot stat '%s': %s", get_path_buffer(), strerror(errno)); + error_s("cannot stat '%s'", get_path_buffer()); return; } @@ -218,7 +218,7 @@ COMMAND(cp) { if (argc - start == 2) { struct stat s; if (lstat(argv[start], &s) < 0) { - error("cannot stat '%s': %s", argv[start], strerror(errno)); + error("cannot stat '%s'", argv[start]); } push_path_buffer(argv[argc-2]); push_path_buffer_2(argv[argc-1]); @@ -234,7 +234,7 @@ COMMAND(cp) { push_path_buffer_2(argv[argc-1]); if (lstat(get_path_buffer_2(), &s) < 0) { - error("target: '%s': %s", get_path_buffer_2(), strerror(errno)); + error("target: '%s'", get_path_buffer_2()); } for (i = start; i < argc - 1; i++) { |