RT-Thread RTOS  1.0.0
An open source embedded real-time operating system
File API

Functions

int dfs_file_open (struct dfs_fd *fd, const char *path, int flags)
int dfs_file_close (struct dfs_fd *fd)
int dfs_file_ioctl (struct dfs_fd *fd, int cmd, void *args)
int dfs_file_read (struct dfs_fd *fd, void *buf, rt_size_t len)
int dfs_file_getdents (struct dfs_fd *fd, struct dirent *dirp, rt_size_t nbytes)
int dfs_file_unlink (const char *path)
int dfs_file_write (struct dfs_fd *fd, const void *buf, rt_size_t len)
int dfs_file_flush (struct dfs_fd *fd)
int dfs_file_lseek (struct dfs_fd *fd, rt_off_t offset)
int dfs_file_stat (const char *path, struct stat *buf)
int dfs_file_rename (const char *oldpath, const char *newpath)

Function Documentation

int dfs_file_open ( struct dfs_fd *  fd,
const char *  path,
int  flags 
)

this function will open a file which specified by path with specified flags.

Parameters:
fdthe file descriptor pointer to return the corresponding result.
paththe specified file path.
flagsthe flags for open operator.
Returns:
0 on successful, -1 on failed.
int dfs_file_close ( struct dfs_fd *  fd)

this function will close a file descriptor.

Parameters:
fdthe file descriptor to be closed.
Returns:
0 on successful, -1 on failed.
int dfs_file_ioctl ( struct dfs_fd *  fd,
int  cmd,
void *  args 
)

this function will perform a io control on a file descriptor.

Parameters:
fdthe file descriptor.
cmdthe command to send to file descriptor.
argsthe argument to send to file descriptor.
Returns:
0 on successful, -1 on failed.
int dfs_file_read ( struct dfs_fd *  fd,
void *  buf,
rt_size_t  len 
)

this function will read specified length data from a file descriptor to a buffer.

Parameters:
fdthe file descriptor.
bufthe buffer to save the read data.
lenthe length of data buffer to be read.
Returns:
the actual read data bytes or 0 on end of file or failed.
int dfs_file_getdents ( struct dfs_fd *  fd,
struct dirent *  dirp,
rt_size_t  nbytes 
)

this function will fetch directory entries from a directory descriptor.

Parameters:
fdthe directory descriptor.
dirpthe dirent buffer to save result.
nbytesthe available room in the buffer.
Returns:
the read dirent, others on failed.
int dfs_file_unlink ( const char *  path)

this function will unlink (remove) a specified path file from file system.

Parameters:
paththe specified path file to be unlinked.
Returns:
0 on successful, -1 on failed.
int dfs_file_write ( struct dfs_fd *  fd,
const void *  buf,
rt_size_t  len 
)

this function will write some specified length data to file system.

Parameters:
fdthe file descriptor.
bufthe data buffer to be written.
lenthe data buffer length
Returns:
the actual written data length.
int dfs_file_flush ( struct dfs_fd *  fd)

this function will flush buffer on a file descriptor.

Parameters:
fdthe file descriptor.
Returns:
0 on successful, -1 on failed.
int dfs_file_lseek ( struct dfs_fd *  fd,
rt_off_t  offset 
)

this function will seek the offset for specified file descriptor.

Parameters:
fdthe file descriptor.
offsetthe offset to be seeked.
Returns:
the current position after seek.
int dfs_file_stat ( const char *  path,
struct stat buf 
)

this function will get file information.

Parameters:
paththe file path.
bufthe data buffer to save stat description.
Returns:
0 on successful, -1 on failed.
int dfs_file_rename ( const char *  oldpath,
const char *  newpath 
)

this function will rename an old path name to a new path name.

Parameters:
oldpaththe old path name.
newpaththe new path name.
Returns:
0 on successful, -1 on failed.
 All Data Structures Variables