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

Function unlink

components/dfs/dfs_v2/src/dfs_posix.c:486–514  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

484 * @return 0 on successful, -1 on failed.
485 */
486int 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}
515RTM_EXPORT(unlink);
516
517#ifndef _WIN32 /* we can not implement these functions */

Callers

nothing calls this directly

Calls 3

rt_set_errnoFunction · 0.85
dfs_file_lstatFunction · 0.85
dfs_file_unlinkFunction · 0.70

Tested by

no test coverage detected