Changeset View
Changeset View
Standalone View
Standalone View
bin/cp/cp.c
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
main(int argc, char *argv[]) | main(int argc, char *argv[]) | ||||
{ | { | ||||
struct stat to_stat, tmp_stat; | struct stat to_stat, tmp_stat; | ||||
enum op type; | enum op type; | ||||
int Hflag, Lflag, ch, fts_options, r, have_trailing_slash; | int Hflag, Lflag, ch, fts_options, r, have_trailing_slash; | ||||
char *target; | char *target; | ||||
char *p, **av; | |||||
fts_options = FTS_NOCHDIR | FTS_PHYSICAL; | fts_options = FTS_NOCHDIR | FTS_PHYSICAL; | ||||
Hflag = Lflag = 0; | Hflag = Lflag = 0; | ||||
while ((ch = getopt(argc, argv, "HLPRafilnprsvx")) != -1) | while ((ch = getopt(argc, argv, "HLPRafilnprsvx")) != -1) | ||||
switch (ch) { | switch (ch) { | ||||
case 'H': | case 'H': | ||||
Hflag = 1; | Hflag = 1; | ||||
Lflag = 0; | Lflag = 0; | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
} | } | ||||
have_trailing_slash = (to.p_end[-1] == '/'); | have_trailing_slash = (to.p_end[-1] == '/'); | ||||
if (have_trailing_slash) | if (have_trailing_slash) | ||||
STRIP_TRAILING_SLASH(to); | STRIP_TRAILING_SLASH(to); | ||||
to.target_end = to.p_end; | to.target_end = to.p_end; | ||||
/* Set end of argument list for fts(3). */ | /* Set end of argument list for fts(3). */ | ||||
argv[argc] = NULL; | argv[argc] = NULL; | ||||
gbe: This line can be removed. | |||||
/* Strip trailing slashes from source files */ | |||||
for (av = argv; *av != NULL; av++) { | |||||
p = *av + strlen(*av); | |||||
while (p > *av + 1 && p[-1] == '/') | |||||
*--p = '\0'; | |||||
} | |||||
/* | /* | ||||
* Cp has two distinct cases: | * Cp has two distinct cases: | ||||
* | * | ||||
* cp [-R] source target | * cp [-R] source target | ||||
* cp [-R] source1 ... sourceN directory | * cp [-R] source1 ... sourceN directory | ||||
* | * | ||||
* In both cases, source can be either a file or a directory. | * In both cases, source can be either a file or a directory. | ||||
▲ Show 20 Lines • Show All 292 Lines • Show Last 20 Lines |
This line can be removed.