2010-07-16 Dario Rodriguez <dario.rodriguez@artica.es>

* misc/pandora_file.cc: fixed unclosed directory with function closedir
	and control posible delete errors.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3018 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
darode 2010-07-16 12:28:49 +00:00
parent e78abe09af
commit afb6e012a9
2 changed files with 21 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2010-07-16 Dario Rodriguez <dario.rodriguez@artica.es>
* misc/pandora_file.cc: fixed unclosed directory with function closedir
and control posible delete errors.
2010-07-16 Dario Rodriguez <dario.rodriguez@artica.es>
* win32/bin/util/unzip.exe: Added to bin/utils to use it to unzip

View File

@ -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;
}