changeset 894:4697c5bd7025

Improve the path helper functions.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 09 Nov 2012 08:20:55 +0200
parents c835aa129e3b
children b6e069c9c000
files src/xs_support.c
diffstat 1 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_support.c	Fri Nov 09 07:47:05 2012 +0200
+++ b/src/xs_support.c	Fri Nov 09 08:20:55 2012 +0200
@@ -27,7 +27,11 @@
 #include "xs_support.h"
 #include <stdarg.h>
 #include <ctype.h>
-
+#ifndef __AUDACIOUS_NEWVFS__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#endif
 
 /* Error messages
  */
@@ -75,23 +79,28 @@
 
 gboolean xs_is_dir_path(const gchar *path)
 {
-    XSFile *fp = xs_fopen(path, "rb");
-    if (fp != NULL)
-    {
-        xs_fclose(fp);
+#ifndef __AUDACIOUS_NEWVFS__
+    struct stat sb;
+    if (stat(path, &sb) < 0)
         return FALSE;
-    }
-    else
-        return TRUE;
+
+    return (S_ISDIR(sb.st_mode));
+#else
+    // XXX
+#endif
 }
 
 
 gchar *xs_get_dir_path(const gchar *path)
 {
-    if (xs_is_dir_path(path))
+#ifndef __AUDACIOUS_NEWVFS__
+    if (!xs_is_dir_path(path))
         return g_dirname(path);
     else
         return g_strdup(path);
+#else
+    // XXX
+#endif
 }