eina: Check if we can open dir first

SVN revision: 78172
This commit is contained in:
Sebastian Dransfeld 2012-10-18 09:12:14 +00:00
parent 39d7882866
commit b6add7a518
1 changed files with 6 additions and 6 deletions

View File

@ -889,6 +889,7 @@ eina_file_stat_ls(const char *dir)
#ifdef HAVE_DIRENT_H
Eina_File_Direct_Iterator *it;
size_t length;
DIR *dirp;
EINA_SAFETY_ON_NULL_RETURN_VAL(dir, NULL);
@ -896,18 +897,17 @@ eina_file_stat_ls(const char *dir)
if (length < 1)
return NULL;
dirp = opendir(dir);
if (!dirp)
return NULL;
it = calloc(1, sizeof(Eina_File_Direct_Iterator) + length);
if (!it)
return NULL;
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
it->dirp = opendir(dir);
if (!it->dirp)
{
free(it);
return NULL;
}
it->dirp = dirp;
if (length + _eina_name_max(it->dirp) + 2 >= EINA_PATH_MAX)
{