summaryrefslogtreecommitdiff
path: root/src/helper/tpax_path_copy.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-05-26 14:41:33 +0000
committermidipix <writeonce@midipix.org>2024-05-26 14:41:33 +0000
commit6c8a81097fd305d428891377433d7d88ba1119fd (patch)
tree91f2b4fa467e1a7851e2a1fd3f8ccc1f2d50fe1b /src/helper/tpax_path_copy.c
parent94230e73b767a4acc02a98d4a2520631517f1a2a (diff)
downloadtpax-6c8a81097fd305d428891377433d7d88ba1119fd.tar.bz2
tpax-6c8a81097fd305d428891377433d7d88ba1119fd.tar.xz
library api's: _util_ (utility helper interfaces) namespace overhaul.
Diffstat (limited to 'src/helper/tpax_path_copy.c')
-rw-r--r--src/helper/tpax_path_copy.c86
1 files changed, 0 insertions, 86 deletions
diff --git a/src/helper/tpax_path_copy.c b/src/helper/tpax_path_copy.c
deleted file mode 100644
index 084cc73..0000000
--- a/src/helper/tpax_path_copy.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/**************************************************************/
-/* tpax: a topological pax implementation */
-/* Copyright (C) 2020--2024 SysDeer Technologies, LLC */
-/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */
-/**************************************************************/
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-#include <tpax/tpax.h>
-#include "tpax_driver_impl.h"
-
-int tpax_path_copy(
- char * dstpath,
- const char * srcpath,
- size_t bufsize,
- uint32_t flags,
- size_t * nwritten)
-{
- const char * src;
- char * dst;
- char * cap;
-
- if (!bufsize) {
- errno = ENOBUFS;
- return -1;
- }
-
- src = srcpath;
- dst = dstpath;
- cap = &dst[bufsize];
-
- if ((src[0] == '/') && (src[1] == '/') && (src[2] != '/')) {
- *dst++ = *src++;
- *dst++ = *src++;
- }
-
- if (flags & TPAX_DRIVER_PURE_PATH_OUTPUT)
- if ((src[0] == '.') && (src[1] == '/'))
- for (++src; *src=='/'; src++)
- (void)0;
-
- for (; *src; ) {
- if ((src[0] == '.') && (src[1] == '.')) {
- if ((src[2] == '/') || (src[2] == '\0')) {
- if (flags & TPAX_DRIVER_STRICT_PATH_INPUT) {
- errno = EINVAL;
- return -1;
- }
- }
- }
-
- if (flags & TPAX_DRIVER_PURE_PATH_OUTPUT) {
- if ((src[0] == '.') && (src[1] == '/') && (src[-1] == '/')) {
- for (++src; *src=='/'; src++)
- (void)0;
-
- } else if ((src[0] == '/')) {
- for (src++; *src=='/'; src++)
- (void)0;
-
- *dst++ = '/';
-
- } else {
- *dst++ = *src++;
- }
- } else {
- *dst++ = *src++;
- }
-
- if (dst == cap) {
- errno = ENOBUFS;
- return -1;
- }
- }
-
- if (nwritten)
- *nwritten = dst - dstpath;
-
- *dst = '\0';
-
- return 0;
-}