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

Function lwp_setcwd

components/lwp/lwp.c:107–128  ·  view source on GitHub ↗

* @brief Sets the current working directory for the calling LWP or system * * @param[in] buf Pointer to the path string to set as working directory * * @note This function handles both LWP-specific and system-wide working directories: * - For LWPs, sets the working_directory in the LWP structure * - For non-LWP threads, sets the global working_directory variable */

Source from the content-addressed store, hash-verified

105 * - For non-LWP threads, sets the global working_directory variable
106 */
107void lwp_setcwd(char *buf)
108{
109 struct rt_lwp *lwp = RT_NULL;
110
111 if(strlen(buf) >= DFS_PATH_MAX)
112 {
113 rt_kprintf("buf too long!\n");
114 return ;
115 }
116
117 lwp = (struct rt_lwp *)rt_thread_self()->lwp;
118 if (lwp)
119 {
120 rt_strncpy(lwp->working_directory, buf, DFS_PATH_MAX - 1);
121 }
122 else
123 {
124 rt_strncpy(working_directory, buf, DFS_PATH_MAX - 1);
125 }
126
127 return ;
128}
129
130/**
131 * @brief Get the current working directory for the light-weight process

Callers 4

chdirFunction · 0.85
setcwdFunction · 0.85
chdirFunction · 0.85
setcwdFunction · 0.85

Calls 3

rt_kprintfFunction · 0.85
rt_thread_selfFunction · 0.85
rt_strncpyFunction · 0.85

Tested by

no test coverage detected