Get Directory

requesttype=0x0b

Error codes:

0x00000000 No errors
0x02000022 File not found
0x02000029 File was protected
0x02000086 Path not found

Command: variable length (here 0x64 bytes)

00000000  24 00 00 00 02 02 00 00 00 00 00 00 00 00 00 00  $...............
00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000040  02 00 00 00 0b 00 20 11 24 00 00 00 78 80 8f 00  ...... .$...x...
00000050  00 41 3a 5c 44 43 49 4d 5c 31 30 30 43 41 4e 4f  .A:\DCIM\100CANO
00000060  4e 00 00 00                                      N...
      

The byte at offset 0x50 gives the level of recursion allowed, here zero (no recursion). This is followed by the directory pathname, here A:\DCIM\100CANON.

Response: 0x40 bytes

00000000  00 00 00 00 02 03 78 00 00 00 00 00 00 00 00 00  ......x.........
00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      

As with all long dialogues, the message contains only the length of data to follow, as a word starting at offset 0x06. In this case, the subsequent data will be 0x78 bytes long. The next message from the camera is:

00000000  a0 00 00 00 00 00 cc 54 8b 41 41 3a 5c 44 43 49  .......T.AA:\DCI
00000010  4d 5c 31 30 30 43 41 4e 4f 4e 00 20 00 d3 9a 9f  M\100CANON. ....
00000020  00 98 0f 90 41 49 4d 47 5f 30 30 39 38 2e 43 52  ....AIMG_0098.CR
00000030  32 00 20 00 52 b0 68 00 7a b8 91 41 49 4d 47 5f  2. .R.h.z..AIMG_
00000000  30 30 39 39 2e 43 52 32 00 20 00 f3 2e 69 00 8a  0099.CR2. ...i..
00000010  b8 91 41 49 4d 47 5f 30 31 30 30 2e 43 52 32 00  ..AIMG_0100.CR2.
00000020  80 00 00 00 00 00 00 00 00 00 2e 2e 00 00 00 00  ................
00000030  00 00 00 00 00 00 00 00                          ........
      

This shows four entries. Each entry contains

1 byte attribute bits (described in Table 2.3, “File attributes”)
1 zero byte
4 bytes file size in bytes (zero if directory)
4 bytes UNIX time
File name (null-terminated string of arbitrary length)
.. in name means leave directory.

An entry with attributes, date, and length all zero indicates the end of the directory listing. It seems that with this camera, Canon has changed to putting the string ".." in this empty entry; formerly, the name contained only a single NUL.

The contents of this listing:

A:\DCIM\100CANON, attribute byte 0xa0. This is the name of the directory listed.

IMG_0098.CR2, attribute byte 0x20, size 0x009f9ad3 (10,459,869) time 0x41900f98.

IMG_0099.CR2, attribute byte 0x20, size 0x0068b052 (6,860,882) time 0x4191b87a.

IMG_0100.CR2, attribute byte 0x20, size 0x00692ef3 (6,893,299) time 0x4191b88a.