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

Function dfs_dentry_full_path

components/dfs/dfs_v2/src/dfs_dentry.c:365–391  ·  view source on GitHub ↗

* @brief Get the full path of a directory entry by combining mount point and relative path * * @param[in] dentry Pointer to the directory entry structure * * @return char* Newly allocated string containing full path, or NULL if allocation failed * * @note The caller is responsible for freeing the returned string using rt_free() * @note Handles path concatenation with or without additional '

Source from the content-addressed store, hash-verified

363 * @note Handles path concatenation with or without additional '/' separator
364 */
365char* dfs_dentry_full_path(struct dfs_dentry* dentry)
366{
367 char *path = NULL;
368
369 if (dentry && dentry->mnt)
370 {
371 int mnt_len = strlen(dentry->mnt->fullpath);
372 int path_len = strlen(dentry->pathname);
373
374 path = (char *) rt_malloc(mnt_len + path_len + 3);
375 if (path)
376 {
377 if (dentry->pathname[0] == '/' || dentry->mnt->fullpath[mnt_len - 1] == '/')
378 {
379 rt_snprintf(path, mnt_len + path_len + 2, "%s%s", dentry->mnt->fullpath,
380 dentry->pathname);
381 }
382 else
383 {
384 rt_snprintf(path, mnt_len + path_len + 2, "%s/%s", dentry->mnt->fullpath,
385 dentry->pathname);
386 }
387 }
388 }
389
390 return path;
391}
392
393/**
394 * @brief Get the parent directory path of a dentry by combining mount point and path

Callers 6

sys_fchdirFunction · 0.85
proc_pid_fd_lookupFunction · 0.85
openatFunction · 0.85
utimensatFunction · 0.85
dfs_fd_dumpFunction · 0.85

Calls 2

rt_mallocFunction · 0.85
rt_snprintfFunction · 0.85

Tested by

no test coverage detected