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

Function lwp_getcwd

components/lwp/lwp.c:139–165  ·  view source on GitHub ↗

* @brief Get the current working directory for the light-weight process * * @return char* Pointer to the current working directory string * * @note The function returns either: * - LWP's working directory (if valid and absolute path) * - System default working directory (if no LWP or invalid path) */

Source from the content-addressed store, hash-verified

137 * - System default working directory (if no LWP or invalid path)
138 */
139char *lwp_getcwd(void)
140{
141 char *dir_buf = RT_NULL;
142 struct rt_lwp *lwp = RT_NULL;
143 rt_thread_t thread = rt_thread_self();
144
145 if (thread)
146 {
147 lwp = (struct rt_lwp *)thread->lwp;
148 }
149
150 if (lwp)
151 {
152 if(lwp->working_directory[0] != '/')
153 {
154 dir_buf = &working_directory[0];
155 }
156 else
157 {
158 dir_buf = &lwp->working_directory[0];
159 }
160 }
161 else
162 dir_buf = &working_directory[0];
163
164 return dir_buf;
165}
166
167/**
168 * @brief Set the kernel stack pointer for the current thread

Callers 5

cmd_lsFunction · 0.85
getcwdFunction · 0.85
dfs_normalize_pathFunction · 0.85
getcwdFunction · 0.85
dfs_normalize_pathFunction · 0.85

Calls 1

rt_thread_selfFunction · 0.85

Tested by

no test coverage detected