mirror of https://github.com/axmolengine/axmol.git
Merge pull request #9401 from minggo/iss9398-not-close-dir
invoke closedir after invoke opendir
This commit is contained in:
commit
dd5659b6eb
|
@ -1102,17 +1102,28 @@ bool FileUtils::createDirectory(const std::string& path)
|
|||
|
||||
// Create path recursively
|
||||
subpath = "";
|
||||
for (int i = 0; i < dirs.size(); ++i) {
|
||||
for (int i = 0; i < dirs.size(); ++i)
|
||||
{
|
||||
subpath += dirs[i];
|
||||
dir = opendir(subpath.c_str());
|
||||
|
||||
if (!dir)
|
||||
{
|
||||
// directory doesn't exist, should create a new one
|
||||
|
||||
int ret = mkdir(subpath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
if (ret != 0 && (errno != EEXIST))
|
||||
{
|
||||
// current directory can not be created, sub directories can not be created too
|
||||
// should return
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// directory exists, should close opened dir
|
||||
closedir(dir);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
|
@ -1122,8 +1133,9 @@ bool FileUtils::createDirectory(const std::string& path)
|
|||
static int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
|
||||
{
|
||||
auto ret = remove(fpath);
|
||||
if (ret) {
|
||||
log("Fail to remove:%s ",fpath);
|
||||
if (ret)
|
||||
{
|
||||
log("Fail to remove: %s ",fpath);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue