mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-13 13:23:02 +00:00
Added rmdir_recurs(), a test helper function which recursively removes the content of a directory.
This commit is contained in:
parent
47d0db78bb
commit
3b3a10176e
@ -175,3 +175,29 @@ int cmp_files(const char *a, const char *b)
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static int remove_filesystem_element_recurs(void *GIT_UNUSED(nil), char *path)
|
||||
{
|
||||
char temp_path[GIT_PATH_MAX];
|
||||
int error = GIT_SUCCESS;
|
||||
|
||||
GIT_UNUSED_ARG(nil);
|
||||
|
||||
error = gitfo_isdir(path);
|
||||
if (error == GIT_SUCCESS)
|
||||
{
|
||||
strcpy(temp_path, path);
|
||||
error = gitfo_dirent(temp_path, sizeof(temp_path), remove_filesystem_element_recurs, NULL);
|
||||
if (error < GIT_SUCCESS)
|
||||
return error;
|
||||
|
||||
return rmdir(path);
|
||||
}
|
||||
|
||||
return gitfo_unlink(path);
|
||||
}
|
||||
|
||||
int rmdir_recurs(char *directory_path)
|
||||
{
|
||||
return remove_filesystem_element_recurs(NULL, directory_path);
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ extern int remove_loose_object(const char *odb_dir, git_object *object);
|
||||
|
||||
extern int cmp_files(const char *a, const char *b);
|
||||
extern int copy_file(const char *source, const char *dest);
|
||||
extern int rmdir_recurs(char *directory_path);
|
||||
|
||||
#endif
|
||||
/* INCLUDE_test_helpers_h__ */
|
||||
|
Loading…
Reference in New Issue
Block a user