Created
March 22, 2012 20:36
-
-
Save arrbee/2163858 to your computer and use it in GitHub Desktop.
Alternative rewrite for test_helpers.c:copy_file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int copy_file(const char *src, const char *dst) | |
{ | |
git_buf source_buf = GIT_BUF_INIT; | |
git_file dst_fd; | |
int error = GIT_ERROR; | |
if (git_futils_readbuffer(&source_buf, src) < GIT_SUCCESS) | |
return GIT_ENOTFOUND; | |
dst_fd = git_futils_creat_withpath(dst, 0777, 0666); | |
if (dst_fd < 0) | |
error = dst_fd; | |
else | |
error = p_write(dst_fd, source_buf.ptr, source_buf.size); | |
git_buf_free(&source_buf); | |
if (dst_fd >= 0) | |
p_close(dst_fd); | |
return error; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment