summaryrefslogtreecommitdiff
path: root/tests/test_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_helpers.c')
-rw-r--r--tests/test_helpers.c75
1 files changed, 38 insertions, 37 deletions
diff --git a/tests/test_helpers.c b/tests/test_helpers.c
index 760de238b..5c2ccee15 100644
--- a/tests/test_helpers.c
+++ b/tests/test_helpers.c
@@ -32,17 +32,17 @@ int write_object_data(char *file, void *data, size_t len)
git_file fd;
int ret;
- if ((fd = gitfo_creat(file, S_IREAD | S_IWRITE)) < 0)
+ if ((fd = p_creat(file, S_IREAD | S_IWRITE)) < 0)
return -1;
- ret = gitfo_write(fd, data, len);
- gitfo_close(fd);
+ ret = p_write(fd, data, len);
+ p_close(fd);
return ret;
}
int write_object_files(const char *odb_dir, object_data *d)
{
- if (gitfo_mkdir(odb_dir, 0755) < 0) {
+ if (p_mkdir(odb_dir, 0755) < 0) {
int err = errno;
fprintf(stderr, "can't make directory \"%s\"", odb_dir);
if (err == EEXIST)
@@ -51,7 +51,7 @@ int write_object_files(const char *odb_dir, object_data *d)
return -1;
}
- if ((gitfo_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) {
+ if ((p_mkdir(d->dir, 0755) < 0) && (errno != EEXIST)) {
fprintf(stderr, "can't make object directory \"%s\"\n", d->dir);
return -1;
}
@@ -65,16 +65,16 @@ int write_object_files(const char *odb_dir, object_data *d)
int remove_object_files(const char *odb_dir, object_data *d)
{
- if (gitfo_unlink(d->file) < 0) {
+ if (p_unlink(d->file) < 0) {
fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
return -1;
}
- if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
+ if ((p_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir);
return -1;
}
- if (gitfo_rmdir(odb_dir) < 0) {
+ if (p_rmdir(odb_dir) < 0) {
fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir);
return -1;
}
@@ -104,14 +104,14 @@ int remove_loose_object(const char *repository_folder, git_object *object)
ptr += GIT_OID_HEXSZ + 1;
*ptr = 0;
- if (gitfo_unlink(full_path) < 0) {
+ if (p_unlink(full_path) < 0) {
fprintf(stderr, "can't delete object file \"%s\"\n", full_path);
return -1;
}
*top_folder = 0;
- if ((gitfo_rmdir(full_path) < 0) && (errno != ENOTEMPTY)) {
+ if ((p_rmdir(full_path) < 0) && (errno != ENOTEMPTY)) {
fprintf(stderr, "can't remove object directory \"%s\"\n", full_path);
return -1;
}
@@ -134,44 +134,44 @@ int cmp_objects(git_rawobj *o, object_data *d)
int copy_file(const char *src, const char *dst)
{
- gitfo_buf source_buf;
+ git_fbuffer source_buf;
git_file dst_fd;
int error = GIT_ERROR;
- if (gitfo_read_file(&source_buf, src) < GIT_SUCCESS)
+ if (git_futils_readbuffer(&source_buf, src) < GIT_SUCCESS)
return GIT_ENOTFOUND;
- dst_fd = gitfo_creat_force(dst, 0644);
+ dst_fd = git_futils_creat_withpath(dst, 0644);
if (dst_fd < 0)
goto cleanup;
- error = gitfo_write(dst_fd, source_buf.data, source_buf.len);
+ error = p_write(dst_fd, source_buf.data, source_buf.len);
cleanup:
- gitfo_free_buf(&source_buf);
- gitfo_close(dst_fd);
+ git_futils_freebuffer(&source_buf);
+ p_close(dst_fd);
return error;
}
int cmp_files(const char *a, const char *b)
{
- gitfo_buf buf_a, buf_b;
+ git_fbuffer buf_a, buf_b;
int error = GIT_ERROR;
- if (gitfo_read_file(&buf_a, a) < GIT_SUCCESS)
+ if (git_futils_readbuffer(&buf_a, a) < GIT_SUCCESS)
return GIT_ERROR;
- if (gitfo_read_file(&buf_b, b) < GIT_SUCCESS) {
- gitfo_free_buf(&buf_a);
+ if (git_futils_readbuffer(&buf_b, b) < GIT_SUCCESS) {
+ git_futils_freebuffer(&buf_a);
return GIT_ERROR;
}
if (buf_a.len == buf_b.len && !memcmp(buf_a.data, buf_b.data, buf_a.len))
error = GIT_SUCCESS;
- gitfo_free_buf(&buf_a);
- gitfo_free_buf(&buf_b);
+ git_futils_freebuffer(&buf_a);
+ git_futils_freebuffer(&buf_b);
return error;
}
@@ -182,11 +182,11 @@ static int remove_filesystem_element_recurs(void *GIT_UNUSED(nil), char *path)
GIT_UNUSED_ARG(nil);
- error = gitfo_isdir(path);
+ error = git_futils_isdir(path);
if (error == GIT_SUCCESS) {
size_t root_size = strlen(path);
- error = gitfo_dirent(path, GIT_PATH_MAX, remove_filesystem_element_recurs, NULL);
+ error = git_futils_direach(path, GIT_PATH_MAX, remove_filesystem_element_recurs, NULL);
if (error < GIT_SUCCESS)
return error;
@@ -194,7 +194,7 @@ static int remove_filesystem_element_recurs(void *GIT_UNUSED(nil), char *path)
return rmdir(path);
}
- return gitfo_unlink(path);
+ return p_unlink(path);
}
int rmdir_recurs(const char *directory_path)
@@ -214,10 +214,10 @@ static int copy_filesystem_element_recurs(void *_data, char *source)
copydir_data *data = (copydir_data *)_data;
data->dst[data->dst_len] = 0;
- git__joinpath(data->dst, data->dst, source + data->src_len);
+ git_path_join(data->dst, data->dst, source + data->src_len);
- if (gitfo_isdir(source) == GIT_SUCCESS)
- return gitfo_dirent(source, GIT_PATH_MAX, copy_filesystem_element_recurs, _data);
+ if (git_futils_isdir(source) == GIT_SUCCESS)
+ return git_futils_direach(source, GIT_PATH_MAX, copy_filesystem_element_recurs, _data);
return copy_file(source, data->dst);
}
@@ -229,13 +229,14 @@ int copydir_recurs(const char *source_directory_path, const char *destination_di
copydir_data data;
/* Source has to exist, Destination hast to _not_ exist */
- if (gitfo_isdir(source_directory_path) || !gitfo_isdir(destination_directory_path))
+ if (git_futils_isdir(source_directory_path) != GIT_SUCCESS ||
+ git_futils_isdir(destination_directory_path) == GIT_SUCCESS)
return GIT_EINVALIDPATH;
- git__joinpath(source_buffer, source_directory_path, "");
+ git_path_join(source_buffer, source_directory_path, "");
data.src_len = strlen(source_buffer);
- git__joinpath(dest_buffer, destination_directory_path, "");
+ git_path_join(dest_buffer, destination_directory_path, "");
data.dst = dest_buffer;
data.dst_len = strlen(dest_buffer);
@@ -262,14 +263,14 @@ 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_futils_isdir(path))
+ return git_futils_direach(path, GIT_PATH_MAX, remove_placeholders_recurs, data);
- if (git__basename_r(passed_filename, sizeof(passed_filename), path) < GIT_SUCCESS)
- return GIT_EINVALIDPATH;
+ if (git_path_basename_r(passed_filename, sizeof(passed_filename), path) < GIT_SUCCESS)
+ return GIT_EINVALIDPATH;
if (!strcmp(data, passed_filename))
- return gitfo_unlink(path);
+ return p_unlink(path);
return GIT_SUCCESS;
}
@@ -278,7 +279,7 @@ int remove_placeholders(char *directory_path, char *filename)
{
char buffer[GIT_PATH_MAX];
- if (gitfo_isdir(directory_path))
+ if (git_futils_isdir(directory_path))
return GIT_EINVALIDPATH;
strcpy(buffer, directory_path);