* this function is a POSIX compliant version, which will return current * working directory. * * @param buf the returned current directory. * @param size the buffer size. * * @return the returned current directory. */
| 1337 | * @return the returned current directory. |
| 1338 | */ |
| 1339 | char *getcwd(char *buf, size_t size) |
| 1340 | { |
| 1341 | if (buf == NULL) |
| 1342 | { |
| 1343 | rt_set_errno(-EBADF); |
| 1344 | return NULL; |
| 1345 | } |
| 1346 | |
| 1347 | #ifdef DFS_USING_WORKDIR |
| 1348 | char *dir_buf = RT_NULL; |
| 1349 | |
| 1350 | dfs_lock(); |
| 1351 | |
| 1352 | #ifdef RT_USING_SMART |
| 1353 | dir_buf = lwp_getcwd(); |
| 1354 | #else |
| 1355 | dir_buf = &working_directory[0]; |
| 1356 | #endif |
| 1357 | |
| 1358 | /* copy to buf parameter */ |
| 1359 | if (buf) |
| 1360 | { |
| 1361 | rt_strncpy(buf, dir_buf, size); |
| 1362 | } |
| 1363 | |
| 1364 | dfs_unlock(); |
| 1365 | #else |
| 1366 | rt_kprintf(NO_WORKING_DIR); |
| 1367 | #endif |
| 1368 | |
| 1369 | return buf; |
| 1370 | } |
| 1371 | RTM_EXPORT(getcwd); |
| 1372 | |
| 1373 | /** |
nothing calls this directly
no test coverage detected