summaryrefslogtreecommitdiffstats
path: root/firmware/common
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-02-07 02:45:26 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-02-07 02:45:26 -0500
commite5042fd090f29af9d19e2f162c5ae3016ab3743e (patch)
tree76404ae1e7d6735d0a5cd5cf65324b177ff5df7c /firmware/common
parent72dc23929919241a9295e5eae754b47ac358a922 (diff)
downloadrockbox-e5042fd090f29af9d19e2f162c5ae3016ab3743e.tar.gz
rockbox-e5042fd090f29af9d19e2f162c5ae3016ab3743e.tar.bz2
rockbox-e5042fd090f29af9d19e2f162c5ae3016ab3743e.zip
Add some comments about the behavior of a couple path functions.
Critical reminders about the reasons path_dirname() and path_basename() do certain things with a given kind of input and how to interpret them. Change-Id: I4e6ad29476bdd30abfb644f9360cc7dfd86298df
Diffstat (limited to 'firmware/common')
-rw-r--r--firmware/common/pathfuncs.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/firmware/common/pathfuncs.c b/firmware/common/pathfuncs.c
index f5674983d9..0935a9a6e3 100644
--- a/firmware/common/pathfuncs.c
+++ b/firmware/common/pathfuncs.c
@@ -202,9 +202,16 @@ int path_strip_drive(const char *name, const char **nameptr, bool greedy)
* "/" *nameptr->/, len=1: "/"
* "//" *nameptr->2nd /, len=1: "/"
* "/a" *nameptr->a, len=1: "a"
+ * "a/" *nameptr->a, len=1: "a"
* "/a/bc" *nameptr->b, len=2: "bc"
* "d" *nameptr->d, len=1: "d"
* "ef/gh" *nameptr->g, len=2: "gh"
+ *
+ * Notes: * Doesn't do suffix removal at this time.
+ * * In the same string, path_dirname() returns a pointer with the
+ * same or lower address as path_basename().
+ * * Pasting a separator between the returns of path_dirname() and
+ * path_basename() will result in a path equivalent to the input.
*/
size_t path_basename(const char *name, const char **nameptr)
{
@@ -232,9 +239,17 @@ size_t path_basename(const char *name, const char **nameptr)
* "/" *nameptr->/, len=1: "/"
* "//" *nameptr->2nd /, len=1: "/"
* "/a" *nameptr->/, len=1: "/"
+ * "a/" *nameptr->a, len=0: ""
* "/a/bc" *nameptr->/, len=2: "/a"
* "d" *nameptr->d, len=0: ""
* "ef/gh" *nameptr->e, len=2: "ef"
+ *
+ * Notes: * Interpret len=0 as ".".
+ * * In the same string, path_dirname() returns a pointer with the
+ * same or lower address as path_basename().
+ * * Pasting a separator between the returns of path_dirname() and
+ * path_basename() will result in a path equivalent to the input.
+ *
*/
size_t path_dirname(const char *name, const char **nameptr)
{