/*
- * Copyright (C) 1995-2005, Index Data ApS
+ * Copyright (C) 1995-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tpath.c,v 1.7 2006-04-26 09:40:43 adam Exp $
+ * $Id: tpath.c,v 1.10 2006-06-08 10:26:10 adam Exp $
*/
/**
* \file tpath.c
- * \brief Implements path fopen
+ * \brief File Path utilities
*/
#if HAVE_CONFIG_H
#include <yaz/tpath.h>
#include <yaz/log.h>
#include <sys/types.h>
-#if HAVE_SYS_STAT_H
#include <sys/stat.h>
-#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
len = path_sep - path;
else
len = strlen(path);
+ /* is path is relative and base is to be used */
if (!strchr ("/\\", *path) && base)
{
+ /* yes: make base the first part */
strcpy (fullpath, base);
slen = strlen(fullpath);
fullpath[slen++] = '/';
}
memcpy (fullpath+slen, path, len);
slen += len;
- if (!strchr("/\\", fullpath[slen-1]))
+ if (slen > 0 && !strchr("/\\", fullpath[slen-1]))
fullpath[slen++] = '/';
}
strcpy (fullpath+slen, fname);