Basic File List Example
Display a list of files on the Gecko OS file system
- SDK directory:
applications/gecko-os/basic/file_list
API Features Demonstrated
Platforms
This app works on:
- WGM160P
Requirements and Prerequisites
Requires a Gecko OS evaluation board, such as a WGM160P_eval.
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 Gecko OS terminal.
Information about files is shown in the following sequence:
- File statistics
- Files on extended flash
- Files located in the
webapp/
directory - Files on extended flash are shown by paging
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/gecko-os.css.gz 22722 ABCB
10 webapp/gecko-os.js.gz 71570 88F1
Listing webapp files...
# Name Size Checksum
0 webapp/unauthorized.html 9531 154C
1 webapp/index.html 2031 CA05
2 webapp/gecko-os.css.gz 22722 ABCB
3 webapp/gecko-os.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/gecko-os.css.gz 22722 ABCB
4 webapp/gecko-os.js.gz 71570 88F1
Page: 3
# Name Size Checksum
0 apps/external_file_list-debug.zap 1888 7ECF
Implementation
This app uses gos_file_list, a wrapper for the file list Command API ls. It is passed a pointer to a gos_file_t linked list structure that is then passed to print_file_list
for formatting and display on the Gecko OS terminal.
When you are finished with the linked list structure, you must call gos_file_destroy_list to deallocate memory and clean up.
See the following links for additional information about the Gecko OS features used in this app.
gos_app_init
- Calls the subroutines in sequence:
display_file_stats
list_extended_files_only
list_webapp_files
list_with_paging
display_file_stats
- File statistics are shown using the gos_file_system_get_stats API.
list_extended_files_only
- Files on extended flash are shown by passing the GOS_FILE_LOCATION_EXTENDED memory type to the gos_file_list API.
list_webapp_files
- Files located in the
webapp/
directory are shown by passing awebapp/
search string to gos_file_list.
list_with_paging
- Files are paged by passing a parameters structure to gos_file_list.
- The gos_file__list_parameters_t structure
.offset
parameter corresponds to thels
command-b base sector
option. - The gos_file__list_parameters_t structure
.limit
parameter corresponds to thels
command-c max file count
option - See the notes about paging in the ls documentation.
- The gos_file__list_parameters_t structure
print_file_list
- Formats and displays the file list on the Gecko OS terminal.
Source
See: