summaryrefslogtreecommitdiff
path: root/wrapper.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2017-05-03 17:16:49 +0700
committerJunio C Hamano <gitster@pobox.com>2017-05-26 12:33:55 +0900
commit11dc1fcb3fa53f5a46486daa7cb38ed387153f2e (patch)
tree98bf996bbac5e5c0b85ee1673a83d14a8ae0fbab /wrapper.c
parent8e178ec4d072da4cd8f4449e17aef3aff5b57f6a (diff)
downloadgit-11dc1fcb3fa53f5a46486daa7cb38ed387153f2e.tar.gz
wrapper.c: add and use warn_on_fopen_errors()
In many places, Git warns about an inaccessible file after a fopen() failed. To discern these cases from other cases where we want to warn about inaccessible files, introduce a new helper specifically to test whether fopen() failed because the current user lacks the permission to open file in question. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/wrapper.c b/wrapper.c
index d837417709..20c25e7e65 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -418,6 +418,16 @@ FILE *fopen_for_writing(const char *path)
return ret;
}
+int warn_on_fopen_errors(const char *path)
+{
+ if (errno != ENOENT && errno != ENOTDIR) {
+ warn_on_inaccessible(path);
+ return -1;
+ }
+
+ return 0;
+}
+
int xmkstemp(char *template)
{
int fd;