|
发表于 2021-4-10 08:53:42
|
显示全部楼层
- CHAR entry_name[FX_MAX_LONG_NAME_LEN];
- int ls(char *pathname)
- {
- UINT status;
- UINT attributes;
- UINT cnt;
- ULONG size;
- UINT year;
- UINT month;
- UINT day;
- UINT hour;
- UINT minute;
- UINT second;
- char *path;
- if (pathname == FX_NULL)
- {
- path = FX_NULL;
- printf("Directory /:\n");
- }
- else
- {
- path = (char *)pathname;
- printf("Directory %s:\n", path);
- }
- // find first
- status = fx_directory_first_full_entry_find(get_nand_flash_disk(0),
- entry_name,
- &attributes,
- &size,
- &year, &month, &day,
- &hour, &minute, &second);
- if (status != FX_SUCCESS)
- {
- return status;
- }
- /* judge file or directory */
- if (attributes & FX_DIRECTORY)
- {
- printf("%-20s", (char *)entry_name);
- printf("%-25s", "<DIR>");
- printf("%-25lu\n", size);
- }
- else
- {
- printf("%-20s", (char *)entry_name); /* 长文件名 */
- printf("%-25lu\n", size);
- }
- for (cnt = 0; ; cnt++)
- {
- status = fx_directory_next_full_entry_find(get_nand_flash_disk(0),
- entry_name,
- &attributes,
- &size,
- &year, &month, &day,
- &hour, &minute, &second);
- if (status == FX_NO_MORE_ENTRIES)
- {
- return FX_SUCCESS;
- }
- if (status != FX_SUCCESS || entry_name[0] == 0)
- {
- break;
- }
- if (entry_name[0] == '.')
- {
- continue;
- }
- /* judge file or directory */
- if (attributes & FX_DIRECTORY)
- {
- printf("%-20s", (char *)entry_name); /* 长文件名 */
- printf("%-25s\n", "<DIR>");
- }
- else
- {
- printf("%-20s", (char *)entry_name); /* 长文件名 */
- printf("%-25lu\n", size);
- }
- }
- return status;
- }
复制代码 |
|