* this function is a POSIX compliant version, which will unlink (remove) a * specified path file from file system. * * @param pathname the specified path name to be unlinked. * * @return 0 on successful, -1 on failed. */
| 484 | * @return 0 on successful, -1 on failed. |
| 485 | */ |
| 486 | int unlink(const char *pathname) |
| 487 | { |
| 488 | int result; |
| 489 | struct stat stat; |
| 490 | |
| 491 | if (pathname == NULL) |
| 492 | { |
| 493 | rt_set_errno(-EBADF); |
| 494 | return -1; |
| 495 | } |
| 496 | |
| 497 | result = dfs_file_lstat(pathname, &stat); |
| 498 | if (result == 0 && S_ISDIR(stat.st_mode)) |
| 499 | { |
| 500 | rt_set_errno(-RT_ERROR); |
| 501 | |
| 502 | return -1; |
| 503 | } |
| 504 | |
| 505 | result = dfs_file_unlink(pathname); |
| 506 | if (result < 0) |
| 507 | { |
| 508 | rt_set_errno(result); |
| 509 | |
| 510 | return -1; |
| 511 | } |
| 512 | |
| 513 | return 0; |
| 514 | } |
| 515 | RTM_EXPORT(unlink); |
| 516 | |
| 517 | #ifndef _WIN32 /* we can not implement these functions */ |
nothing calls this directly
no test coverage detected