2 * Copyright (C) 1995-2005, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: tpath.c,v 1.6 2005-06-25 15:46:06 adam Exp $
9 * \brief Implements path fopen
20 #include <yaz/tpath.h>
23 FILE *yaz_path_fopen(const char *path, const char *name, const char *mode)
25 return yaz_fopen (path, name, mode, 0);
28 int yaz_fclose (FILE *f)
33 FILE *yaz_fopen(const char *path, const char *name, const char *mode,
42 const char *path_sep = 0;
49 /* somewhat dirty since we have to consider Windows
52 if (strchr ("/\\.", *path))
54 path_sep = strchr (path+1, ':');
56 else if (path[0] && path[1])
57 path_sep = strchr (path+2, ':');
59 len = path_sep - path;
62 if (!strchr ("/\\", *path) && base)
68 memcpy (spath+slen, path, len);
70 if (!strchr("/\\", spath[slen-1]))
73 strcpy (spath+slen, name);
74 if ((f = fopen(spath, mode)))
84 int yaz_is_abspath (const char *p)
91 if (*p && p[1] == ':' && isalpha(*p))
99 * indent-tabs-mode: nil
101 * vim: shiftwidth=4 tabstop=8 expandtab