MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_file_get_fpos

Function dfs_file_get_fpos

components/dfs/dfs_v2/src/dfs_file.c:266–278  ·  view source on GitHub ↗

* @brief Get the current file position * * This function retrieves the current file position (offset) from the file structure. * For regular files, it acquires a mutex lock before accessing the position to ensure * thread safety. For other file types, it directly returns the position without locking. * * @param[in] file Pointer to the file structure containing position information * * @ret

Source from the content-addressed store, hash-verified

264 * @return off_t Current file position, or 0 if file pointer is NULL
265 */
266off_t dfs_file_get_fpos(struct dfs_file *file)
267{
268 if (file)
269 {
270 if (file->vnode->type == FT_REGULAR)
271 {
272 rt_mutex_take(&file->pos_lock, RT_WAITING_FOREVER);
273 }
274 return file->fpos;
275 }
276
277 return 0;
278}
279
280/**
281 * @brief Set the current file position

Callers 5

preadFunction · 0.85
pwriteFunction · 0.85
dfs_file_readFunction · 0.85
dfs_file_writeFunction · 0.85
dfs_file_lseekFunction · 0.85

Calls 1

rt_mutex_takeFunction · 0.85

Tested by

no test coverage detected