Implement cp -f
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "../text.h"
|
||||
#include "../util.h"
|
||||
|
||||
bool cp_fflag = false;
|
||||
bool cp_rflag = false;
|
||||
|
||||
int
|
||||
@@ -62,8 +63,12 @@ cp(const char *s1, const char *s2)
|
||||
if(!(f1 = fopen(s1, "r")))
|
||||
eprintf("fopen %s:", s1);
|
||||
|
||||
if(!(f2 = fopen(s2, "w")))
|
||||
eprintf("fopen %s:", s2);
|
||||
if(!(f2 = fopen(s2, "w"))) {
|
||||
if (cp_fflag == true)
|
||||
unlink(s2);
|
||||
if (!(f2 = fopen(s2, "w")))
|
||||
eprintf("fopen %s:", s2);
|
||||
}
|
||||
|
||||
concat(f1, s1, f2, s2);
|
||||
fchmod(fileno(f2), st.st_mode);
|
||||
|
@@ -18,4 +18,3 @@ fnck(const char *a, const char *b, int (*fn)(const char *, const char *))
|
||||
if(fn(a, b) == -1)
|
||||
eprintf("%s -> %s:", a, b);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user