diff options
| author | nulltoken <emeric.fermas@gmail.com> | 2011-03-05 14:26:22 +0100 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-03-23 00:25:04 +0200 |
| commit | 29e1797c14c4c67f5f941130bdda835b8c74869e (patch) | |
| tree | 75ee70768f12ef5cb4d191d6a16e4fc81f6aaf88 /tests/test_helpers.c | |
| parent | 3fe9c60c6ad66d4637c7669c0661b5097918ddbd (diff) | |
| download | libgit2-29e1797c14c4c67f5f941130bdda835b8c74869e.tar.gz | |
Add remove_placeholders() test helper function which recursively removes marker files from a directory structure
Diffstat (limited to 'tests/test_helpers.c')
| -rw-r--r-- | tests/test_helpers.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_helpers.c b/tests/test_helpers.c index 1d345356a..760de238b 100644 --- a/tests/test_helpers.c +++ b/tests/test_helpers.c @@ -256,3 +256,31 @@ void close_temp_repo(git_repository *repo) git_repository_free(repo); 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); +} |
