Directory Open - 0x11
Description
Used with Directory Read to list files and directories in a given directory. To get a listing of entries in a directory:
-
Send a Directory Open Request.
-
Parse multiple entries from the Response.
-
If the last entry has the ENTRY_IS_LAST flag set, the listing is complete and the Directory Handle was automatically released.
-
If the listing is not complete, do one of the following:
-
Send a Directory Read Request to get additional directory entries
-
Send a Directory Close Request to release the Directory Handle.
-
Request
Offset | Size | Frame Field | Description |
---|---|---|---|
5 | 8-bit |
File System Command |
Directory Open 0x10 |
6 | 16-bit |
Path ID |
See command Get Path ID - 0x1C for description. |
8-n | variable |
Directory Name |
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 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 | 16-bit |
Status |
Success - 0x00 |
7 | 16-bit |
Directory Handle |
Value returned in initial Directory Open Response. |
9 | 32-bit |
File's size in lower 24 bits, combined with the following flags:
|
|
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 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 Request to get additional entries.