diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-12-18 21:55:52 +0000 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-12-18 21:55:52 +0000 |
commit | 4ccb69e98ecdca80bad9e656d686b0086ca3149a (patch) | |
tree | 4645752244ed87fdc89d94dec92d67847185bab0 /src | |
parent | 922ee9ab4045c81d6874b07fdb8aadc551f824d2 (diff) | |
download | xine-lib-4ccb69e98ecdca80bad9e656d686b0086ca3149a.tar.gz xine-lib-4ccb69e98ecdca80bad9e656d686b0086ca3149a.tar.bz2 |
Clean up recursive mkdir().
Diffstat (limited to 'src')
-rw-r--r-- | src/input/input_cdda.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index e658e30ca..ed6f2b4f9 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -1283,39 +1283,29 @@ static void _cdda_mkdir_safe(xine_t *xine, char *path) { } /* - * Make recursive directory creation + * Make recursive directory creation (given an absolute pathname) */ -static void _cdda_mkdir_recursive_safe(xine_t *xine, char *path) { - char *p, *pp; - char buf[XINE_PATH_MAX + XINE_NAME_MAX + 1] = { 0, }; - char buf2[XINE_PATH_MAX + XINE_NAME_MAX + 1] = { 0, }; - - if(path == NULL) +static void _cdda_mkdir_recursive_safe (xine_t *xine, char *path) +{ + if (!path) return; - snprintf(buf, sizeof(buf), "%s", path); - pp = buf; - while((p = xine_strsep(&pp, "/")) != NULL) { - if(p && strlen(p)) { - -#ifdef WIN32 - if (*buf2 != '\0') { -#endif - - int size = strlen(buf2); - snprintf(buf2 + size, sizeof(buf2) - size, "/%s", p); - -#ifdef WIN32 - } - else { - snprintf(buf2, sizeof(buf2), "%s", p); - } + char buf[strlen (path) + 1]; + strcpy (buf, path); + char *p = strchr (buf, '/') ? : buf; -#endif /* WIN32 */ + do + { + while (*p++ == '/') /**/; + p = strchr (p, '/'); + if (p) + *p = 0; + _cdda_mkdir_safe (xine, buf); + if (p) + *p = '/'; + } while (p); - _cdda_mkdir_safe(xine, buf2); - } - } + return 0; } /* |