Commit 29e1797c by nulltoken Committed by Vicent Marti

Add remove_placeholders() test helper function which recursively removes marker…

Add remove_placeholders() test helper function which recursively removes marker files from a directory structure
parent 3fe9c60c
...@@ -256,3 +256,31 @@ void close_temp_repo(git_repository *repo) ...@@ -256,3 +256,31 @@ void close_temp_repo(git_repository *repo)
git_repository_free(repo); git_repository_free(repo);
rmdir_recurs(TEMP_REPO_FOLDER); rmdir_recurs(TEMP_REPO_FOLDER);
} }
static int remove_placeholders_recurs(void *filename, char *path)
{
char passed_filename[GIT_PATH_MAX];
char *data = (char *)filename;
if (!gitfo_isdir(path))
return gitfo_dirent(path, GIT_PATH_MAX, remove_placeholders_recurs, data);
if (git__basename_r(passed_filename, sizeof(passed_filename), path) < GIT_SUCCESS)
return GIT_EINVALIDPATH;
if (!strcmp(data, passed_filename))
return gitfo_unlink(path);
return GIT_SUCCESS;
}
int remove_placeholders(char *directory_path, char *filename)
{
char buffer[GIT_PATH_MAX];
if (gitfo_isdir(directory_path))
return GIT_EINVALIDPATH;
strcpy(buffer, directory_path);
return remove_placeholders_recurs(filename, buffer);
}
...@@ -67,6 +67,7 @@ extern int cmp_files(const char *a, const char *b); ...@@ -67,6 +67,7 @@ extern int cmp_files(const char *a, const char *b);
extern int copy_file(const char *source, const char *dest); extern int copy_file(const char *source, const char *dest);
extern int rmdir_recurs(const char *directory_path); extern int rmdir_recurs(const char *directory_path);
extern int copydir_recurs(const char *source_directory_path, const char *destination_directory_path); extern int copydir_recurs(const char *source_directory_path, const char *destination_directory_path);
extern int remove_placeholders(char *directory_path, char *filename);
extern int open_temp_repo(git_repository **repo, const char *path); extern int open_temp_repo(git_repository **repo, const char *path);
extern void close_temp_repo(git_repository *repo); extern void close_temp_repo(git_repository *repo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment