[net.sources] 4.2 directory I/O in V7 and other unmentionables

peter@baylor.UUCP (Peter da Silva) (08/29/85)

The following is what I use to emulate 4.2 directory stuff in non-4.2
systems. It has worked fine so far, touch wood. I suppose you could
improve it by making readdir an extern, but since I generally use this
for patching 4.2-type sources that's overkill. If you wanted to spend
time pleying with setjmp/longjmp you could even make it a macro!

You'll still have to patch any references to weirder parts of struct direct,
oh well.

----- cut here -----
#ifndef BSD
#define opendir(n) fopen(n, "r")
#define DIR FILE
static DIR *readdir(dp)
DIR *dp;
{
	static struct direct db[1];

	while(fread(db, sizeof(struct direct), 1, dp)) {
		if(db->d_ino)
			return db;
	}
	return NULL;
}
#define closedir fclose
#endif


-- 
	Peter (Made in Australia) da Silva
		UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter
		MCI: PDASILVA; CIS: 70216,1076