Basic File List Example

Display a list of files on the ZentriOS file system

API Features Demonstrated

Platforms

This app works on:

Requirements and Prerequisites

Requires ZentriOS-powered hardware with serial flash memory, such as an AMW004 orAMW106 module

Description

This app displays information about files on the filesystem and then exits. Information is formatted and written to the log bus which can be viewed on a ZentriOS terminal.

Information about files is shown in the following sequence:

Expected output is similar to:

> File count....... 11
Flash size....... 1048576
Bytes used....... 401408
Bytes available.. 647168
Listing files on extended flash...
 #                             Name    Size Checksum
 0                   .recovery.html    7574 6BD9
 1 apps/external_file_list-debug.zap    1888 7ECF
 2                 command_help.csv   47254 8ED4
 3             default_setup.script     135 C90E
 4                   favicon.ico.gz     721 41C7
 5                  geotrust_ca.pem    1236 6E5A
 6                  sys/wifi_fw.bin  210412 5891
 7                webapp/index.html    2031 CA05
 8         webapp/unauthorized.html    9531 154C
 9           webapp/zentrios.css.gz   22722 ABCB
10            webapp/zentrios.js.gz   71570 88F1
Listing webapp files...
 #                             Name    Size Checksum
 0         webapp/unauthorized.html    9531 154C
 1                webapp/index.html    2031 CA05
 2           webapp/zentrios.css.gz   22722 ABCB
 3            webapp/zentrios.js.gz   71570 88F1
Listing files on extended flash with 'paging' ...
Page: 1
 #                             Name    Size Checksum
 0                  sys/wifi_fw.bin  210412 5891
 1                  geotrust_ca.pem    1236 6E5A
 2                 command_help.csv   47254 8ED4
 3         webapp/unauthorized.html    9531 154C
 4                   .recovery.html    7574 6BD9
Page: 2
 #                             Name    Size Checksum
 0                webapp/index.html    2031 CA05
 1                   favicon.ico.gz     721 41C7
 2             default_setup.script     135 C90E
 3           webapp/zentrios.css.gz   22722 ABCB
 4            webapp/zentrios.js.gz   71570 88F1
Page: 3
 #                             Name    Size Checksum
 0 apps/external_file_list-debug.zap    1888 7ECF

Implementation

This app uses zn_file_list, a wrapper for the file list Command API ls. It is passed a pointer to a zos_file_t linked list structure that is then passed to print_file_list for formatting and display on the ZentriOS terminal.

When you are finished with the linked list structure, you must call zn_file_destroy_list to deallocate memory and clean up.

See the following links for additional information about the ZentriOS features used in this app.

zn_app_init

display_file_stats

list_extended_files_only

list_webapp_files

list_with_paging

print_file_list

Source

See: