1.1 --- a/libe2access/lib/src/path.c Sun Feb 13 01:46:28 2022 +0100
1.2 +++ b/libe2access/lib/src/path.c Mon Feb 14 00:42:55 2022 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Path functions.
1.6 *
1.7 - * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2019, 2022 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -64,3 +64,19 @@
1.13 {
1.14 return strchr(path, (int) '/') == NULL;
1.15 }
1.16 +
1.17 +/* Split a path into directory and basename components, returning a pointer to
1.18 + the basename component. */
1.19 +
1.20 +char *path_split(char *path)
1.21 +{
1.22 + char *s = strrchr(path, (int) '/');
1.23 +
1.24 + if (s != NULL)
1.25 + {
1.26 + *s = '\0';
1.27 + return s + 1;
1.28 + }
1.29 + else
1.30 + return path;
1.31 +}