summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-03-06 16:14:31 -0800
committerRussell Belfer <arrbee@arrbee.com>2012-03-06 16:27:13 -0800
commitae9e29fde7e7d1c0c3e95bdabbb5c96fc71b1c71 (patch)
tree65d8215f898fc30b579b72d815e6adc78823dd6c /src/fileops.c
parentcb8a79617b15e347f26d21cedde0f2b8670c1876 (diff)
downloadlibgit2-ae9e29fde7e7d1c0c3e95bdabbb5c96fc71b1c71.tar.gz
Migrating diff to new error handling
Ended up migrating a bunch of upstream functions as well including vector, attr_file, and odb in order to get this to work right.
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/fileops.c b/src/fileops.c
index 4414c86c6..7ee39f1d5 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -37,7 +37,7 @@ int git_futils_mktmp(git_buf *path_out, const char *filename)
if ((fd = p_mkstemp(path_out->ptr)) < 0) {
giterr_set(GITERR_OS,
- "Failed to create temporary file '%s': %s", path_out->ptr, strerror(errno));
+ "Failed to create temporary file '%s'", path_out->ptr);
return -1;
}
@@ -53,8 +53,7 @@ int git_futils_creat_withpath(const char *path, const mode_t dirmode, const mode
fd = p_creat(path, mode);
if (fd < 0) {
- giterr_set(GITERR_OS,
- "Failed to create file '%s': %s", path, strerror(errno));
+ giterr_set(GITERR_OS, "Failed to create file '%s'", path);
return -1;
}
@@ -65,8 +64,7 @@ int git_futils_creat_locked(const char *path, const mode_t mode)
{
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, mode);
if (fd < 0) {
- giterr_set(GITERR_OS,
- "Failed to create locked file '%s': %s", path, strerror(errno));
+ giterr_set(GITERR_OS, "Failed to create locked file '%s'", path);
return -1;
}
@@ -115,10 +113,8 @@ int git_futils_readbuffer_updated(git_buf *buf, const char *path, time_t *mtime,
if (updated != NULL)
*updated = 0;
- if ((fd = p_open(path, O_RDONLY)) < 0) {
- giterr_set(GITERR_OS, "Failed to read file '%s': %s", path, strerror(errno));
- return (errno == ENOENT) ? GIT_ENOTFOUND : -1;
- }
+ if ((fd = git_futils_open_ro(path)) < 0)
+ return fd;
if (p_fstat(fd, &st) < 0 || S_ISDIR(st.st_mode) || !git__is_sizet(st.st_size+1)) {
close(fd);
@@ -154,8 +150,7 @@ int git_futils_readbuffer_updated(git_buf *buf, const char *path, time_t *mtime,
if (read_size < 0) {
close(fd);
- giterr_set(GITERR_OS, "Failed to read descriptor for %s: %s",
- path, strerror(errno));
+ giterr_set(GITERR_OS, "Failed to read descriptor for '%s'", path);
return -1;
}