comparison 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
comparison
equal deleted inserted replaced
892:f1b33b5e153d 893:c835aa129e3b
69 return -1; 69 return -1;
70 70
71 return pos; 71 return pos;
72 } 72 }
73 #endif 73 #endif
74
75
76 gboolean xs_is_dir_path(const gchar *path)
77 {
78 XSFile *fp = xs_fopen(path, "rb");
79 if (fp != NULL)
80 {
81 xs_fclose(fp);
82 return FALSE;
83 }
84 else
85 return TRUE;
86 }
87
88
89 gchar *xs_get_dir_path(const gchar *path)
90 {
91 if (xs_is_dir_path(path))
92 return g_dirname(path);
93 else
94 return g_strdup(path);
95 }
74 96
75 97
76 guint16 xs_fread_be16(XSFile *f) 98 guint16 xs_fread_be16(XSFile *f)
77 { 99 {
78 return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f)); 100 return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f));