[Mesa-dev] [RFC 14/20] mesa: add _mesa_mkdir helper to imports.h

Tapani Pälli tapani.palli at intel.com
Mon Jun 2 05:05:55 PDT 2014


Function provides platform agnostic way to create a directory. This
will be used by the binary shader cache.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 src/mesa/main/imports.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index af780b2..db588a7 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -465,6 +465,24 @@ _mesa_little_endian(void)
    return *((const GLubyte *) &ui);
 }
 
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+
+static inline int
+_mesa_mkdir(const char *path)
+{
+#ifdef _WIN32
+   if (_mkdir(path) != 0)
+      return errno;
+   return 0;
+#else
+   if (mkdir(path, 0775) != 0)
+      return errno;
+   return 0;
+#endif
+}
+
 
 
 /**********************************************************************
-- 
1.8.3.1



More information about the mesa-dev mailing list