-
Notifications
You must be signed in to change notification settings - Fork 276
delete_directory fails silently if it contains subfolders #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5992efe
to
c7092f7
Compare
Would the |
src/util/file_util.cpp
Outdated
@@ -107,7 +107,13 @@ void delete_directory(const std::string &path) | |||
struct dirent *ent; | |||
|
|||
while((ent=readdir(dir))!=NULL) | |||
remove((path+"/"+ent->d_name).c_str()); | |||
{ | |||
std::string sub_path = path+"/"+ent->d_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sub_path=path...
src/util/file_util.cpp
Outdated
remove((path+"/"+ent->d_name).c_str()); | ||
{ | ||
std::string sub_path = path+"/"+ent->d_name; | ||
if(ent->d_type == DT_DIR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d_type==DT_DIR
src/util/file_util.cpp
Outdated
@@ -107,7 +107,13 @@ void delete_directory(const std::string &path) | |||
struct dirent *ent; | |||
|
|||
while((ent=readdir(dir))!=NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullptr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not my code. I fear that if I change this it will expand the context area and you'll then find something else above that you want me to change too.
c7092f7
to
3eaa6a3
Compare
I've fixed @peterschrammel's lint errors. Unfortunately I don't have a Windows environment set up to implement and test this behaviour on Windows. I only use this fix in regression tests in the security scanner repo though so any issues will be quickly apparent and won't affect core CBMC. |
I believe @kroening has a Windows environment (and there would be one available via AppVeyor). |
Does @kroening want to test the following code to see if it can delete a folder containing a sub-folder and some files? If this is going to take much more of my time though I'm probably just going to close this issue and give up. Shame you can't get an improvement into CBMC without having to fix other broken code around it. Makes things take so long that really shouldn't.
|
Did the previous code even work on Windows? unlink seems to be called with a path relative to the passed folder. |
I suggest to create a unit test for this in the /unit folder. So, we know at least if it works/worked/will-work-soon on all platforms. |
Code written and tested by @smowton for Windows has been added. |
a5caaf7
to
129a592
Compare
129a592
to
386c230
Compare
Thanks @NathanJPhillips and @smowton! |
386c230
to
5ae3b17
Compare
5ae3b17
to
d110db0
Compare
No description provided.