diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2012-07-18 23:26:21 +0200 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2012-07-30 21:20:51 +0200 |
| commit | 8c655cfdc09b0be326e7d9f190ae728d4e2bdc87 (patch) | |
| tree | 668b5e8506dd8eea506067535f593a4c2524d021 /apps/misc.c | |
| parent | 9dd2eb49bec19de06c5cfd168a0e4cd4dc44c867 (diff) | |
| download | rockbox-8c655cfdc09b0be326e7d9f190ae728d4e2bdc87.zip rockbox-8c655cfdc09b0be326e7d9f190ae728d4e2bdc87.tar.gz rockbox-8c655cfdc09b0be326e7d9f190ae728d4e2bdc87.tar.bz2 rockbox-8c655cfdc09b0be326e7d9f190ae728d4e2bdc87.tar.xz | |
New GUI browser to select one (or more) folders.
The browser lets the user pick one or more directories in a convinient
GUI browser. The initial directory list is read from a string
(separated by colons) and the resulting list is written back to the same
string (again separated by colons).
Note: The work was initially done by Jonathan Gordon, however I changed
it substantially so I claim autorship.
This selector is going to be used for autoresume and database scan folders.
Change-Id: Id1d3186dad783411eb5c6056ce93f5b6123c7aa0
Diffstat (limited to 'apps/misc.c')
| -rw-r--r-- | apps/misc.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/apps/misc.c b/apps/misc.c index 5b20b35..d7d4bdd 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -1075,6 +1075,37 @@ void format_time(char* buf, int buf_size, long t) } } +/** + * Splits str at each occurence of split_char and puts the substrings into vector, + * but at most vector_lenght items. Empty substrings are ignored. + * + * Modifies str by replacing each split_char following a substring with nul + * + * Returns the number of substrings found, i.e. the number of valid strings + * in vector + */ +int split_string(char *str, const char split_char, char *vector[], const int vector_length) +{ + int i; + char *p = str; + + /* skip leading splitters */ + while(*p == split_char) p++; + + /* *p in the condition takes care of trailing splitters */ + for(i = 0; p && *p && i < vector_length; i++) + { + vector[i] = p; + if ((p = strchr(p, split_char))) + { + *p++ = '\0'; + while(*p == split_char) p++; /* skip successive splitters */ + } + } + + return i; +} + /** Open a UTF-8 file and set file descriptor to first byte after BOM. * If no BOM is present this behaves like open(). |