MCPcopy Create free account
hub / github.com/boostorg/filesystem / is_empty

Function is_empty

src/operations.cpp:4068–4165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4066);
4067
4068BOOST_FILESYSTEM_DECL
4069bool is_empty(path const& p, system::error_code* ec)
4070{
4071 if (ec)
4072 ec->clear();
4073
4074#if defined(BOOST_FILESYSTEM_POSIX_API)
4075
4076 boost::scope::unique_fd file;
4077 int err = 0;
4078 while (true)
4079 {
4080 file.reset(::open(p.c_str(), O_RDONLY | O_CLOEXEC));
4081 if (BOOST_UNLIKELY(!file))
4082 {
4083 err = errno;
4084 if (err == EINTR)
4085 continue;
4086
4087 fail:
4088 emit_error(err, p, ec, "boost::filesystem::is_empty");
4089 return false;
4090 }
4091
4092 break;
4093 }
4094
4095#if defined(BOOST_FILESYSTEM_NO_O_CLOEXEC) && defined(FD_CLOEXEC)
4096 if (BOOST_UNLIKELY(::fcntl(file.get(), F_SETFD, FD_CLOEXEC) < 0))
4097 {
4098 err = errno;
4099 goto fail;
4100 }
4101#endif
4102
4103#if defined(BOOST_FILESYSTEM_USE_STATX)
4104 struct ::statx path_stat;
4105 if (BOOST_UNLIKELY(invoke_statx(file.get(), "", AT_EMPTY_PATH | AT_NO_AUTOMOUNT, STATX_TYPE | STATX_SIZE, &path_stat) < 0))
4106 {
4107 err = errno;
4108 goto fail;
4109 }
4110
4111 if (BOOST_UNLIKELY((path_stat.stx_mask & (STATX_TYPE | STATX_SIZE)) != (STATX_TYPE | STATX_SIZE)))
4112 {
4113 err = BOOST_ERROR_NOT_SUPPORTED;
4114 goto fail;
4115 }
4116#else
4117 struct ::stat path_stat;
4118 if (BOOST_UNLIKELY(::fstat(file.get(), &path_stat) < 0))
4119 {
4120 err = errno;
4121 goto fail;
4122 }
4123#endif
4124
4125 const mode_t mode = get_mode(path_stat);

Callers 6

create_treeFunction · 0.50
directory_iterator_testsFunction · 0.50
create_directory_testsFunction · 0.50
remove_testsFunction · 0.50
symlink_is_empty_testsFunction · 0.50
query_testFunction · 0.50

Calls 9

emit_errorFunction · 0.85
invoke_statxFunction · 0.85
get_modeFunction · 0.85
is_empty_directoryFunction · 0.85
get_sizeFunction · 0.85
create_file_handleFunction · 0.85
clearMethod · 0.80
getMethod · 0.80
c_strMethod · 0.45

Tested by 6

create_treeFunction · 0.40
directory_iterator_testsFunction · 0.40
create_directory_testsFunction · 0.40
remove_testsFunction · 0.40
symlink_is_empty_testsFunction · 0.40
query_testFunction · 0.40