Response example for "dir"

The result of this request is returned as an XML document which contains one <file...> tag per entry found in the targeted directory. With the ObjectStore (NS4) file system, an implicit directory is recognized as a file entry, and it will be listed in the response output for this action.

Important: When interpreting response output from this call, you must support the appropriate XML escaping for object names that include characters such as a quote ( " ) and an ampersand ( & ).

Lexicographical response example the "dir" action

Results are provided lexicographically for the dir action, listing objects in the specified [path].

Let's assume that you're using this action to target the following "sampledir" [path]:

GET /[CP code]/sampledir HTTP/1.1

You would see the following as a response:

1 | <stat directory="/[CP code]/sampledir">  
2 |     <file type="file" name="File2" size="398421" md5="[HASH]" mtime="1524068379"/>  
3 |     <file type="symlink" name="My_symlink.html" target="File1" mtime="1524110333"/>  
4 |     <file type="dir" name="dir1" bytes="19873716" files="6" mtime="1524068415" implicit="true"/>  
5 |     <file type="dir" name="dir2" bytes="3874912" files="1" mtime="1524068422" implicit="true"/>  
6 |     <file type="dir" name="explicitdir1" bytes="0" files="1" mtime="1524068459"/>  
7 |     <file type="dir" name="explicitdir2" bytes="3" files="2" mtime="1524068462"/>
8 |     <file type="file" name="file1" size="532459" md5="[HASH]" mtime="1524068382"/>   
9 | </stat>
Explanation of response results
Note: The line numbers shown in the example above do not appear in the actual output. They are only for reference in the points that follow.
  • The targeted [path] is listed first in the response.
  • Objects are listed in "lexicographical" order. As an example of this, notice how a file named "File2" (line 2) is displayed before a directory named "dir1" (line 4).
  • Objects also include informational details:
    • Files and symlinks: This includes the size of the file, the associated md5 hash, and the time the file was last modified (mtime).
    • Directories: This includes the total size of all file content in bytes, the number of files in the directory, the last modified date (mtime). Finally, if the directory is implicit it is labeled as such.

What is lexicographic sorting?

Lexicographical sorting is the ordering of objects based on the first character that is different. When one is a prefix of the other, the shorter string is "less."

Results are sorted by comparing each character position with numbers displayed before alpha characters. Objects are listed from the specified start [path] in the following sort order:

  • Numbers: Numbers are displayed alphabetically before alpha characters. In this example "10" comes before "2" due to the first character "1" being less than "2".
    • Example: 1, 10, 2, 21, 3
  • Alpha characters: Alphabetic sorting takes case sensitivity into consideration. Capitalized letters sort before lowercase.
    • Example: C, D, a, b