2 * Copyright (c) 1995-2003, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: tpath.c,v 1.9 2003-01-06 08:20:28 adam Exp $
16 #include <yaz/tpath.h>
19 FILE *yaz_path_fopen(const char *path, const char *name, const char *mode)
21 return yaz_fopen (path, name, mode, 0);
24 int yaz_fclose (FILE *f)
29 FILE *yaz_fopen(const char *path, const char *name, const char *mode,
38 const char *path_sep = 0;
45 /* somewhat dirty since we have to consider Windows
48 if (strchr ("/\\.", *path))
50 path_sep = strchr (path+1, ':');
52 else if (path[0] && path[1])
53 path_sep = strchr (path+2, ':');
55 len = path_sep - path;
58 if (!strchr ("/\\", *path) && base)
64 memcpy (spath+slen, path, len);
66 if (!strchr("/\\", spath[slen-1]))
69 strcpy (spath+slen, name);
70 if ((f = fopen(spath, mode)))
80 int yaz_is_abspath (const char *p)
87 if (*p && p[1] == ':' && isalpha(*p))