Avoid misleading success message on error
[git.git] / git-compat-util.h
index 4185b12..0c98c99 100644 (file)
@@ -84,6 +84,28 @@ static inline void *xcalloc(size_t nmemb, size_t size)
        return ret;
 }
 
+static inline ssize_t xread(int fd, void *buf, size_t len)
+{
+       ssize_t nr;
+       while (1) {
+               nr = read(fd, buf, len);
+               if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
+                       continue;
+               return nr;
+       }
+}
+
+static inline ssize_t xwrite(int fd, const void *buf, size_t len)
+{
+       ssize_t nr;
+       while (1) {
+               nr = write(fd, buf, len);
+               if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
+                       continue;
+               return nr;
+       }
+}
+
 /* Sane ctype - no locale, and works with signed chars */
 #undef isspace
 #undef isdigit
@@ -110,4 +132,7 @@ static inline int sane_case(int x, int high)
        return x;
 }
 
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 256
+#endif
 #endif