diff options
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/dir.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/firmware/common/dir.c b/firmware/common/dir.c index 5fa5f9db6e..9f5f082b56 100644 --- a/firmware/common/dir.c +++ b/firmware/common/dir.c | |||
@@ -34,9 +34,11 @@ static DIR opendirs[MAX_OPEN_DIRS]; | |||
34 | /* how to name volumes, first char must be outside of legal file names, | 34 | /* how to name volumes, first char must be outside of legal file names, |
35 | a number gets appended to enumerate, if applicable */ | 35 | a number gets appended to enumerate, if applicable */ |
36 | #ifdef HAVE_MMC | 36 | #ifdef HAVE_MMC |
37 | static const char* vol_names = ":MMC"; | 37 | static const char* vol_names = "<MMC%d>"; |
38 | #define VOL_ENUM_POS 4 /* position of %d, to avoid runtime calculation */ | ||
38 | #else | 39 | #else |
39 | static const char* vol_names = ":HD"; | 40 | static const char* vol_names = "<HD%d>"; |
41 | #define VOL_ENUM_POS 3 | ||
40 | #endif | 42 | #endif |
41 | 43 | ||
42 | /* returns on which volume this is, and copies the reduced name | 44 | /* returns on which volume this is, and copies the reduced name |
@@ -45,10 +47,10 @@ static int strip_volume(const char* name, char* namecopy) | |||
45 | { | 47 | { |
46 | int volume = 0; | 48 | int volume = 0; |
47 | 49 | ||
48 | if (name[1] == vol_names[0] ) /* a colon identifies our volumes */ | 50 | if (name[1] == vol_names[0] ) /* a '<' quickly identifies our volumes */ |
49 | { | 51 | { |
50 | const char* temp; | 52 | const char* temp; |
51 | temp = name + 1 + strlen(vol_names); /* behind special name */ | 53 | temp = name + 1 + VOL_ENUM_POS; /* behind '/' and special name */ |
52 | volume = atoi(temp); /* number is following */ | 54 | volume = atoi(temp); /* number is following */ |
53 | temp = strchr(temp, '/'); /* search for slash behind */ | 55 | temp = strchr(temp, '/'); /* search for slash behind */ |
54 | if (temp != NULL) | 56 | if (temp != NULL) |
@@ -167,7 +169,7 @@ struct dirent* readdir(DIR* dir) | |||
167 | memset(theent, 0, sizeof(*theent)); | 169 | memset(theent, 0, sizeof(*theent)); |
168 | theent->attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME; | 170 | theent->attribute = FAT_ATTR_DIRECTORY | FAT_ATTR_VOLUME; |
169 | snprintf(theent->d_name, sizeof(theent->d_name), | 171 | snprintf(theent->d_name, sizeof(theent->d_name), |
170 | "%s%d", vol_names, dir->volumecounter); | 172 | vol_names, dir->volumecounter); |
171 | return theent; | 173 | return theent; |
172 | } | 174 | } |
173 | } | 175 | } |