Added the options -x and -X to copyattr. They can be used to specify an
exclude pattern for file respectively path names. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24584 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
da17e06b92
commit
b71cab0178
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005, Ingo Weinhold, bonefish@users.sf.net.
|
||||
* Copyright 2005-2008, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@ -19,6 +19,12 @@
|
||||
#include <SymLink.h>
|
||||
#include <TypeConstants.h>
|
||||
|
||||
#include <EntryFilter.h>
|
||||
|
||||
|
||||
using BPrivate::EntryFilter;
|
||||
|
||||
|
||||
static const char *kCommandName = "copyattr";
|
||||
static const int kCopyBufferSize = 64 * 1024; // 64 KB
|
||||
|
||||
@ -68,6 +74,8 @@ const char *kUsage =
|
||||
" -t, --type <type> - Copy only the attributes of type <type>. If -n is\n"
|
||||
" specified too, only the attribute matching the name\n"
|
||||
" and the type is copied.\n"
|
||||
" -x <pattern> - Exclude source entries matching <pattern>.\n"
|
||||
" -X <pattern> - Exclude source paths matching <pattern>.\n"
|
||||
" -v, --verbose - Print more messages.\n"
|
||||
" -, -- - Marks the end of options. The arguments after, even\n"
|
||||
" if starting with \"-\" are considered file names.\n"
|
||||
@ -121,6 +129,7 @@ private:
|
||||
type_code fType;
|
||||
};
|
||||
|
||||
|
||||
// Parameters
|
||||
struct Parameters {
|
||||
Parameters()
|
||||
@ -136,6 +145,7 @@ struct Parameters {
|
||||
bool move_files;
|
||||
bool verbose;
|
||||
AttributeFilter attribute_filter;
|
||||
EntryFilter entry_filter;
|
||||
};
|
||||
|
||||
|
||||
@ -275,6 +285,10 @@ static void
|
||||
copy_entry(const char *sourcePath, const char *destPath,
|
||||
const Parameters ¶meters)
|
||||
{
|
||||
// apply entry filter
|
||||
if (!parameters.entry_filter.Filter(sourcePath))
|
||||
return;
|
||||
|
||||
// stat source
|
||||
struct stat sourceStat;
|
||||
if (lstat(sourcePath, &sourceStat) < 0) {
|
||||
@ -626,6 +640,12 @@ main(int argc, const char *const *argv)
|
||||
|| strcmp(arg, "--verbose") == 0) {
|
||||
parameters.verbose = true;
|
||||
|
||||
} else if (strcmp(arg, "-x") == 0 || strcmp(arg, "--type") == 0) {
|
||||
parameters.entry_filter.AddExcludeFilter(next_arg(argi), true);
|
||||
|
||||
} else if (strcmp(arg, "-X") == 0 || strcmp(arg, "--type") == 0) {
|
||||
parameters.entry_filter.AddExcludeFilter(next_arg(argi), false);
|
||||
|
||||
} else if (strcmp(arg, "-") == 0 || strcmp(arg, "--") == 0) {
|
||||
moreOptions = false;
|
||||
|
||||
|
@ -32,6 +32,7 @@ if $(HOST_PLATFORM) in r5 bone dano {
|
||||
|
||||
BuildPlatformMain <build>catattr : catattr.cpp : $(HOST_LIBBE) ;
|
||||
|
||||
UsePrivateObjectHeaders copyattr.cpp : shared : : true ;
|
||||
BuildPlatformMain <build>copyattr : copyattr.cpp
|
||||
: $(HOST_LIBBE) $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user