diff common/portpath.c @ 176:70d627e9e801

New portability function to test if a file is an directory.
author Sascha Wilde <wilde@intevation.de>
date Tue, 25 Mar 2014 16:45:32 +0100
parents 3343ddf43f42
children 17e1c8f37d72
line wrap: on
line diff
--- a/common/portpath.c	Tue Mar 25 16:31:52 2014 +0100
+++ b/common/portpath.c	Tue Mar 25 16:45:32 2014 +0100
@@ -60,3 +60,21 @@
   else
     return false;
 }
+
+bool
+port_isdir(char *path)
+{
+  int ret;
+#ifndef _WIN32
+  struct stat sb;
+  ret = stat(path, &sb);
+#else
+  struct _stat sb;
+  ret = _stat(path, &sb);
+#endif
+
+  if ((ret == 0) && S_ISDIR(sb.st_mode))
+    return true;
+  else
+    return false;
+}

http://wald.intevation.org/projects/trustbridge/