From 619bf2d74ef3e5431cb6057698f324590368122b Mon Sep 17 00:00:00 2001 From: Miller Puckette Date: Thu, 22 May 2008 18:25:27 +0000 Subject: 0.42-0 test 01. No real work yet, just bug fixes and updates. svn path=/trunk/; revision=9867 --- pd/src/s_path.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'pd/src/s_path.c') diff --git a/pd/src/s_path.c b/pd/src/s_path.c index f59f09c7..ef441184 100644 --- a/pd/src/s_path.c +++ b/pd/src/s_path.c @@ -69,6 +69,24 @@ void sys_unbashfilename(const char *from, char *to) *to = 0; } +/* test if path is absolute or relative, based on leading /, env vars, ~, etc */ +int sys_isabsolutepath(const char *dir) +{ + if (dir[0] == '/' || dir[0] == '~' +#ifdef MSW + || dir[0] == '%' || (dir[1] == ':' && dir[2] == '/') +#endif + ) + { + return 1; + } + else + { + return 0; + } +} + + /******************* Utility functions used below ******************/ /*! @@ -250,11 +268,7 @@ int sys_trytoopenone(const char *dir, const char *name, const char* ext, int sys_open_absolute(const char *name, const char* ext, char *dirresult, char **nameresult, unsigned int size, int bin, int *fdp) { - if (name[0] == '/' -#ifdef MSW - || (name[1] == ':' && name[2] == '/') -#endif - ) + if (sys_isabsolutepath(name)) { char dirbuf[MAXPDSTRING]; int dirlen = (strrchr(name, '/') - name); -- cgit v1.2.1