diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index 26820bd65a..139600fee0 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,8 @@ +2010-07-16 Dario Rodriguez + + * misc/pandora_file.cc: fixed unclosed directory with function closedir + and control posible delete errors. + 2010-07-16 Dario Rodriguez * win32/bin/util/unzip.exe: Added to bin/utils to use it to unzip diff --git a/pandora_agents/win32/misc/pandora_file.cc b/pandora_agents/win32/misc/pandora_file.cc index b8f673da1f..9b8b110cff 100644 --- a/pandora_agents/win32/misc/pandora_file.cc +++ b/pandora_agents/win32/misc/pandora_file.cc @@ -164,10 +164,16 @@ Pandora_File::removeDir (const string filepath) { /*If its a file, delete it*/ if(errno == ENOTDIR) { if (remove (filepath.c_str ()) == -1) { + + /*Close dir oppened*/ + closedir(dir); return DELETE_ERROR; } return 0; } else { + + /*Close dir oppened*/ + closedir(dir); return DELETE_ERROR; } } @@ -187,13 +193,20 @@ Pandora_File::removeDir (const string filepath) { case S_IFDIR: /*If tmp is a folder, recursive delete*/ if ( (strcmp(dir_content->d_name,".") != 0) && (strcmp(dir_content->d_name,"..") != 0)){ - removeDir(tmp); + if( removeDir(tmp) == DELETE_ERROR ) { + + /*Close dir oppened*/ + closedir(dir); + return DELETE_ERROR; + } } break; default: /*If tmp is a file, it will be deleted*/ if (remove (tmp.c_str ()) == -1) { + /*Close dir oppened*/ + closedir(dir); return DELETE_ERROR; } break; @@ -205,6 +218,8 @@ Pandora_File::removeDir (const string filepath) { /*When the folder is empty, delete the folder*/ if (rmdir (filepath.c_str ()) == -1) { + /*Close dir oppened*/ + closedir(dir); return DELETE_ERROR; }