Description

Used with Directory Read - 0x13 to list files and directories in a given directory. To get a listing of entries in a directory:

  1. Send a Directory Open Request.

  2. Parse multiple entries from the Response.

  3. If the last entry has the ENTRY_IS_LAST flag set, the listing is complete and the Directory Handle was automatically released.

  4. If the listing is not complete, do one of the following:

Format

Offset Size Frame Field Description

5

8-bit

File System Command

Directory Open - 0x11

6

16-bit

Path ID

See Get Path ID - 0x1C for a description

8-n

variable

Options

Pathname relative to Path ID, or empty to get a file listing for the Path ID.

Success Response

A Directory Open Request sends a response identical to a Directory Read - 0x13 Request. An empty directory returns a single entry with only the ENTRY_IS_LAST flag set, and a 0-byte Entry Name. A response ending with an ENTRY_IS_LAST flag automatically closes the Directory Handle.

Offset Size Frame Field Description

5

8-bit

File System Command

Directory Read - 0x13 or Directory Open - 0x11, depending on request

6

8-bit

Status

Success - 0x00

7

16-bit

Directory Handle

Value returned in initial Directory Open Response.

9

32-bit

File Size/Entry Flags

File’s size in lower 24 bits, combined with the following flags:

  • 0x80000000 (ENTRY_IS_DIR): Entry is a directory.

  • 0x40000000 (ENTRY_IS_SECURE): File is secure (write-only).

  • 0x01000000 (ENTRY_IS_LAST): This is the last entry.

  • Other flags in the top 8 bits (0x3E) are currently reserved and set to zero.

13-n

variable

Entry Name

File or directory name.

If there is enough room in the frame, there may be additional entries after the first.

n+1

8-bit

Null Terminator

0x00 byte to separate entries.

n+2

32-bit

File Size and Flags

Refer to description above.

n+6

variable

Entry Name

Refer to description above.

Process the entries in a Directory Open Response or Directory Read - 0x13 Response as follows:

  • Split the File Size and Flags field into separate File Size and Flags.

  • Look for a null terminator after the File Size and Flags field.

  • Extract Entry Name as bytes after File Size and Flags and before either the null terminator or the end of the frame.

  • Repeat this sequence if Entry Name had a null terminator and the packet contains unprocessed entries.

  • If the final entry of the frame does not have ENTRY_IS_LAST set, send another Directory Read - 0x13 Request to get additional entries.