Get Directory

requesttype=0x0b

Command: variable length (here 0x5b bytes)

0000  1b 00 00 00 02 02 00 00-00 00 00 00 00 00 00 00  ................
0010  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
0020  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
0030  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
0040  02 00 00 00 0b 00 00 11-1b 00 00 00 06 00 00 00  ................
0050  00 44 3a 5c 44 43 49 4d-00 00 00                 .D:\DCIM...     
      

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

Response: 0x40 bytes (PowerShot G2)

0000  00 00 00 00 02 03 56 00-00 00 00 00 00 00 00 00  ......V.........
0010  40 04 fe 15 d3 78 6a fb-54 bf d1 3c ed 63 4a 5d  @....xj.T..<.cJ]
0020  2a f7 cf 75 10 db cd e6-a3 47 9f 95 c3 e0 67 23  *..u.....G....g#
0030  a8 20 63 df ad 22 bc 8d-c8 6f 01 8a 56 78 8a 24  . c.."...o..Vx.$
      

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 0x56 bytes long. The next message from the camera is:

0000  80 00 00 00 00 00 48 e2-48 3e 44 3a 5c 44 43 49  ......H.H>D:\DCI
0010  4d 00 10 00 00 00 00 00-44 e6 43 3e 43 41 4e 4f  M.......D.C>CANO
0020  4e 4d 53 43 00 10 00 00-00 00 00 64 f6 48 3e 31  NMSC.......d.H>1
0030  35 35 43 41 4e 4f 4e 00-10 00 00 00 00 00 52 fb  55CANON.......R.
0040  48 3e 31 35 36 43 41 4e-4f 4e 00 00 00 00 00 00  H>156CANON......
0050  00 00 00 00 00 00      -                         ......          
      

Error codes:

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

The example 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 attribute, date, length, and name all zero indicates the end of the directory listing.

Since these are all directory entries, each shows a file size of zero.:

D:\DCIM, attribute byte 0x80. This is the name of the directory listed. .

CANONMSC, attribute byte 0x10, time Fri Feb 7 22:00:52 2003 (0x3e43e644).

155CANON, attribute byte 0x10, time Tue Feb 11 18:11:00 2003 (0x3e48f664).

156CANON, attribute byte 0x10, time Tue Feb 11 18:32:02 2003 (0x3e48fb52).

Here is an example of dealing with multiple levels in the directory hierarchy. The contents of this camera are:

Thu May 4 00:11:40 2000 D:\DCIM\100CANON\IMG_0001.JPG 778435
Thu May 4 00:28:32 2000 D:\DCIM\100CANON\IMG_0002.JPG 44409
Thu May 4 00:28:32 2000 D:\DCIM\CANONMSC\100.CTG 2634
Thu May 4 00:28:32 2000 D:\DCIM\CANONMSC\D.CTG 383

Directory contents: "D:" (recurse = 0x0)

00000000 80 00 00 00 00 00 00 00-00 00 44 3A 00 10 00 00 ..........D:....
00000010 00 00 00 C6 B5 10 39 44-43 49 4D 00 00 00 00 00 ......9DCIM.....
00000020 00 00 00 00 00 00 00                            .......
        

Directory contents: "D:" (recurse = 0x1)

00000000 80 00 00 00 00 00 00 00-00 00 44 3A 00 80 00 00 ..........D:....
00000010 00 00 00 36 C0 10 39 2E-5C 44 43 49 4D 00 10 00 ...6..9.\DCIM...
00000020 00 00 00 00 36 C0 10 39-31 30 30 43 41 4E 4F 4E ....6..9100CANON
00000030 00 10 00 00 00 00 00 CC-B5 10 39 43 41 4E 4F 4E ..........9CANON
00000040 4D 53 43 00 80 00 00 00-00 00 00 00 00 00 2E 2E MSC.............
00000050 00 00 00 00 00 00 00 00-00 00 00 00             ............
      

Directory contents: "D:" (recurse = 0x2)

00000000 80 00 00 00 00 00 00 00-00 00 44 3A 00 80 00 00 ..........D:....
00000010 00 00 00 36 C0 10 39 2E-5C 44 43 49 4D 00 80 00 ...6..9.\DCIM...
00000020 00 00 00 00 3C C0 10 39-2E 5C 31 30 30 43 41 4E ....<..9.\100CAN
00000030 4F 4E 00 20 00 C3 E0 0B-00 3C C0 10 39 49 4D 47 ON. .....<..9IMG
00000040 5F 30 30 30 31 2E 4A 50-47 00 20 00 79 AD 00 00 _0001.JPG. .y...
00000050 30 C4 10 39 49 4D 47 5F-30 30 30 32 2E 4A 50 47 0..9IMG_0002.JPG
00000060 00 80 00 00 00 00 00 00-00 00 00 2E 2E 00 80 00 ................
00000070 00 00 00 00 30 C4 10 39-2E 5C 43 41 4E 4F 4E 4D ....0..9.\CANONM
00000080 53 43 00 20 00 4A 0A 00-00 30 C4 10 39 31 30 30 SC. .J...0..9100
00000090 2E 43 54 47 00 20 00 7F-01 00 00 30 C4 10 39 44 .CTG. .....0..9D
000000A0 2E 43 54 47 00 80 00 00-00 00 00 00 00 00 00 2E .CTG............
000000B0 2E 00 80 00 00 00 00 00-00 00 00 00 2E 2E 00 00 ................
000000C0 00 00 00 00 00 00 00 00-00 00                   ..........
      

Here is a formatted listing of the entries:

                              D  :
0000: 0080 00000000 00000000 44 3A 00
                              .  \  D  C  I  M
000D: 0080 00000000 3910C036 2E 5C 44 43 49 4D 00
                              .  \  1  0  0  C  A  N  O  N
001E: 0080 00000000 3910C03C 2E 5C 31 30 30 43 41 4E 4F 4E 00
                              I  M  G  _  0  0  0  1  .  J  P  G
0033: 0020 000BE0C3 3910C03C 49 4D 47 5F 30 30 30 31 2E 4A 50-47 00
                              I  M  G  _  0  0  0  2  .  J  P  G
004A: 0020 0000AD79 3910C430 49 4D 47 5F 30 30 30 32 2E 4A 50 47 00
                              .  .
0061: 0080 00000000 00000000 2E 2E 00
                              .  \  C  A  N  O  N  M  S  C
006E: 0080 00000000 3910C430 2E 5C 43 41 4E 4F 4E 4D 53 43 00
                              1  0  0  .  C  T  G
0083: 0020 00000A4A 3910C430 31 30 30 2E 43 54 47 00
                              D  .  C  T  G
0095: 0020 0000017F 3910C430 44 2E 43 54 47 00
                              .  .
00A6: 0080 00000000 00000000 2E 2E 00
                              .  .
00B2: 0080 00000000 00000000 2E 2E 00

00BF: 0000 00000000 00000000 00