e72cf0100e06d6fadb7282d4e7eb2c592f320951 galt Mon Jul 4 13:08:35 2011 -0700 Adding parallel-fetch loading of remote bigDataUrl tracks using pthreads diff --git src/lib/portimpl.c src/lib/portimpl.c index 381ab91..2504145 100644 --- src/lib/portimpl.c +++ src/lib/portimpl.c @@ -92,56 +92,47 @@ { int result = mkdir (trashDirName, S_IRWXU | S_IRWXG | S_IRWXO); if (0 != result) errnoAbort("failed to create directory %s", trashDirName); } } void makeDirsOnPath(char *pathName) /* Create directory specified by pathName. If pathName contains * slashes, create directory at each level of path if it doesn't * already exist. Abort with error message if there's a problem. * (It's not considered a problem for the directory to already * exist. ) */ { -/* Save a copy of current directory. */ -char *curDir = cloneString(getCurrentDir()); + +/* shortcut for paths that already exist */ +if (fileExists(pathName)) + return; /* Return current directory. Abort if it fails. */ /* Make local copy of pathName. */ int len = strlen(pathName); char pathCopy[len+1]; strcpy(pathCopy, pathName); +/* Tolerate double-slashes in path, everyone else does it. */ + /* Start at root if it's an absolute path name. */ char *s = pathCopy, *e; -if (pathCopy[0] == '/') - { - setCurrentDir("/"); - ++s; - } +while (*s++ == '/') + /* do nothing */; -/* Step through it one slash at a time - changing directory if possible - * else making directory if possible, else dying. */ +/* Step through it one slash at a time + * making directory if possible, else dying. */ for (; !isEmpty(s); s = e) { /* Find end of this section and terminate string there. */ e = strchr(s, '/'); if (e != NULL) - *e++ = 0; - - if (s[0]!=0) /* Tolerate double-slash in path, everyone else does it. */ - /* Cd there. If that fails mkdir there and then cd there. */ - if (!maybeSetCurrentDir(s)) - { - if (!makeDir(s)) - { - break; - } - setCurrentDir(s); - } + *e = 0; + makeDir(pathCopy); + if (e != NULL) + *e++ = '/'; } -setCurrentDir(curDir); -freeMem(curDir); }