1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jens Arnold 2006-06-30 05:35:11 +00:00
parent 2ef6afe0a0
commit f9b20914e6

View file

@ -47,17 +47,20 @@ static const char* vol_names = "<HD%d>";
static int strip_volume(const char* name, char* namecopy) static int strip_volume(const char* name, char* namecopy)
{ {
int volume = 0; int volume = 0;
const char *temp = name;
if (name[1] == vol_names[0] ) /* a '<' quickly identifies our volumes */
while (*temp && strchr("/", *temp)) /* skip all leading slashes */
++temp;
if (*temp && !strncmp(temp, vol_names, VOL_ENUM_POS))
{ {
const char* temp; temp += VOL_ENUM_POS; /* behind special name */
temp = name + 1 + VOL_ENUM_POS; /* behind '/' and special name */ volume = atoi(temp); /* number is following */
volume = atoi(temp); /* number is following */
temp = strchr(temp, '/'); /* search for slash behind */ temp = strchr(temp, '/'); /* search for slash behind */
if (temp != NULL) if (temp != NULL)
name = temp; /* use the part behind the volume */ name = temp; /* use the part behind the volume */
else else
name = "/"; /* else this must be the root dir */ name = "/"; /* else this must be the root dir */
} }
strncpy(namecopy, name, MAX_PATH); strncpy(namecopy, name, MAX_PATH);