Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site baylor.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!ut-sally!ut-ngp!shell!neuro1!baylor!peter From: peter@baylor.UUCP (Peter da Silva) Newsgroups: net.sources Subject: 4.2 directory I/O in V7 and other unmentionables Message-ID: <588@baylor.UUCP> Date: Thu, 29-Aug-85 16:41:30 EDT Article-I.D.: baylor.588 Posted: Thu Aug 29 16:41:30 1985 Date-Received: Tue, 10-Sep-85 03:43:25 EDT Distribution: net Organization: The Power Elite, Houston, TX Lines: 32 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