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:
parent
afd5174eaf
commit
ed64a663a0
2 changed files with 6 additions and 13 deletions
10
apps/misc.c
10
apps/misc.c
|
|
@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue