Added "--ignore-attributes" switch to the "cp" command.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24330 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2586d10ea9
commit
0006905bfb
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2007, Ingo Weinhold, bonefish@cs.tu-berlin.de.
|
* Copyright 2005-2008, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -38,6 +38,7 @@ static const int sCopyBufferSize = 64 * 1024; // 64 KB
|
|||||||
struct Options {
|
struct Options {
|
||||||
Options()
|
Options()
|
||||||
: attributesOnly(false),
|
: attributesOnly(false),
|
||||||
|
ignoreAttributes(false),
|
||||||
dereference(true),
|
dereference(true),
|
||||||
force(false),
|
force(false),
|
||||||
recursive(false)
|
recursive(false)
|
||||||
@ -45,6 +46,7 @@ struct Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool attributesOnly;
|
bool attributesOnly;
|
||||||
|
bool ignoreAttributes;
|
||||||
bool dereference;
|
bool dereference;
|
||||||
bool force;
|
bool force;
|
||||||
bool recursive;
|
bool recursive;
|
||||||
@ -1189,9 +1191,11 @@ copy_entry(FSDomain *sourceDomain, const char *source,
|
|||||||
targetDeleter.SetTo(targetNode);
|
targetDeleter.SetTo(targetNode);
|
||||||
|
|
||||||
// copy attributes
|
// copy attributes
|
||||||
error = copy_attributes(source, sourceNode, target, targetNode);
|
if (!options.ignoreAttributes) {
|
||||||
if (error != FSSH_B_OK)
|
error = copy_attributes(source, sourceNode, target, targetNode);
|
||||||
return error;
|
if (error != FSSH_B_OK)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
// copy contents
|
// copy contents
|
||||||
if (sourceNode->IsFile()) {
|
if (sourceNode->IsFile()) {
|
||||||
@ -1224,27 +1228,36 @@ command_cp(int argc, const char* const* argv)
|
|||||||
const char *arg = argv[argi];
|
const char *arg = argv[argi];
|
||||||
if (arg[0] == '-') {
|
if (arg[0] == '-') {
|
||||||
if (arg[1] == '\0') {
|
if (arg[1] == '\0') {
|
||||||
fprintf(stderr, "Error: Invalid option `-'\n");
|
fprintf(stderr, "Error: Invalid option '-'\n");
|
||||||
return FSSH_EINVAL;
|
return FSSH_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; arg[i]; i++) {
|
if (arg[1] == '-') {
|
||||||
switch (arg[i]) {
|
if (strcmp(arg, "--ignore-attributes") == 0) {
|
||||||
case 'a':
|
options.ignoreAttributes = true;
|
||||||
options.attributesOnly = true;
|
} else {
|
||||||
case 'd':
|
fprintf(stderr, "Error: Unknown option '%s'\n", arg);
|
||||||
options.dereference = false;
|
return FSSH_EINVAL;
|
||||||
break;
|
}
|
||||||
case 'f':
|
} else {
|
||||||
options.force = true;
|
for (int i = 1; arg[i]; i++) {
|
||||||
break;
|
switch (arg[i]) {
|
||||||
case 'r':
|
case 'a':
|
||||||
options.recursive = true;
|
options.attributesOnly = true;
|
||||||
break;
|
case 'd':
|
||||||
default:
|
options.dereference = false;
|
||||||
fprintf(stderr, "Error: Unknown option `-%c'\n",
|
break;
|
||||||
arg[i]);
|
case 'f':
|
||||||
return FSSH_EINVAL;
|
options.force = true;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
options.recursive = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Error: Unknown option '-%c'\n",
|
||||||
|
arg[i]);
|
||||||
|
return FSSH_EINVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user