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:
parent
afd5174eaf
commit
ed64a663a0
2 changed files with 6 additions and 13 deletions
12
apps/misc.c
12
apps/misc.c
|
@ -1115,12 +1115,8 @@ bool file_exists(const char *file)
|
|||
bool dir_exists(const char *path)
|
||||
{
|
||||
DIR* d = opendir(path);
|
||||
bool retval;
|
||||
if (d != NULL) {
|
||||
closedir(d);
|
||||
retval = true;
|
||||
} else {
|
||||
retval = false;
|
||||
}
|
||||
return retval;
|
||||
if (!d)
|
||||
return false;
|
||||
closedir(d);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -590,17 +590,14 @@ static void adjust_cursor(void)
|
|||
cursor = max_cursor;
|
||||
}
|
||||
|
||||
static bool check_dir(char *folder)
|
||||
static bool check_dir(const char *folder)
|
||||
{
|
||||
DIR *dir = opendir(folder);
|
||||
if (!dir && strcmp(folder, "/"))
|
||||
if (strcmp(folder, "/") && !dir_exists(folder))
|
||||
{
|
||||
int rc = mkdir(folder);
|
||||
if(rc < 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
closedir(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue