1 Star 0 Fork 344

seasky100 / awtk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
fs_t.md 15.60 KB
一键复制 编辑 原始数据 按行查看 历史
xianjimli 提交于 2020-04-07 09:44 . update idl/docs

fs_t

概述

文件状态信息。

函数

函数名称 说明
file_exist 判断文件是否存在。
file_get_size 获取文件大小。
file_read 读取文件的全部内容。
file_read_part 从某个位置读取文件。
file_remove 刪除文件。
file_write 写入文件。
fs_create_dir 创建目录。
fs_dir_exist 判断目录是否存在。
fs_dir_rename 目录重命名。
fs_file_close 关闭文件。
fs_file_eof 判断文件是否结束。
fs_file_exist 判断文件是否存在。
fs_file_printf 写入文件。
fs_file_read 读取文件。
fs_file_rename 文件重命名。
fs_file_seek 定位读写指针到指定的位置。
fs_file_truncate 清除文件内容。
fs_file_write 写入文件。
fs_get_cwd 获取当前所在目录。
fs_get_disk_info 获取文件系统信息。
fs_get_exe 获取可执行文件所在目录。
fs_get_file_size 获取文件大小。
fs_get_user_storage_path 获取home目录或者应用程序可以写入数据的目录。
fs_open_dir 打开目录。
fs_open_file 打开文件。
fs_remove_dir 刪除目录。
fs_remove_file 刪除文件。
fs_stat 获取文件信息。
os_fs 获取缺省的文件系统对象。

file_exist 函数


  • 函数功能:

判断文件是否存在。

  • 函数原型:
bool_t file_exist (const char* name);
  • 参数说明:
参数 类型 说明
返回值 bool_t 返回TRUE表示成功,否则表示失败。
name const char* 文件名。

file_get_size 函数


  • 函数功能:

获取文件大小。

  • 函数原型:
int32_t file_get_size (const char* name);
  • 参数说明:
参数 类型 说明
返回值 int32_t 返回非负表示文件大小,否则表示失败。
name const char* 文件名。

file_read 函数


  • 函数功能:

读取文件的全部内容。

  • 函数原型:
void* file_read (const char* name, uint32_t* size);
  • 参数说明:
参数 类型 说明
返回值 void* 返回读取的数据,需要调用TKMEM_FREE释放。
name const char* 文件名。
size uint32_t* 返回实际读取的长度。

file_read_part 函数


  • 函数功能:

从某个位置读取文件。

  • 函数原型:
int32_t file_read_part (const char* name, const void* buffer, uint32_t size, uint32_t offset);
  • 参数说明:
参数 类型 说明
返回值 int32_t 返回实际读取的字节数。
name const char* 文件名。
buffer const void* 数据缓冲区。
size uint32_t 数据长度。
offset uint32_t 偏移量。

file_remove 函数


  • 函数功能:

刪除文件。

  • 函数原型:
ret_t file_remove (const char* name);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
name const char* 文件名。

file_write 函数


  • 函数功能:

写入文件。

  • 函数原型:
ret_t file_write (const char* name, const void* buffer, uint32_t size);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
name const char* 文件名。
buffer const void* 数据缓冲区。
size uint32_t 数据长度。

fs_create_dir 函数


  • 函数功能:

创建目录。

  • 函数原型:
ret_t fs_create_dir (fs_t* fs, const char* name);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 目录名称。

fs_dir_exist 函数


  • 函数功能:

判断目录是否存在。

  • 函数原型:
bool_t fs_dir_exist (fs_t* fs, const char* name);
  • 参数说明:
参数 类型 说明
返回值 bool_t 返回TRUE表示存在,否则表示不存在。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 目录名称。

fs_dir_rename 函数


  • 函数功能:

目录重命名。

  • 函数原型:
ret_t fs_dir_rename (fs_t* fs, const char* name, const char* new_name);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回TRUE表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 旧目录名称。
new_name const char* 新目录名称。

fs_file_close 函数


  • 函数功能:

关闭文件。

  • 函数原型:
ret_t fs_file_close (fs_file_t* file);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
file fs_file_t* 文件对象。

fs_file_eof 函数


  • 函数功能:

判断文件是否结束。

  • 函数原型:
bool_t fs_file_eof (fs_file_t* file);
  • 参数说明:
参数 类型 说明
返回值 bool_t 返回TRUE表示结束,否则表示没结束。
file fs_file_t* 文件对象。

fs_file_exist 函数


  • 函数功能:

判断文件是否存在。

  • 函数原型:
bool_t fs_file_exist (fs_t* fs, const char* name);
  • 参数说明:
参数 类型 说明
返回值 bool_t 返回TRUE表示存在,否则表示不存在。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 文件名。

fs_file_printf 函数


  • 函数功能:

写入文件。

  • 函数原型:
int32_t fs_file_printf (fs_file_t* file, const char* const format_str);
  • 参数说明:
参数 类型 说明
返回值 int32_t 返回实际写入的字节数。
file fs_file_t* 文件对象。
format_str const char* const 格式化字符串。

fs_file_read 函数


  • 函数功能:

读取文件。

  • 函数原型:
int32_t fs_file_read (fs_file_t* file, void* buffer, uint32_t size);
  • 参数说明:
参数 类型 说明
返回值 int32_t 返回实际读取的字节数。
file fs_file_t* 文件对象。
buffer void* 用于返回数据的缓冲区。
size uint32_t 缓冲区大小。

fs_file_rename 函数


  • 函数功能:

文件重命名。

  • 函数原型:
ret_t fs_file_rename (fs_t* fs, const char* name, const char* new_name);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回TRUE表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 旧文件名。
new_name const char* 新文件名。

fs_file_seek 函数


  • 函数功能:

定位读写指针到指定的位置。

  • 函数原型:
ret_t fs_file_seek (fs_file_t* file, uint32_t offset);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
file fs_file_t* 文件对象。
offset uint32_t 数据长度。

fs_file_truncate 函数


  • 函数功能:

清除文件内容。

  • 函数原型:
ret_t fs_file_truncate (fs_file_t* file);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
file fs_file_t* 文件对象。

fs_file_write 函数


  • 函数功能:

写入文件。

  • 函数原型:
int32_t fs_file_write (fs_file_t* file, const void* buffer, uint32_t size);
  • 参数说明:
参数 类型 说明
返回值 int32_t 返回实际写入的字节数。
file fs_file_t* 文件对象。
buffer const void* 数据缓冲区。
size uint32_t 数据长度。

fs_get_cwd 函数


  • 函数功能:

获取当前所在目录。

  • 函数原型:
ret_t fs_get_cwd (fs_t* fs, char* path);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
path char* 保存当前所在目录的路径。

fs_get_disk_info 函数


  • 函数功能:

获取文件系统信息。

  • 函数原型:
ret_t fs_get_disk_info (fs_t* fs, const char* value, int32_t* free_kb, int32_t* total_kb);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回不是-1表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
value const char* 卷名。
free_kb int32_t* 用于返回空闲空间大小(KB)
total_kb int32_t* 用于返回总共空间大小(KB)

fs_get_exe 函数


  • 函数功能:

获取可执行文件所在目录。

  • 函数原型:
ret_t fs_get_exe (fs_t* fs, char* path);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
path char* 保存可执行文件的路径。

fs_get_file_size 函数


  • 函数功能:

获取文件大小。

  • 函数原型:
ret_t fs_get_file_size (fs_t* fs, const char* name);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回不是-1表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 文件名。

fs_get_user_storage_path 函数


  • 函数功能:

获取home目录或者应用程序可以写入数据的目录。

  • 函数原型:
ret_t fs_get_user_storage_path (fs_t* fs, char* path);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
path char* 保存路径。

fs_open_dir 函数


  • 函数功能:

打开目录。

  • 函数原型:
fs_dir_t fs_open_dir (fs_t* fs, const char* name);
  • 参数说明:
参数 类型 说明
返回值 fs_dir_t 返回非NULL表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 目录名称。

fs_open_file 函数


  • 函数功能:

打开文件。

  • 函数原型:
ret_t fs_open_file (fs_t* fs, const char* name, const char* mode);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回非NULL表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 文件名。
mode const char* 打开方式。

fs_remove_dir 函数


  • 函数功能:

刪除目录。

  • 函数原型:
ret_t fs_remove_dir (fs_t* fs, const char* name);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 目录名称。

fs_remove_file 函数


  • 函数功能:

刪除文件。

  • 函数原型:
ret_t fs_remove_file (fs_t* fs, const char* name);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 文件名。

fs_stat 函数


  • 函数功能:

获取文件信息。

  • 函数原型:
ret_t fs_stat (fs_t* fs, const char* name, fs_stat_info_t* fst);
  • 参数说明:
参数 类型 说明
返回值 ret_t 返回RET_OK表示成功,否则表示失败。
fs fs_t* 文件系统对象,一般赋值为os_fs()。
name const char* 文件名。
fst fs_stat_info_t* 文件状态信息。

os_fs 函数


  • 函数功能:

获取缺省的文件系统对象。

  • 函数原型:
fs_t* os_fs ();
  • 参数说明:
参数 类型 说明
返回值 fs_t* 返回文件系统对象。
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/seasky100/awtk.git
git@gitee.com:seasky100/awtk.git
seasky100
awtk
awtk
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891