Mercurial > hg > xmms-sid
changeset 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 | f1b33b5e153d |
children | 4697c5bd7025 |
files | src/xs_support.c src/xs_support.h |
diffstat | 2 files changed, 25 insertions(+), 0 deletions(-) [+] |
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));
--- a/src/xs_support.h Fri Nov 09 07:46:29 2012 +0200 +++ b/src/xs_support.h Fri Nov 09 07:47:05 2012 +0200 @@ -124,6 +124,9 @@ gboolean xs_fload_buffer_path(const gchar *ppath, const gchar *pfilename, guint8 **pbuf, size_t *bufSize, const size_t maxSize, gboolean failMaxSize); +gboolean xs_is_dir_path(const gchar *path); +gchar *xs_get_dir_path(const gchar *path); + /* Error messages and debugging */