Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
brechtsanders committed Aug 19, 2021
1 parent c4fc77c commit 089a67c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
10 changes: 10 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
0.2.12

2021-08-19 Brecht Sanders https://github.com/brechtsanders/

* fix dirtrav_recursive_delete() and dirtravw_recursive_delete() to delete as much as possible on failure

0.2.11

2021-08-18 Brecht Sanders https://github.com/brechtsanders/

* fix build for non-Windows operating systems

0.2.10

2021-08-18 Brecht Sanders https://github.com/brechtsanders/
Expand Down
2 changes: 1 addition & 1 deletion include/dirtrav_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ THE SOFTWARE.
/*! \brief minor version number */
#define DIRTRAV_VERSION_MINOR 2
/*! \brief micro version number */
#define DIRTRAV_VERSION_MICRO 11
#define DIRTRAV_VERSION_MICRO 12
/*! @} */

/*! \cond PRIVATE */
Expand Down
31 changes: 16 additions & 15 deletions src/dirtrav.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,39 +480,40 @@ DLL_EXPORT_DIRTRAV int DIRTRAVFN(traverse_path_parts) (const DIRCHAR* startpath,
int DIRTRAVFN(recursive_delete_file_callback) (DIRTRAVFN(entry) info)
{
#ifdef _WIN32
if (DIRWINFN(DeleteFile)(info->fullpath))
if (!DIRWINFN(DeleteFile)(info->fullpath))
#else
if (unlink(info->fullpath) == 0)
if (unlink(info->fullpath) != 0)
#endif
return 0;
return 1;
*((int*)info->callbackdata) |= 1;
return 0;
}

int DIRTRAVFN(recursive_delete_folder_callback) (DIRTRAVFN(entry) info)
{
#ifdef _WIN32
if (DIRWINFN(RemoveDirectory)(info->fullpath))
if (!DIRWINFN(RemoveDirectory)(info->fullpath))
#else
if (rmdir(info->fullpath) == 0)
if (rmdir(info->fullpath) != 0)
#endif
return 0;
return 2;
*((int*)info->callbackdata) |= 2;
return 0;
}

int DIRTRAVFN(recursive_delete) (const DIRCHAR* path)
{
int result;
int status = 0;
if (!path || !*path)
return -2;
if ((result = DIRTRAVFN(traverse_directory)(path, DIRTRAVFN(recursive_delete_file_callback), NULL, DIRTRAVFN(recursive_delete_folder_callback), NULL)) == 0) {
DIRTRAVFN(traverse_directory)(path, DIRTRAVFN(recursive_delete_file_callback), NULL, DIRTRAVFN(recursive_delete_folder_callback), (void*)&status);
if (status != 0)
return status;
#ifdef _WIN32
if (!DIRWINFN(RemoveDirectory)(path))
if (!DIRWINFN(RemoveDirectory)(path))
#else
if (rmdir(path) != 0)
if (rmdir(path) != 0)
#endif
return -1;
}
return result;
return (2 | 4);
return 0;
}

int DIRTRAVFN(make_full_path_callback) (DIRTRAVFN(entry) info)
Expand Down

0 comments on commit 089a67c

Please sign in to comment.