MCPcopy Create free account
hub / github.com/coreutils/coreutils / target_directory_operand

Function target_directory_operand

gl/lib/targetdir.c:60–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 On failure return -2 if AT_FDCWD is -1, -1 otherwise. */
59
60int
61target_directory_operand (char const *file, struct stat *st)
62{
63 if (must_be_working_directory (file))
64 return AT_FDCWD;
65
66 int fd = open (file, O_PATHSEARCH | O_DIRECTORY);
67
68 /* On platforms lacking O_PATH, using O_SEARCH | O_DIRECTORY to
69 open an overly-protected non-directory can fail with either
70 EACCES or ENOTDIR. Prefer ENOTDIR as it makes for better
71 diagnostics. */
72 if (O_PATHSEARCH == O_SEARCH && fd < 0 && errno == EACCES)
73 errno = stat (file, st) < 0 || S_ISDIR (st->st_mode) ? EACCES : ENOTDIR;
74
75 return fd - (AT_FDCWD == -1 && fd < 0);
76}

Callers 3

mainFunction · 0.85
mainFunction · 0.85
do_copyFunction · 0.85

Calls 2

statClass · 0.70

Tested by

no test coverage detected