Description
This function returns a sorted list of files and directories.
Examples
Note:
Use cPanel's API Shell interface (Home >> Advanced >> API Shell) to directly test cPanel API calls.
Parameters
| Parameters | Type | Description | Possible values | Example | 
| dirs | string | Required The directory from which to list files. | A valid directory on the server. | public_html | 
| types | string | A pipe-separated list of file types to return. If you do not use this parameter, the function returns all file types. | 
 | file|dir | 
| limit_to_list | Boolean | Whether to return only entries that begin with filepath- If you do not use this parameter, the function returns all filenames. 
 | 
 | 0 | 
| only_these_files | string | The files to return. If you do not use this parameter, the function returns all files. 
 | A list of comma-separated files. | cpbackup-exclude.conf | 
| show_hidden | Boolean | Whether to include hidden files in the output. This parameter defaults to 0. 
 | 
 | 1 | 
| check_for_leaf_directories | Boolean | Whether to return directories that contain subdirectories. This parameter defaults to 0. | 
 | 1 | 
| mime_types | string | The MIME types to return. If you use this parameter, the function returns the specified MIME types and sets the include_mime parameter's value to 1. If you do not use this parameter, the function returns all MIME types. | A comma-separated list ofMIME types. | text-plain | 
| raw_mime_types | string | The raw MIME types to return. If you use this parameter, the function returns the specified MIME types and sets the include_mime parameter's value to 1. If you do not use this parameter, the function returns all MIME types. 
 | A comma-separated list of raw MIME types. | text/plain | 
| include_mime | Boolean | Whether to return the file's MIME type. This parameter defaults to 0. Note: If you set this value to 0 but also include themime_types or raw_mime_types parameters, the function overrides your specified value and sets this parameter to 1. | 
 | 1 | 
| include_hash | Boolean | Whether to include a hash of the file's information in the return. This parameter defaults to 0. 
 | 
 | 0 | 
| include_permissions | Boolean | Whether to parse the file owner's read and write permissions. This parameter defaults to 0. | 
 | 0 | 
Returns
| Return | Type | Description | Possible values | Example | 
| files | array of hashes | An array of hashes that contains information about each file. | This array of hashes includes the absdir, ctime,exists, file, fullpath,gid, hash, humansize,isleaf, mimename,mimetype, mode, mtime,nicemode, path, phash,rawmimename,rawmimetype, size, type,uid, read, write, andisparent returns. | 
 | 
| absdir | string | The path to the user's home directory. The function returns this value in the files array of hashes. | A valid file path. | /home/user | 
| ctime | string | The file's creation time. The function returns this value in the files array of hashes. | A time in Unix time format. | 1400573272 | 
| exists | Boolean | Whether the file exists in the directory. The function returns this value in the files array of hashes. | 
 | 1 | 
| file | string | The filename. The function returns this value in the files array of hashes. | A valid filename on the server. | cgi-bin | 
| fullpath | string | The file's full file path. The function returns this value in the files array of hashes. | A valid filepath on the server. | /home/user/public_html/cgi-bin | 
| gid | integer | The file owner's system group ID. The function returns this value in the files array of hashes. | A positive integer. | 503 | 
| hash | string | The full file path's hash. The function returns this value in the files array of hashes. | A string of letters and integers. | L2hvbWUvY29saW4vcHVibGljX2h0bWw | 
| humansize | string | The formatted size of the file. The function returns this value in the files array of hashes. | A positive integer and one of the following symbols: 
 | 5 KB | 
| isleaf | Boolean | Whether the directory contains subdirectories. The function returns this value in the files array of hashes. | 
 | 1 | 
| mimename | string | The file's MIME type name. The function returns this value in the files array of hashes. | A valid MIME name on the server. | text-plain | 
| mimetype | string | The file's MIME type. The function returns this value in the files array of hashes. | A valid MIME type on the server. | text/plain | 
| mode | string | The file's textual permissions. The function returns this value in the files array of hashes. | A string value in Unix format. | 16877 | 
| mtime | string | The file's last modification time. The function returns this value in the files array of hashes. | A time in Unix time format. | 1400573272 | 
| nicemode | integer | The file's numerical permissions. The function returns this value in the files array of hashes. | An integer value in octal notation. | 0755 | 
| path | string | The absolute path to the file. The function returns this value in the files array of hashes. | A valid file path. | /home/user/public.html | 
| phash | string | The parent filepath's file hash. The function returns this value in the files array of hashes. | A string of letters and integers. | L2hvbWUvY29saW4vcHVibGljX2h0bWw | 
| rawmimename | string | The file's raw MIME type's name. The function returns this value in the files array of hashes. | A valid raw MIME type'sname on the server. | text-plain | 
| rawmimetype | string | The file's raw MIME type. The function returns this value in the files array of hashes. | A valid raw MIME type on the server. | text/plain | 
| size | integer | The file's size, in bytes. The function returns this value in the files array of hashes. | A positive integer. | 4096 | 
| type | string | The item's type. The function returns this value in the files array of hashes. | 
 | file | 
| uid | integer | The file owner's system user ID. The function returns this value in the files array of hashes. | A positive integer. | 502 | 
| read | Boolean | Whether the file is readable. Note: The function only outputs this return if the include_permissionsvalue is 1. The function returns this value in the files array of hashes. 
 | 
 | 1 | 
| write | Boolean | Whether the file is writable. Note: The function only outputs this return if the include_permissionsvalue is 1. The function returns this value in the files array of hashes. 
 | 
 | 1 | 
| isparent | Boolean | Whether the file is a parent record. The function returns this value in the files array of hashes. | 
 | 1 | 
| dirs | array of hashes | An array of hashes that contains information about each directory. | This array of hashes includes the absdir, ctime,exists, file, fullpath,gid, hash, humansize,isleaf, mimename,mimetype, mode, mtime,nicemode, path, phash,rawmimename,rawmimetype, size, type,uid, read, write, andisparent returns. | 
 | 
| absdir | string | The path to the user's home directory. The function returns this value in the dirs array of hashes. | A valid file path. | /home/user | 
| ctime | string | The directory's creation time. The function returns this value in the dirs array of hashes. | A time in Unix time format. | 1400573272 | 
| exists | Boolean | Whether the directory exists in the directory. The function returns this value in the dirs array of hashes. | 
 | 1 | 
| file | string | The directory name. The function returns this value in the dirs array of hashes. | A valid directory name on the server. | cgi-bin | 
| fullpath | string | The directory's full directory path. The function returns this value in the dirs array of hashes. | A valid directory path on the server. | /home/user/public_html/cgi-bin | 
| gid | integer | The directory owner's system group ID. The function returns this value in the dirs array of hashes. | A positive integer. | 503 | 
| hash | string | The full directory path's hash. The function returns this value in the dirs array of hashes. | A string of letters and integers. | L2hvbWUvY29saW4vcHVibGljX2h0bWw | 
| humansize | string | The formatted size of thedirectory. The function returns this value in the dirs array of hashes. | A positive integer and one of the following symbols: 
 | 5 KB | 
| isleaf | Boolean | Whether the directory contains subdirectories. The function returns this value in the dirs array of hashes. | 
 | 1 | 
| mimename | string | The MIME type's name. The function returns this value in the dirs array of hashes. | A valid MIME name on the server. | text-plain | 
| mimetype | string | The directory's MIME's type. The function returns this value in the dirs array of hashes. | A valid MIME type on the server. | text/plain | 
| mode | string | The directory's textual permissions. The function returns this value in the dirs array of hashes. | A string value in Unix format. | 16877 | 
| mtime | string | The directory's last modification time. The function returns this value in the dirs array of hashes. | A time in Unix time format. | 1400573272 | 
| nicemode | integer | The directory's numerical permissions. The function returns this value in the dirs array of hashes. | An integer value in octal notation. | 0755 | 
| path | string | The path to the directory. The function returns this value in the dirs array of hashes.< 
 Related Articles | 
