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

Function directory_status

src/system.h:318–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316 DS_NONEMPTY = 0,
317};
318static inline int
319directory_status (int fd_cwd, char const *dir)
320{
321 DIR *dirp;
322 bool no_direntries;
323 int saved_errno;
324 int fd = openat (fd_cwd, dir,
325 (O_RDONLY | O_DIRECTORY
326 | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK));
327
328 if (fd < 0)
329 return errno;
330
331 dirp = fdopendir (fd);
332 if (dirp == NULL)
333 {
334 saved_errno = errno;
335 close (fd);
336 return saved_errno;
337 }
338
339 errno = 0;
340 no_direntries = !readdir_ignoring_dot_and_dotdot (dirp);
341 saved_errno = errno;
342 closedir (dirp);
343 return no_direntries && saved_errno == 0 ? DS_EMPTY : saved_errno;
344}
345
346/* Factor out some of the common --help and --version processing code. */
347

Callers 2

get_dir_statusFunction · 0.85
ignorable_failureFunction · 0.85

Calls 1

Tested by

no test coverage detected