commit: d123b8b11e60c5a0fddba6c4c221ceb1968529ad
parent 3d77320c512fa26c6f372d4fd087912d8e61f4a8
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 10 May 2024 20:50:36 +0200
lib/path.{c,h} => lib/fs.{c,h}
Diffstat:
7 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/Makefile b/Makefile
@@ -135,13 +135,13 @@ cmd/tr: cmd/tr.c lib/tr_str.c lib/tr_str.h Makefile
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
$(CC) -std=c99 $(CFLAGS) -o $@ cmd/tr.c lib/tr_str.c $(LDFLAGS) $(LDSTATIC)
-cmd/chown: cmd/chown.c lib/path.c lib/path.h lib/user_group_parse.c lib/user_group_parse.h Makefile
+cmd/chown: cmd/chown.c lib/fs.c lib/fs.h lib/user_group_parse.c lib/user_group_parse.h Makefile
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/chown.c lib/path.c lib/user_group_parse.c $(LDFLAGS) $(LDSTATIC)
+ $(CC) -std=c99 $(CFLAGS) -o $@ cmd/chown.c lib/fs.c lib/user_group_parse.c $(LDFLAGS) $(LDSTATIC)
-cmd/realpath: cmd/realpath.c lib/path.c lib/path.h Makefile
+cmd/realpath: cmd/realpath.c lib/fs.c lib/fs.h Makefile
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/realpath.c lib/path.c $(LDFLAGS) $(LDSTATIC)
+ $(CC) -std=c99 $(CFLAGS) -o $@ cmd/realpath.c lib/fs.c $(LDFLAGS) $(LDSTATIC)
cmd/expr.tab.c: cmd/expr.y Makefile
$(YACC) -b cmd/expr cmd/expr.y
@@ -150,6 +150,6 @@ cmd/expr: cmd/expr.tab.c Makefile
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
$(CC) -std=c99 $(CFLAGS) -o $@ cmd/expr.tab.c $(LDFLAGS) $(LDSTATIC)
-cmd/install: cmd/install.c lib/mode.c lib/user_group_parse.c lib/user_group_parse.h lib/path.c lib/path.h lib/mkdir.c lib/mkdir.h Makefile
+cmd/install: cmd/install.c lib/mode.c lib/user_group_parse.c lib/user_group_parse.h lib/fs.c lib/fs.h lib/mkdir.c lib/mkdir.h Makefile
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/install.c lib/mode.c lib/user_group_parse.c lib/path.c lib/mkdir.c $(LDFLAGS) $(LDSTATIC)
+ $(CC) -std=c99 $(CFLAGS) -o $@ cmd/install.c lib/mode.c lib/user_group_parse.c lib/fs.c lib/mkdir.c $(LDFLAGS) $(LDSTATIC)
diff --git a/cmd/chown.c b/cmd/chown.c
@@ -9,7 +9,7 @@
#define _NETBSD_SOURCE
#endif
-#include "../lib/path.h"
+#include "../lib/fs.h"
#include "../lib/user_group_parse.h"
#include <assert.h>
diff --git a/cmd/install.c b/cmd/install.c
@@ -6,9 +6,9 @@
#define _GNU_SOURCE // musl, glibc
#define _DEFAULT_SOURCE // FreeBSD
+#include "../lib/fs.h"
#include "../lib/mkdir.h"
#include "../lib/mode.h"
-#include "../lib/path.h"
#include "../lib/user_group_parse.h"
#include <assert.h>
diff --git a/cmd/realpath.c b/cmd/realpath.c
@@ -5,7 +5,7 @@
#define _POSIX_C_SOURCE 200809L
#define _XOPEN_SOURCE 700 // realpath is in XSI
-#include "../lib/path.h"
+#include "../lib/fs.h"
#include <errno.h>
#include <limits.h> // PATH_MAX
diff --git a/lib/fs.c b/lib/fs.c
@@ -0,0 +1,37 @@
+// utils-std: Collection of commonly available Unix tools
+// SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+// SPDX-License-Identifier: MPL-2.0
+
+#include "./fs.h"
+
+#include <string.h> // strrchr
+
+char *
+static_basename(char *path)
+{
+ char *sep = strrchr(path, '/');
+
+ return (sep == NULL) ? path : sep + 1;
+}
+
+char *
+path_split_static(char *path, bool trim)
+{
+ char *child = NULL;
+ size_t path_len = strlen(path);
+
+ // delete trailing slashes
+ if(trim)
+ for(int i = path_len - 1; i > 0 && path[i] == '/'; i--)
+ path[i] = 0;
+
+ for(int i = path_len - 1; i > 0; i--)
+ if(path[i] == '/')
+ {
+ path[i] = 0;
+ child = &path[i + 1];
+ break;
+ }
+
+ return child;
+}
diff --git a/lib/path.h b/lib/fs.h
diff --git a/lib/path.c b/lib/path.c
@@ -1,37 +0,0 @@
-// utils-std: Collection of commonly available Unix tools
-// SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-// SPDX-License-Identifier: MPL-2.0
-
-#include "./path.h"
-
-#include <string.h> // strrchr
-
-char *
-static_basename(char *path)
-{
- char *sep = strrchr(path, '/');
-
- return (sep == NULL) ? path : sep + 1;
-}
-
-char *
-path_split_static(char *path, bool trim)
-{
- char *child = NULL;
- size_t path_len = strlen(path);
-
- // delete trailing slashes
- if(trim)
- for(int i = path_len - 1; i > 0 && path[i] == '/'; i--)
- path[i] = 0;
-
- for(int i = path_len - 1; i > 0; i--)
- if(path[i] == '/')
- {
- path[i] = 0;
- child = &path[i + 1];
- break;
- }
-
- return child;
-}