TIP: Click on subject to list as thread! ANSI
echo: cis.os9.68000.osk
to: Jim Sutemeier 70673,1754 (X)
from: Bruce MacKenzie 71725,376
date: 1991-11-18 19:53:41
subject: #13101-#C programming (fopen)

#: 13102 S12/OS9/68000 (OSK)
    18-Nov-91  19:53:41
Sb: #13101-#C programming (fopen)
Fm: Bruce MacKenzie 71725,376
To: Jim Sutemeier 70673,1754 (X)

Jim,
 You read from the directory as you would from any other file.  Under OS9 (I
can't speak for OSK--check your docs) each directory entry consists of a 29
byte name field followed by a 3 byte logical sector number for the file
descriptor sector.  The microware OS9 C compiler defines a structure in
direct.h to help access the directory:

 struct dirent{
      char dir_name[29];
      char dir_addr[3];
 }

 So all one need do is define a structure of this type and read the directory
entries into it:

 struct dirent dat;

 in=fopen("/dd","d");

 while(fread(&dat,sizeof(dat),1,in)!=0){
 .
 .
 .

 If the entry is unused the first byte of the filename is set to zero.  The
last byte of the filename has its MSB set so you have to clear this bit and set
the next byte to zero to make it a proper C string.  At the end of the
directory fread() returns 0 for EOF.

There is 1 Reply.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.