From 23fa887f1584afb60aeb38288bb74837e4f067db Mon Sep 17 00:00:00 2001 From: midipix Date: May 23 2020 05:59:01 +0000 Subject: driver: implemented directory archive member recursion logic. --- diff --git a/include/tpax/tpax.h b/include/tpax/tpax.h index 0be10f9..d9c73ad 100644 --- a/include/tpax/tpax.h +++ b/include/tpax/tpax.h @@ -48,6 +48,8 @@ extern "C" { #define TPAX_DRIVER_WRITE_FORMAT_USTAR 0x40000 #define TPAX_DRIVER_WRITE_FORMAT_RUSTAR 0x80000 +#define TPAX_DRIVER_DIR_MEMBER_RECURSE 0x100000 + /* error flags */ #define TPAX_ERROR_TOP_LEVEL 0x0001 #define TPAX_ERROR_NESTED 0x0002 diff --git a/src/driver/tpax_amain.c b/src/driver/tpax_amain.c index f71f16c..84b15f4 100644 --- a/src/driver/tpax_amain.c +++ b/src/driver/tpax_amain.c @@ -12,7 +12,8 @@ #ifndef TPAX_DRIVER_FLAGS #define TPAX_DRIVER_FLAGS TPAX_DRIVER_VERBOSITY_ERRORS \ - | TPAX_DRIVER_VERBOSITY_USAGE + | TPAX_DRIVER_VERBOSITY_USAGE \ + | TPAX_DRIVER_DIR_MEMBER_RECURSE #endif static const char vermsg[] = "%s%s%s (https://git.foss21.org/tpax): " diff --git a/src/driver/tpax_driver_ctx.c b/src/driver/tpax_driver_ctx.c index 81c4e34..d8e2de8 100644 --- a/src/driver/tpax_driver_ctx.c +++ b/src/driver/tpax_driver_ctx.c @@ -83,10 +83,10 @@ static int tpax_driver_usage( snprintf(header,sizeof(header), "%s — topological pax implementation\n\n" "Synopsis:\n" - " %s\n" - " %s -r\n" - " %s -w [−x format] [-b blocksize]\n" - " %s -r -w\n\n" + " %s [-d]\n" + " %s -r [-d]\n" + " %s -w [−x format] [-b blocksize] [-d]\n" + " %s -r -w [-d]\n\n" "Options:\n", program,program,program,program,program); @@ -395,6 +395,14 @@ int tpax_get_driver_ctx( program,entry->arg, optv,meta); break; + + case TAG_RECURSE: + cctx.drvflags |= TPAX_DRIVER_DIR_MEMBER_RECURSE; + break; + + case TAG_NORECURSE: + cctx.drvflags &= ~(uintptr_t)TPAX_DRIVER_DIR_MEMBER_RECURSE; + break; } } else { operand = entry; @@ -500,6 +508,12 @@ int tpax_get_driver_ctx( break; } + /* not implemented features */ + if (cctx.drvflags & TPAX_DRIVER_EXEC_MODE_MASK) + if (cctx.drvflags & TPAX_DRIVER_DIR_MEMBER_RECURSE) + return tpax_driver_error_not_implemented( + fdctx->fderr,program,"directory recursion",meta); + /* driver ctx */ if (!(ctx = tpax_driver_ctx_alloc(meta,fdctx,&cctx,nunits))) { if (cctx.drvflags & TPAX_DRIVER_EXEC_MODE_COPY) diff --git a/src/internal/tpax_driver_impl.h b/src/internal/tpax_driver_impl.h index 0a5c583..74af288 100644 --- a/src/internal/tpax_driver_impl.h +++ b/src/internal/tpax_driver_impl.h @@ -28,6 +28,8 @@ enum app_tags { TAG_COPY, TAG_FORMAT, TAG_BLKSIZE, + TAG_RECURSE, + TAG_NORECURSE, }; struct tpax_driver_ctx_impl { diff --git a/src/skin/tpax_skin_default.c b/src/skin/tpax_skin_default.c index dacc9d8..c6de7e6 100644 --- a/src/skin/tpax_skin_default.c +++ b/src/skin/tpax_skin_default.c @@ -34,5 +34,12 @@ const struct argv_option tpax_default_options[] = { " 10240 for the ustar format) " "is strongly recommended."}, + {"recurse", 0,TAG_RECURSE,ARGV_OPTARG_NONE,0,0,0, + "recurse into directory archive members " + "(this is the tpax_main() default)"}, + + {"no-recurse", 'd',TAG_NORECURSE,ARGV_OPTARG_NONE,0,0,0, + "do not recurse into directory archive members"}, + {0,0,0,0,0,0,0,0} };