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

Function _dfs_normalize_path

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

* @brief Normalize a path by combining base path and link path * * This function creates a temporary path by combining the base path and link path, * then normalizes it using dfs_normalize_path(). It handles memory allocation and * cleanup internally. * * @param[in] path The base path to combine with the link * @param[in] path_len Length of the base path * @param[in] link_fn The link path

Source from the content-addressed store, hash-verified

158 * @note The caller is responsible for freeing the returned path
159 */
160static char *_dfs_normalize_path(const char *path, int path_len, const char *link_fn, int link_len)
161{
162 char *tmp_path, *fp;
163
164 tmp_path = (char *)rt_malloc(path_len + link_len + 2);
165 if (!tmp_path)
166 {
167 return RT_NULL;
168 }
169
170 memcpy(tmp_path, path, path_len);
171 tmp_path[path_len] = '/';
172 memcpy(tmp_path + path_len + 1, link_fn, link_len);
173 tmp_path[path_len + 1 + link_len] = '\0';
174
175 fp = dfs_normalize_path(NULL, tmp_path);
176 rt_free(tmp_path);
177
178 return fp;
179}
180
181/**
182 * @brief Insert a link path into temporary path buffer

Callers 1

dfs_file_realpathFunction · 0.85

Calls 3

rt_mallocFunction · 0.85
rt_freeFunction · 0.85
dfs_normalize_pathFunction · 0.70

Tested by

no test coverage detected