Mercurial > hg > xmms-sid
diff src/xs_support.c @ 893:c835aa129e3b
Add two new utility functions for checking whether a given path is a
directory or not.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 09 Nov 2012 07:47:05 +0200 |
parents | 7bde71a1ea91 |
children | 4697c5bd7025 |
line wrap: on
line diff
--- a/src/xs_support.c Fri Nov 09 07:46:29 2012 +0200 +++ b/src/xs_support.c Fri Nov 09 07:47:05 2012 +0200 @@ -73,6 +73,28 @@ #endif +gboolean xs_is_dir_path(const gchar *path) +{ + XSFile *fp = xs_fopen(path, "rb"); + if (fp != NULL) + { + xs_fclose(fp); + return FALSE; + } + else + return TRUE; +} + + +gchar *xs_get_dir_path(const gchar *path) +{ + if (xs_is_dir_path(path)) + return g_dirname(path); + else + return g_strdup(path); +} + + guint16 xs_fread_be16(XSFile *f) { return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f));