TuyaOS
宏定义 | 类型定义 | 函数
tuya_uf_db.h 文件参考

tuya unique file database module 更多...

#include "tuya_cloud_types.h"
tuya_uf_db.h 的引用(Include)关系图:

浏览源代码.

宏定义

#define UF_SEEK_CUR   1
 
#define UF_SEEK_END   2
 
#define UF_SEEK_SET   0
 

类型定义

typedef VOID uFILE
 unique file handle
 
typedef unsigned char ufmode_t
 unique file mode
 

函数

OPERATE_RET uf_db_init (VOID)
 tuya unique file database system initialization 更多...
 
OPERATE_RET uf_db_user_param_read (OUT BYTE_T **buf, OUT UINT_T *len)
 read user parameter from unique file database 更多...
 
OPERATE_RET uf_db_user_param_write (IN BYTE_T *data, IN CONST UINT_T len)
 write user parameter to unique file database 更多...
 
INT_T ufaccess (IN CHAR_T *filepath, IN INT_T mode)
 test the permission of the unique file 更多...
 
OPERATE_RET ufclose (IN uFILE *fd)
 close a unique file 更多...
 
OPERATE_RET ufdelete (IN CHAR_T *filepath)
 delete the unique file 更多...
 
BOOL_T ufeof (IN uFILE *fd)
 check if the current offset reach the end of the file 更多...
 
BOOL_T ufexist (IN CHAR_T *filepath)
 check if unique file is exist 更多...
 
INT_T ufflush (IN uFILE *stream)
 flush the unique file, write the cache to physical disk 更多...
 
OPERATE_RET ufformat (VOID)
 format uf flash 更多...
 
INT_T ufgetc (IN uFILE *stream)
 read a character from unique file 更多...
 
CHAR_T * ufgets (IN CHAR_T *s, IN INT_T n, IN uFILE *stream)
 read a line from unique file 更多...
 
INT_T ufgetsize (IN CHAR_T *filepath)
 get the size of the unique file 更多...
 
INT_T ufileno (IN uFILE *stream)
 get the file description 更多...
 
OPERATE_RET ufinit (VOID)
 unique file system initialization 更多...
 
uFILEufopen (IN CHAR_T *filepath, IN CHAR_T *mode)
 open a unique file 更多...
 
INT_T ufprintf (IN uFILE *stream, IN const char *pFmt,...)
 write a specail format to unique file 更多...
 
UINT_T ufread (IN uFILE *fd, IN UCHAR_T *buf, IN CONST UINT_T len)
 read from unique file 更多...
 
INT_T ufscanf (IN uFILE *stream, IN INT_T count, IN PCHAR_T pFmt,...)
 read a special format from unique file 更多...
 
INT_T ufseek (IN uFILE *fd, IN UINT_T offset, IN CONST ufmode_t uf_mode)
 seek to the offset of the unique file 更多...
 
INT_T ufsync (IN INT_T fd)
 sync the unique file, write the file info to pysical disk 更多...
 
INT_T uftell (IN uFILE *fd)
 get current offset of the unique file 更多...
 
UINT_T ufwrite (IN uFILE *fd, IN UCHAR_T *buf, IN CONST UINT_T len)
 write to unique file 更多...
 
UINT_T ufwrite_raw_end (IN uFILE *fd)
 Exit ufwrite raw mode 更多...
 
UINT_T ufwrite_raw_start (IN uFILE *fd)
 enter ufwrite raw mode 更多...
 

详细描述

tuya unique file database module

日期
2019-04-25

copyright Copyright (c) {2018-2020} 涂鸦科技 www.tuya.com

函数说明

◆ uf_db_init()

OPERATE_RET uf_db_init ( VOID  )

tuya unique file database system initialization

返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ uf_db_user_param_read()

OPERATE_RET uf_db_user_param_read ( OUT BYTE_T **  buf,
OUT UINT_T *  len 
)

read user parameter from unique file database

参数
[out]bufbuffer of the data read from user parameter file database
[out]lenlength of the data read from user parameter file database
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
the user parameter database is a file named "user_param_key", and max size is 4096 byte

◆ uf_db_user_param_write()

OPERATE_RET uf_db_user_param_write ( IN BYTE_T *  data,
IN CONST UINT_T  len 
)

write user parameter to unique file database

参数
[in]datadata write to user parameter database
[in]lendata length write to user parameter database
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
the user parameter database is a file named "user_param_key", and max size is 4096 byte

◆ ufaccess()

INT_T ufaccess ( IN CHAR_T *  filepath,
IN INT_T  mode 
)

test the permission of the unique file

参数
[in]filepaththe full file path
[in]modecheck the access mode
返回
INT_T
注解
the access mode contains "R_OK": read permission,"W_OK": write permission,"X_OK":excute permission,"F_OK": existed, in flash unique file system, only support "F_OK" mode.

◆ ufclose()

OPERATE_RET ufclose ( IN uFILE fd)

close a unique file

参数
fdthe file handle
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ ufdelete()

OPERATE_RET ufdelete ( IN CHAR_T *  filepath)

delete the unique file

参数
[in]filepaththe full file path
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ ufeof()

BOOL_T ufeof ( IN uFILE fd)

check if the current offset reach the end of the file

参数
[in]fdthe file handle
返回
TRUE on reach the EOF, FLASE on not reach the EOF.

◆ ufexist()

BOOL_T ufexist ( IN CHAR_T *  filepath)

check if unique file is exist

参数
[in]filepaththe full file path
返回
TRUE on existed, FLASE on not existed.

◆ ufflush()

INT_T ufflush ( IN uFILE stream)

flush the unique file, write the cache to physical disk

参数
[in]streamthe file handle
返回
0 on success, others on failed
注解
in flash unique file system, always return success because the data was write to flash directly.

◆ ufformat()

OPERATE_RET ufformat ( VOID  )

format uf flash

返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ ufgetc()

INT_T ufgetc ( IN uFILE stream)

read a character from unique file

参数
[in]streamthe file handle
返回
-1 on failed, others means success

◆ ufgets()

CHAR_T * ufgets ( IN CHAR_T *  s,
IN INT_T  n,
IN uFILE stream 
)

read a line from unique file

参数
[in]sthe buffer used to save the string
[in]nthe numbers want to get from the file
[in]streamthe file handle
返回
NULL on failed, others on success
注解
stop and return if reach the n or find "\n" character

◆ ufgetsize()

INT_T ufgetsize ( IN CHAR_T *  filepath)

get the size of the unique file

参数
[in]filepaththe full file path
返回
the size of the file

◆ ufileno()

INT_T ufileno ( IN uFILE stream)

get the file description

参数
[in]streamthe file handle
返回
the file description
注解
in flash unique file system, always return 0, it not support file description

◆ ufinit()

OPERATE_RET ufinit ( VOID  )

unique file system initialization

返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
it will call by uf_db_init

◆ ufopen()

uFILE * ufopen ( IN CHAR_T *  filepath,
IN CHAR_T *  mode 
)

open a unique file

参数
[in]filepaththe full file path
[in]modethe open mode
返回
the handle of the file
注解
the mode is same as file system open mode, contains "r","r+","a","a+","w","w+", and also support binary mode.

◆ ufprintf()

INT_T ufprintf ( IN uFILE stream,
IN const char *  pFmt,
  ... 
)

write a specail format to unique file

参数
[in]streamthe file handle
[in]pFmtthe variable parameters format
...
返回
the counts of written characters

◆ ufread()

UINT_T ufread ( IN uFILE fd,
IN UCHAR_T *  buf,
IN CONST UINT_T  len 
)

read from unique file

参数
[in]fdthe file handle
[in]bufthe buffer used to save the data read from the unique file
[in]lenthe length want to read
返回
the number of byte actually read from the unique file

◆ ufscanf()

INT_T ufscanf ( IN uFILE stream,
IN INT_T  count,
IN PCHAR_T  pFmt,
  ... 
)

read a special format from unique file

参数
[in]streamthe file handle
[in]countthe counts read from file
[in]pFmtthe variable parameters format
...
返回
the items in the paramter list

◆ ufseek()

INT_T ufseek ( IN uFILE fd,
IN UINT_T  offset,
IN CONST ufmode_t  uf_mode 
)

seek to the offset of the unique file

参数
[in]fdthe file handle
[in]offsetthe offset want to seek
[in]uf_modethe seek mode
返回
the current offset after seek

◆ ufsync()

INT_T ufsync ( IN INT_T  fd)

sync the unique file, write the file info to pysical disk

参数
[in]fdthe file handle
返回
0 on success, others on failed
注解
in flash unique file system, always return success because the data was write to flash directly.

◆ uftell()

INT_T uftell ( IN uFILE fd)

get current offset of the unique file

参数
fdthe file handle
返回
the current offset of the file

◆ ufwrite()

UINT_T ufwrite ( IN uFILE fd,
IN UCHAR_T *  buf,
IN CONST UINT_T  len 
)

write to unique file

参数
[in]fdthe file handle
[in]bufthe buffer write to the unique file
[in]lenthe length write to the unique file, in byte
返回
characters written to the unique file

◆ ufwrite_raw_end()

UINT_T ufwrite_raw_end ( IN uFILE fd)

Exit ufwrite raw mode

参数
[in]fdthe file handle
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
all ufwrite operation chould cause data loss before ufwrite_raw_end() invoked

◆ ufwrite_raw_start()

UINT_T ufwrite_raw_start ( IN uFILE fd)

enter ufwrite raw mode

参数
[in]fdthe file handle
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
all ufwrite operation chould cause data loss before ufwrite_raw_end() invoked