Mercurial > hg > xmms-sid
comparison src/xs_support.c @ 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 |
comparison
equal
deleted
inserted
replaced
893:c835aa129e3b | 894:4697c5bd7025 |
---|---|
25 -- | 25 -- |
26 */ | 26 */ |
27 #include "xs_support.h" | 27 #include "xs_support.h" |
28 #include <stdarg.h> | 28 #include <stdarg.h> |
29 #include <ctype.h> | 29 #include <ctype.h> |
30 | 30 #ifndef __AUDACIOUS_NEWVFS__ |
31 #include <sys/types.h> | |
32 #include <sys/stat.h> | |
33 #include <unistd.h> | |
34 #endif | |
31 | 35 |
32 /* Error messages | 36 /* Error messages |
33 */ | 37 */ |
34 void xs_error(const char *fmt, ...) | 38 void xs_error(const char *fmt, ...) |
35 { | 39 { |
73 #endif | 77 #endif |
74 | 78 |
75 | 79 |
76 gboolean xs_is_dir_path(const gchar *path) | 80 gboolean xs_is_dir_path(const gchar *path) |
77 { | 81 { |
78 XSFile *fp = xs_fopen(path, "rb"); | 82 #ifndef __AUDACIOUS_NEWVFS__ |
79 if (fp != NULL) | 83 struct stat sb; |
80 { | 84 if (stat(path, &sb) < 0) |
81 xs_fclose(fp); | |
82 return FALSE; | 85 return FALSE; |
83 } | 86 |
84 else | 87 return (S_ISDIR(sb.st_mode)); |
85 return TRUE; | 88 #else |
89 // XXX | |
90 #endif | |
86 } | 91 } |
87 | 92 |
88 | 93 |
89 gchar *xs_get_dir_path(const gchar *path) | 94 gchar *xs_get_dir_path(const gchar *path) |
90 { | 95 { |
91 if (xs_is_dir_path(path)) | 96 #ifndef __AUDACIOUS_NEWVFS__ |
97 if (!xs_is_dir_path(path)) | |
92 return g_dirname(path); | 98 return g_dirname(path); |
93 else | 99 else |
94 return g_strdup(path); | 100 return g_strdup(path); |
101 #else | |
102 // XXX | |
103 #endif | |
95 } | 104 } |
96 | 105 |
97 | 106 |
98 guint16 xs_fread_be16(XSFile *f) | 107 guint16 xs_fread_be16(XSFile *f) |
99 { | 108 { |