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:
+21
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005, Ingo Weinhold, [email protected].
|
* Copyright 2005-2008, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -19,6 +19,12 @@
|
|||||||
#include <SymLink.h>
|
#include <SymLink.h>
|
||||||
#include <TypeConstants.h>
|
#include <TypeConstants.h>
|
||||||
|
|
||||||
|
#include <EntryFilter.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::EntryFilter;
|
||||||
|
|
||||||
|
|
||||||
static const char *kCommandName = "copyattr";
|
static const char *kCommandName = "copyattr";
|
||||||
static const int kCopyBufferSize = 64 * 1024; // 64 KB
|
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"
|
" -t, --type <type> - Copy only the attributes of type <type>. If -n is\n"
|
||||||
" specified too, only the attribute matching the name\n"
|
" specified too, only the attribute matching the name\n"
|
||||||
" and the type is copied.\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"
|
" -v, --verbose - Print more messages.\n"
|
||||||
" -, -- - Marks the end of options. The arguments after, even\n"
|
" -, -- - Marks the end of options. The arguments after, even\n"
|
||||||
" if starting with \"-\" are considered file names.\n"
|
" if starting with \"-\" are considered file names.\n"
|
||||||
@@ -121,6 +129,7 @@ private:
|
|||||||
type_code fType;
|
type_code fType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
struct Parameters {
|
struct Parameters {
|
||||||
Parameters()
|
Parameters()
|
||||||
@@ -136,6 +145,7 @@ struct Parameters {
|
|||||||
bool move_files;
|
bool move_files;
|
||||||
bool verbose;
|
bool verbose;
|
||||||
AttributeFilter attribute_filter;
|
AttributeFilter attribute_filter;
|
||||||
|
EntryFilter entry_filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -275,6 +285,10 @@ static void
|
|||||||
copy_entry(const char *sourcePath, const char *destPath,
|
copy_entry(const char *sourcePath, const char *destPath,
|
||||||
const Parameters ¶meters)
|
const Parameters ¶meters)
|
||||||
{
|
{
|
||||||
|
// apply entry filter
|
||||||
|
if (!parameters.entry_filter.Filter(sourcePath))
|
||||||
|
return;
|
||||||
|
|
||||||
// stat source
|
// stat source
|
||||||
struct stat sourceStat;
|
struct stat sourceStat;
|
||||||
if (lstat(sourcePath, &sourceStat) < 0) {
|
if (lstat(sourcePath, &sourceStat) < 0) {
|
||||||
@@ -626,6 +640,12 @@ main(int argc, const char *const *argv)
|
|||||||
|| strcmp(arg, "--verbose") == 0) {
|
|| strcmp(arg, "--verbose") == 0) {
|
||||||
parameters.verbose = true;
|
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) {
|
} else if (strcmp(arg, "-") == 0 || strcmp(arg, "--") == 0) {
|
||||||
moreOptions = false;
|
moreOptions = false;
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ if $(HOST_PLATFORM) in r5 bone dano {
|
|||||||
|
|
||||||
BuildPlatformMain <build>catattr : catattr.cpp : $(HOST_LIBBE) ;
|
BuildPlatformMain <build>catattr : catattr.cpp : $(HOST_LIBBE) ;
|
||||||
|
|
||||||
|
UsePrivateObjectHeaders copyattr.cpp : shared : : true ;
|
||||||
BuildPlatformMain <build>copyattr : copyattr.cpp
|
BuildPlatformMain <build>copyattr : copyattr.cpp
|
||||||
: $(HOST_LIBBE) $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) ;
|
: $(HOST_LIBBE) $(HOST_LIBSTDC++) $(HOST_LIBSUPC++) ;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user