* @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) */
| 137 | * - System default working directory (if no LWP or invalid path) |
| 138 | */ |
| 139 | char *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 |
no test coverage detected