diff options
author | midipix <writeonce@midipix.org> | 2024-05-18 01:23:41 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-05-19 03:36:18 +0000 |
commit | f5ae320ff28a77cb8bfe21a24369500f86c19df1 (patch) | |
tree | afb8c2e049a5ee526931c653d2e5f9b02c679c42 /src/logic | |
parent | 9f55a17009446a7586a3694edb0b54988e201e7f (diff) | |
download | tpax-f5ae320ff28a77cb8bfe21a24369500f86c19df1.tar.bz2 tpax-f5ae320ff28a77cb8bfe21a24369500f86c19df1.tar.xz |
item queue: removed old implementation of tpax_archive_append().
Diffstat (limited to 'src/logic')
-rw-r--r-- | src/logic/tpax_archive_append.c | 141 |
1 files changed, 6 insertions, 135 deletions
diff --git a/src/logic/tpax_archive_append.c b/src/logic/tpax_archive_append.c index d8ac12f..1ff71bc 100644 --- a/src/logic/tpax_archive_append.c +++ b/src/logic/tpax_archive_append.c @@ -598,144 +598,15 @@ static int tpax_archive_append_dir( unit); } -static int tpax_archive_append_impl( +int tpax_archive_append_item( const struct tpax_driver_ctx * dctx, - const struct tpax_unit_ctx * uctx, - int depth, - const char * prefix, - struct tpax_dirent * parent) -{ - if (S_ISDIR(uctx->st->st_mode)) - if (dctx->cctx->drvflags & TPAX_DRIVER_DIR_MEMBER_RECURSE) - return tpax_archive_append_dir( - dctx,uctx,0, - tpax_driver_fdcwd(dctx), - depth,prefix,parent); - - return tpax_archive_append_one( - dctx,uctx,0, - tpax_driver_fdcwd(dctx), - prefix,0,0); -} - -int tpax_archive_append( - const struct tpax_driver_ctx * dctx, - const struct tpax_unit_ctx * uctx, - const char * prefix) + const struct tpax_unit_ctx * uctx) { - struct tpax_dirent_buffer * dentbuf; - struct tpax_dirent * cdent; - struct tpax_dirent * cnext; - const struct tpax_dirent * parent; - uintptr_t addr; - const char * rdir; - const char * src; - char * dst; - char * cap; - char * mark; - int idx; - const char * dirv[256]; - char pbuf[2048]; - - /* normalized prefix */ - if (prefix && (prefix[0] == '.') && (!prefix[1])) - prefix = 0; - - if (prefix && (prefix[0] == '.') && (prefix[1] == '/')) - for (++prefix; *prefix=='/'; prefix++) - (void)0; - - if (prefix) - if (!(prefix = tpax_append_prefix_item(dctx,prefix))) - return TPAX_BUFFER_ERROR(dctx); - - /* append explicit item */ - tpax_archive_append_impl(dctx,uctx,0,prefix,0); - - /* iterate through queued items */ - dentbuf = tpax_get_driver_dirents(dctx); - cdent = dentbuf ? dentbuf->dbuf : 0; + (void)dctx; + (void)uctx; - if (cdent) { - dst = pbuf; - cap = &pbuf[sizeof(pbuf)]; - - if (prefix && prefix[0]) { - for (; *src && dst<cap; ) - *dst++ = *src++; - - if (dst == cap) - return TPAX_BUFFER_ERROR(dctx); - - if (dst[-1] != '/') - *dst++ = '/'; - } - - src = *uctx->path; - - for (; *src && dst<cap; ) - *dst++ = *src++; - - if (dst == cap) - return TPAX_BUFFER_ERROR(dctx); - - if (dst[-1] != '/') - *dst++ = '/'; - - *dst = 0; - mark = dst; - rdir = pbuf; - - (void)mark; - } - - for (; cdent; ) { - switch (cdent->dirent.d_type) { - case DT_DIR: - if (tpax_archive_append_dir( - dctx,0,cdent,cdent->fdat, - cdent->depth,rdir,cdent) < 0) - return TPAX_NESTED_ERROR(dctx); - - break; - - default: - if (tpax_archive_append_one( - dctx,0,&cdent->dirent, - cdent->fdat,rdir,cdent,0) < 0) - return TPAX_NESTED_ERROR(dctx); - } - - addr = (uintptr_t)cdent; - addr += cdent->nsize; - cnext = (struct tpax_dirent *)addr; - - if (cnext == dentbuf->cdent) { - dentbuf = dentbuf->next; - cnext = dentbuf ? dentbuf->dbuf : 0; - } - - if (cnext && (cnext->parent != cdent->parent)) { - if (cnext->depth > 256) - return TPAX_BUFFER_ERROR(dctx); - - for (parent=cnext->parent; parent; parent=parent->parent) - dirv[parent->depth - 1] = parent->dirent.d_name; - - for (idx=0,dst=mark; idx<cnext->parent->depth; idx++) { - src = dirv[idx]; - - for (; *src; ) - *dst++ = *src++; - - *dst++ = '/'; - } - - *--dst = 0; - } - - cdent = cnext; - } + (void)tpax_archive_append_dir; + (void)tpax_append_prefix_item; return 0; } |