diff options
author | Miller Puckette <millerpuckette@users.sourceforge.net> | 2008-05-22 18:25:27 +0000 |
---|---|---|
committer | Miller Puckette <millerpuckette@users.sourceforge.net> | 2008-05-22 18:25:27 +0000 |
commit | 619bf2d74ef3e5431cb6057698f324590368122b (patch) | |
tree | 6f94196bba4a6bd11bb51b2feb598e7d242aec16 /pd/src/s_path.c | |
parent | 7007d5067b69480ad5d61edee496a50b6114a0c1 (diff) |
0.42-0 test 01. No real work yet, just bug fixes and updates.
svn path=/trunk/; revision=9867
Diffstat (limited to 'pd/src/s_path.c')
-rw-r--r-- | pd/src/s_path.c | 24 |
1 files changed, 19 insertions, 5 deletions
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); |