Ejemplo n.º 1
0
static int
BATlocation(str *fnme, int *bid)
{
	/* this function was formerly ATTlocation in removed file
	 * monetdb5/modules/mal/attach.c */
	BAT *b = BBPquickdesc(*bid, FALSE);
	char path[BUFSIZ], *s;

	*fnme = NULL;
	if (b == NULL || (!b->T->heap.filename && !b->H->heap.filename))
		return 0;

	s = GDKfilepath(b->T->heap.farmid, BATDIR,
			(b->T->heap.filename ? b->T->heap.filename : b->H->heap.filename), 0);
	if (!MT_path_absolute(s)) {
		snprintf(path, BUFSIZ, "%s%c%s", GDKgetenv("gdk_dbpath"),
			 DIR_SEP, s);
	} else {
		snprintf(path, sizeof(path), "%s", s);
	}
	GDKfree(s);
	s = strrchr(path, '.');
	if (s)
		*s = 0;
	*fnme = GDKstrdup(path);
	return 1;
}
Ejemplo n.º 2
0
static str
absolute_path(str s)
{
	if (!MT_path_absolute(s)) {
		str ret = (str) GDKmalloc(strlen(s) + strlen(monet_cwd) + 2);

		if (ret)
			sprintf(ret, "%s%c%s", monet_cwd, DIR_SEP, s);
		return ret;
	}
	return GDKstrdup(s);
}
Ejemplo n.º 3
0
static int
GDKenvironment(str dbpath)
{
	if (dbpath == 0) {
		fprintf(stderr, "!GDKenvironment: database name missing.\n");
		return 0;
	}
	if (strlen(dbpath) >= PATHLENGTH) {
		fprintf(stderr, "!GDKenvironment: database name too long.\n");
		return 0;
	}
	if (!MT_path_absolute(dbpath)) {
		fprintf(stderr, "!GDKenvironment: directory not an absolute path: %s.\n", dbpath);
		return 0;
	}
	strncpy(GDKdbpathStr, dbpath, PATHLENGTH);
	/* make coverity happy: */
	GDKdbpathStr[PATHLENGTH - 1] = 0;
	return 1;
}