예제 #1
0
파일: file_t.c 프로젝트: dokterp/aldor
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); */

}
예제 #2
0
파일: axlcomp.c 프로젝트: nilqed/aldor
String
compRootFromCmdLine(String cwd, String file)
{
	FileName fname = fnameParseStaticWithin(file, cwd);
	String binDir = fnameDir(fname);
	FileName rootDir = fnameNew(binDir, "..", "");

	String root = fnameUnparse(rootDir);

	return root;
}
예제 #3
0
파일: axlcomp.c 프로젝트: nilqed/aldor
/*
 * Compile .as file, returning error count.
 */
int
compSourceFile(EmitInfo finfo)
{
	AbSyn		ab;
	Stab		stab;
	Foam		foam;
	int		msgCount;
 
	compFileInit(finfo);
	breakSetRoot(NULL);
 
	stab = stabFile();
 
	ab = compFileFront(finfo, stab, NULL, NULL);
	breakSetRoot(ab);
 
	if (emitIsOutputNeededOrWarn(finfo, FTYPENO_CPP)) {
		/* Need to inspect finfo to get the filename */
		FileName fn = emitFileName(finfo, FTYPENO_INTERMED);
		genCpp(ab,fnameDir(fn),fnameName(fn));
		emitTheCpp();
	}

	if (compIsMoreAfterFront(finfo)) {
		foam = compFileMiddle(finfo, stab, ab);
 
		compFileSave(finfo, stab, foam);
		compFileBack(finfo, foam);
 
		foamFree(foam);
	}
 
	msgCount = comsgErrorCount();
	compFileFini(finfo);
	/* abFree(ab); !! ab is seeping into types. */
	if (msgCount < 1) breakInterrupt();
 
	return msgCount;
}
예제 #4
0
파일: include.c 프로젝트: pdo/aldor
local SrcLineList
inclFile(String fname, Bool reincluding, Bool top, long *pnlines)
{
	Scope("inclFile");

	SrcLineList     sll;
	Hash            fhash;
	FileName        fn;
	FileState	o_fileState; 
	IfState		fluid(ifState);
	String		curdir;

	o_fileState 	     = fileState;     /* no fluid(struct) */
	ifState              = NoIf;
	fileState.lineNumber = 0;

	fn = inclFind(fname, fileState.curDir);

	if (fn != 0) {
		fileState.curDir   = strCopy(fnameDir(fn));
		fileState.curFile  = strCopy(fnameUnparseStatic(fn));
		fileState.curFname = fn;
	}
	curdir = fileState.curDir;

	if (fn == 0) {
		fileState = o_fileState;
		if (top) {
			comsgFatal(NULL, ALDOR_F_CantOpen, fname);
			NotReached(sll = 0);
		}
		else
			sll = inclError(ALDOR_F_CantOpen, fname);
	} 
	else {
		fhash = fileHash(fn);
		fname = strCopy (fnameUnparseStatic(fn));

		if (!reincluding && listMemq(Hash)(includedFileCodes, fhash)) {
			sll = listNil(SrcLine);
		}
		else if (listMemq(Hash)(fileState.fileCodes, fhash)) {
			String s = inclActiveFileChain
				(fileState.fileNames, "->");
			fileState = o_fileState;
			sll = inclError(ALDOR_E_InclInfinite, s);
			strFree(s);
		}
		else {
			includedFileCodes   =
			   listCons(Hash)  (fhash,includedFileCodes);
			fileState.fileCodes =
			   listCons(Hash)  (fhash,fileState.fileCodes);
			fileState.fileNames =
			   listCons(String)(fname,fileState.fileNames);
			fileState.infile    = fileRdOpen(fn);

			sll = inclFileContents();

			listFreeCons(Hash)  (fileState.fileCodes);
			listFreeCons(String)(fileState.fileNames);
			fclose(fileState.infile);
		}
		fnameFree(fn);
		strFree(curdir);
				 /*!! curFile is used in src lines */
		strFree(fname);
	}
	if (pnlines) *pnlines = fileState.lineNumber;
	fileState = o_fileState;
	Return(sll);
}