wildmatch: remove unused wildopts parameter
[gitweb.git] / wrapper.c
index 708e98a96585f8f9a800e9ddae942b94ea7372b8..4632c7d4c08c3127c4017c98c0983871f0236d93 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -418,6 +418,32 @@ FILE *fopen_for_writing(const char *path)
        return ret;
 }
 
+static void warn_on_inaccessible(const char *path)
+{
+       warning_errno(_("unable to access '%s'"), path);
+}
+
+int warn_on_fopen_errors(const char *path)
+{
+       if (errno != ENOENT && errno != ENOTDIR) {
+               warn_on_inaccessible(path);
+               return -1;
+       }
+
+       return 0;
+}
+
+FILE *fopen_or_warn(const char *path, const char *mode)
+{
+       FILE *fp = fopen(path, mode);
+
+       if (fp)
+               return fp;
+
+       warn_on_fopen_errors(path);
+       return NULL;
+}
+
 int xmkstemp(char *template)
 {
        int fd;
@@ -576,11 +602,6 @@ int remove_or_warn(unsigned int mode, const char *file)
        return S_ISGITLINK(mode) ? rmdir_or_warn(file) : unlink_or_warn(file);
 }
 
-void warn_on_inaccessible(const char *path)
-{
-       warning_errno(_("unable to access '%s'"), path);
-}
-
 static int access_error_is_ok(int err, unsigned flag)
 {
        return (is_missing_file_error(err) ||