1
0
Fork 0
forked from len0rd/rockbox

make check_dir use dir_exists and slightly optimise the latter

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15744 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Kukla 2007-11-21 22:42:52 +00:00
parent afd5174eaf
commit ed64a663a0
2 changed files with 6 additions and 13 deletions

View file

@ -1115,12 +1115,8 @@ bool file_exists(const char *file)
bool dir_exists(const char *path) bool dir_exists(const char *path)
{ {
DIR* d = opendir(path); DIR* d = opendir(path);
bool retval; if (!d)
if (d != NULL) { return false;
closedir(d); closedir(d);
retval = true; return true;
} else {
retval = false;
}
return retval;
} }

View file

@ -590,17 +590,14 @@ static void adjust_cursor(void)
cursor = max_cursor; cursor = max_cursor;
} }
static bool check_dir(char *folder) static bool check_dir(const char *folder)
{ {
DIR *dir = opendir(folder); if (strcmp(folder, "/") && !dir_exists(folder))
if (!dir && strcmp(folder, "/"))
{ {
int rc = mkdir(folder); int rc = mkdir(folder);
if(rc < 0) if(rc < 0)
return false; return false;
return true;
} }
closedir(dir);
return true; return true;
} }