Skip to content

SIO Command $F6 Read Directory

Oscar Fowler edited this page Jul 25, 2020 · 6 revisions

Read Directory ($F6)

Description

Retrieve the next directory entry text and place into buffer. AUX1 can be used to specify a maximum length to retrieve, which is subsequently truncated by the ESP. This is useful for making read commands more efficient for display, and using a subsequent Directory Open/Directory Read to get the full 256 character filename for mounting.

AUX2 meanwhile, contains the requested host slot in which to read the directory entry, this is required because file descriptor numbers are not guaranteed to be mutually exclusive.

Parameters

DCB Value
DDEVIC $70
DUNIT $01
DCOMND $F6
DSTATS $40
DBUF Buffer to contain the directory entry 0-255 bytes
DTIMLO # of seconds before timeout
DBYT # of bytes to return in directory entry
DAUX1 entry offset 0 being first entry
DAUX2 requested host slot

Returns

NUL terminated string with directory entry. or first byte contains 0x7F if no more entries.

Examples

CC65

/**
   A directory entry, with stat() information
*/
union
{
  struct
  {
    unsigned short mode;
    unsigned long size;
    char filename[256];
  } entry;
  unsigned char rawData[262]; // max size.
} dirEntry;


// loop and read dir for display
while ((dirEntry.entry.filename[0]!=0x7F))
  {
    memset(dirEntry.rawData,0,sizeof(dirEntry.rawData);
    dirEntry.entry.filename[0]=0x7F;
    OS.dcb.ddevic=0x70;
    OS.dcb.dunit=1;
    OS.dcb.dcomnd=0xF6;
    OS.dcb.dstats=0x40;
    OS.dcb.dbuf=&path;
    OS.dcb.dtimlo=0x0F;
    OS.dcb.dbyt=36;
    OS.dcb.daux1=offset;
    OS.dcb.daux2=hostSlot;
    siov();

    if (dirEntry.entry.filename[0]=='.')
      continue;
    else if (dirEntry.entry.filename[0]==0x7F)
      break;
    else
      {
        strcpy(files[num_entries],path);
        screen_puts(0,num_entries+2,path);
        num_entries++;
      }
  }

See Also

  • Open Directory
  • Close Directory

Clone this wiki locally