From f9b20914e6e4037f779642f21cda75570b3c1ce5 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Fri, 30 Jun 2006 05:35:11 +0000 Subject: volume_strip() now ignores multiple leading slashes like the rest of the path handling code. Fixes the stats plugin only counting the internal flash on Ondio, and other potential problems. Posix says multiple slashes are legal. * More precise volume name check. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10155 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/dir.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'firmware/common') diff --git a/firmware/common/dir.c b/firmware/common/dir.c index 7361c78067..88dbe29c80 100644 --- a/firmware/common/dir.c +++ b/firmware/common/dir.c @@ -47,17 +47,20 @@ static const char* vol_names = ""; static int strip_volume(const char* name, char* namecopy) { int volume = 0; - - if (name[1] == vol_names[0] ) /* a '<' quickly identifies our volumes */ + const char *temp = name; + + while (*temp && strchr("/", *temp)) /* skip all leading slashes */ + ++temp; + + if (*temp && !strncmp(temp, vol_names, VOL_ENUM_POS)) { - const char* temp; - temp = name + 1 + VOL_ENUM_POS; /* behind '/' and special name */ - volume = atoi(temp); /* number is following */ + temp += VOL_ENUM_POS; /* behind special name */ + volume = atoi(temp); /* number is following */ temp = strchr(temp, '/'); /* search for slash behind */ if (temp != NULL) - name = temp; /* use the part behind the volume */ + name = temp; /* use the part behind the volume */ else - name = "/"; /* else this must be the root dir */ + name = "/"; /* else this must be the root dir */ } strncpy(namecopy, name, MAX_PATH); -- cgit v1.2.3