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

Function remove_all_nt5_impl

src/operations.cpp:2181–2245  ·  view source on GitHub ↗

remove_all() implementation for Windows XP and older

Source from the content-addressed store, hash-verified

2179
2180//! remove_all() implementation for Windows XP and older
2181uintmax_t remove_all_nt5_impl(path const& p, error_code* ec)
2182{
2183 error_code dit_create_ec;
2184 for (unsigned int attempt = 0u; attempt < remove_all_directory_replaced_retry_count; ++attempt)
2185 {
2186 const DWORD attrs = ::GetFileAttributesW(p.c_str());
2187 if (BOOST_UNLIKELY(attrs == INVALID_FILE_ATTRIBUTES))
2188 {
2189 DWORD err = ::GetLastError();
2190 if (not_found_error(err))
2191 return 0u;
2192
2193 emit_error(err, p, ec, "boost::filesystem::remove_all");
2194 return static_cast< uintmax_t >(-1);
2195 }
2196
2197 // Recurse into directories, but not into junctions or directory symlinks
2198 const bool recurse = (attrs & FILE_ATTRIBUTE_DIRECTORY) != 0 && (attrs & FILE_ATTRIBUTE_REPARSE_POINT) == 0;
2199 uintmax_t count = 0u;
2200 if (recurse)
2201 {
2202 fs::directory_iterator itr;
2203 fs::detail::directory_iterator_construct(itr, p, directory_options::_detail_no_follow, nullptr, &dit_create_ec);
2204 if (BOOST_UNLIKELY(!!dit_create_ec))
2205 {
2206 if (dit_create_ec == make_error_condition(system::errc::not_a_directory) ||
2207 dit_create_ec == make_error_condition(system::errc::too_many_symbolic_link_levels))
2208 {
2209 continue;
2210 }
2211
2212 if (!ec)
2213 BOOST_FILESYSTEM_THROW(filesystem_error("boost::filesystem::remove_all", p, dit_create_ec));
2214
2215 *ec = dit_create_ec;
2216 return static_cast< uintmax_t >(-1);
2217 }
2218
2219 const fs::directory_iterator end_dit;
2220 while (itr != end_dit)
2221 {
2222 count += fs::detail::remove_all_nt5_impl(itr->path(), ec);
2223 if (ec && *ec)
2224 return static_cast< uintmax_t >(-1);
2225
2226 fs::detail::directory_iterator_increment(itr, ec);
2227 if (ec && *ec)
2228 return static_cast< uintmax_t >(-1);
2229 }
2230 }
2231
2232 bool removed = fs::detail::remove_nt5_impl(p, attrs, ec);
2233 if (ec && *ec)
2234 return static_cast< uintmax_t >(-1);
2235
2236 count += removed;
2237 return count;
2238 }

Callers 1

remove_all_implFunction · 0.85

Calls 7

not_found_errorFunction · 0.85
emit_errorFunction · 0.85
remove_nt5_implFunction · 0.85
pathMethod · 0.80
c_strMethod · 0.45

Tested by

no test coverage detected