diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-06-30 05:35:11 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-06-30 05:35:11 +0000 |
commit | f9b20914e6e4037f779642f21cda75570b3c1ce5 (patch) | |
tree | dbf3a2110095f1cbb4e972302878c3bdb4b4b8ac /firmware/common | |
parent | 2ef6afe0a02cdb2454039d8927b93aa56d1afae1 (diff) | |
download | rockbox-f9b20914e6e4037f779642f21cda75570b3c1ce5.tar.gz rockbox-f9b20914e6e4037f779642f21cda75570b3c1ce5.zip |
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
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/dir.c | 17 |
1 files changed, 10 insertions, 7 deletions
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 = "<HD%d>"; | |||
47 | static int strip_volume(const char* name, char* namecopy) | 47 | static int strip_volume(const char* name, char* namecopy) |
48 | { | 48 | { |
49 | int volume = 0; | 49 | int volume = 0; |
50 | 50 | const char *temp = name; | |
51 | if (name[1] == vol_names[0] ) /* a '<' quickly identifies our volumes */ | 51 | |
52 | while (*temp && strchr("/", *temp)) /* skip all leading slashes */ | ||
53 | ++temp; | ||
54 | |||
55 | if (*temp && !strncmp(temp, vol_names, VOL_ENUM_POS)) | ||
52 | { | 56 | { |
53 | const char* temp; | 57 | temp += VOL_ENUM_POS; /* behind special name */ |
54 | temp = name + 1 + VOL_ENUM_POS; /* behind '/' and special name */ | 58 | volume = atoi(temp); /* number is following */ |
55 | volume = atoi(temp); /* number is following */ | ||
56 | temp = strchr(temp, '/'); /* search for slash behind */ | 59 | temp = strchr(temp, '/'); /* search for slash behind */ |
57 | if (temp != NULL) | 60 | if (temp != NULL) |
58 | name = temp; /* use the part behind the volume */ | 61 | name = temp; /* use the part behind the volume */ |
59 | else | 62 | else |
60 | name = "/"; /* else this must be the root dir */ | 63 | name = "/"; /* else this must be the root dir */ |
61 | } | 64 | } |
62 | 65 | ||
63 | strncpy(namecopy, name, MAX_PATH); | 66 | strncpy(namecopy, name, MAX_PATH); |