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:
parent
e78abe09af
commit
afb6e012a9
|
@ -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>
|
2010-07-16 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||||
|
|
||||||
* win32/bin/util/unzip.exe: Added to bin/utils to use it to unzip
|
* win32/bin/util/unzip.exe: Added to bin/utils to use it to unzip
|
||||||
|
|
|
@ -164,10 +164,16 @@ Pandora_File::removeDir (const string filepath) {
|
||||||
/*If its a file, delete it*/
|
/*If its a file, delete it*/
|
||||||
if(errno == ENOTDIR) {
|
if(errno == ENOTDIR) {
|
||||||
if (remove (filepath.c_str ()) == -1) {
|
if (remove (filepath.c_str ()) == -1) {
|
||||||
|
|
||||||
|
/*Close dir oppened*/
|
||||||
|
closedir(dir);
|
||||||
return DELETE_ERROR;
|
return DELETE_ERROR;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
/*Close dir oppened*/
|
||||||
|
closedir(dir);
|
||||||
return DELETE_ERROR;
|
return DELETE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,13 +193,20 @@ Pandora_File::removeDir (const string filepath) {
|
||||||
case S_IFDIR:
|
case S_IFDIR:
|
||||||
/*If tmp is a folder, recursive delete*/
|
/*If tmp is a folder, recursive delete*/
|
||||||
if ( (strcmp(dir_content->d_name,".") != 0) && (strcmp(dir_content->d_name,"..") != 0)){
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
/*If tmp is a file, it will be deleted*/
|
/*If tmp is a file, it will be deleted*/
|
||||||
if (remove (tmp.c_str ()) == -1) {
|
if (remove (tmp.c_str ()) == -1) {
|
||||||
|
/*Close dir oppened*/
|
||||||
|
closedir(dir);
|
||||||
return DELETE_ERROR;
|
return DELETE_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -205,6 +218,8 @@ Pandora_File::removeDir (const string filepath) {
|
||||||
|
|
||||||
/*When the folder is empty, delete the folder*/
|
/*When the folder is empty, delete the folder*/
|
||||||
if (rmdir (filepath.c_str ()) == -1) {
|
if (rmdir (filepath.c_str ()) == -1) {
|
||||||
|
/*Close dir oppened*/
|
||||||
|
closedir(dir);
|
||||||
return DELETE_ERROR;
|
return DELETE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue