Ejemplo n.º 1
0
Archive
arFrString(String name)
{
	static Table	tbl = 0;
	Archive		ar;
	FileName	fn;

	arDEBUG(dbOut, "Looking for archive \"%s\"\n", name);
	
	if (tbl == 0)
		tbl = tblNew((TblHashFun) strAHash, (TblEqFun) strAEqual);

	if ((ar = (Archive) tblElt(tbl, (TblKey) name, (TblElt) 0)) != 0)
		return ar;

	if ((fn = fileRdFind(libSearchPath(), name, FTYPE_AR_INT)) != 0)
		ar = arRead(fn);
	else if (fileIsOpenable((fn = arFileNameFrPath(name)), "r")) {
		ar = arRead(fn);
	}
	else {
		comsgWarning(NULL, ALDOR_W_CantUseArchive, name);
		ar = 0;
	}

	tblSetElt(tbl, (TblKey) name, (TblElt) ar);
	return ar;
}
Ejemplo n.º 2
0
void
testFile(void)
{
	FileName	 testFile;
	FILE		 *fout;

	printf("fileSetHandler:\n");
	fileSetHandler(fileSetHandler((FileErrorFun) 0));

	printf("pathInit:\n");
	pathInit();

	printf("fileRdFind: yabba -- ");
	testFile = fileRdFind(binSearchPath(), "yabba", "");
	if (testFile) 
		printf("dir \"%s\", name \"%s\", type \"%s\"\n",
			fnameDir(testFile),
			fnameName(testFile),
			fnameType(testFile));
	else
		printf("Not found\n");

	printf("fileRdFind: cat -- ");
	testFile = fileRdFind(binSearchPath(), "cat", osExecFileType);
	if (testFile) {
		printf("dir \"%s\", name \"%s\", type \"%s\"\n",
			fnameDir(testFile),
			fnameName(testFile),
			fnameType(testFile));
		
		printf("fileRdOpen: ");
		fout = fileRdOpen(testFile);
		printf("Opened \"%s\"\n",fnameName(testFile));

		fclose(fout);
	}
	else
		printf("Not found\n");

	printf("DONE.\n");

	fnameFree(testFile);
/*	fileRemove(testFile); */

}
Ejemplo n.º 3
0
Archivo: include.c Proyecto: pdo/aldor
/* 
 * Open a file, looking first in the current directory, then
 * in the list of include directories.
 */
local FileName
inclFind(String fname, String curdir)
{
	StringList    dl;
	FileName      fn;

	dl = listCons(String)(curdir, incSearchPath());
	fn = fileRdFind(dl, fname, FTYPE_SRC);
	listFreeCons(String)(dl);
	return fn;
}