/*  mendir.C   */
/*  Copyright 1991 Mountain Math Software  */
/*  All Rights Reserved                    */
#include <dirent.h>
#include <stream.h>
#include <string.h>
#include <stdlib.h>
#include "dirfil.h"
#include "mendir.h"
#include "mkstr.h"
#include "classrel.h"
#include "menuprsl.h"


int NextFile()
{
	static char FileName[MAXNAMLEN+1] ;
	static ExamineDirectory * IncDirExamine = 0 ;
	TheClassRelations.SetCurrentClass(); // clear current class
	// cout << "In NextFile\n" ;
	if (!IncDirExamine) {
		if(!UsrInc) return 1;
		IncDirExamine = new ExamineDirectory(UsrInc,".nod");
	}
	const char * Next = IncDirExamine->NextFile() ;
	if (!Next) return 1;
	// cout << "About to PushFile(" << Next << ")\n" ;
	if (strlen(Next)+strlen(UsrInc)+1 > MAXNAMLEN) {
		cerr << " File name `" << UsrInc << "/" << Next
			<< " longer than " << MAXNAMLEN << "characters.\n" ;
		exit(1);
	}
	strcpy(FileName,UsrInc);
	strcat(FileName,"/");
	strcat(FileName,Next) ;
	cout << "About to PushFile(" << FileName << ")\n" ;
	PushFile(FileName);
	return 0;
}


