Wiki Home >> SIO-Command-$F6-Read-Directory

SIO-Command-$F6-Read-Directory


This is a command for Device $70 - The FujiNet Device itself (see SIO-Commands-for-Device-ID-$70).

Read Directory ($F6)

Description

Retrieve the next directory entry text and place into buffer.

AUX1 specifies a maximum length to retrieve. If the directory entry path is longer than this, it will be truncated to fit this value (along with a terminating NULL character). 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 indicates whether to return additional file details along with the entry text. Setting bit 7 (0x80) will return 10 additional bytes (see RETURNS section below for details) followed by the directory entry text. The max directory entry text length returned will be reduced by 10 bytes to accommodate the additional data.

Parameters

DCBValue
DDEVIC$70
DUNIT$01
DCOMND$F6
DSTATS$40
DBUFBuffer to contain the directory entry 0-255 bytes
DTIMLO# of seconds before timeout
DBYT# of bytes to return in directory entry
DAUX1Maximum length of entry response
DAUX2If bit 0x80 set, additional file details returned

Returns

NULL terminated string with directory entry.

First and second bytes are both set to 0x7F (0x7F7F) when the end of the directory has been reached.

If AUX2 bit 7 (0x80) is set on the request, the following data will be returned before the directory entry text:

ByteItemDescription
0x00MODIFIED_YEARFile modified date-time: years since 1970
0x01MODIFIED_MONTHFile modified date-time: month (1-12)
0x02MODIFIED_DAYFile modified date-time: day of month (1-31)
0x03MODIFIED_HOURFile modified date-time: hour (0-23)
0x04MODIFIED_MINUTEFile modified date-time: minute (0-59)
0x05MODIFIED_SECONDFile modified date-time: second (0-59)
0x06FILE_SIZE_LOFile size low byte
0x07FILE_SIZE_HIFile size high byte
0x08FILE_FLAGSOne or more file flag values (see below)
0x09FILE_TYPEOne of the file type values (see below)

The file's modified date-time value will be adjusted to the local time zone (if any) set on FujiNet.

File FlagValueDescription
FF_DIR0x01Entry is a directory
FF_TRUNC0x02Entry name was truncated to fit requested size
File TypeValueDescription
FT_UNKNOWN0x00File type could not be determined
FT_ATR0x01ATR disk image
FT_ATX0x02ATX disk image
FT_XEX0x03Atari executable

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=36;
    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

Wiki content is mirrored from the FujiNet Github Wiki