| 1196 | } |
| 1197 | |
| 1198 | BOOST_FILESYSTEM_DECL |
| 1199 | void directory_iterator_construct(directory_iterator& it, path const& p, directory_options opts, directory_iterator_params* params, system::error_code* ec) |
| 1200 | { |
| 1201 | // At most one of the two options may be specified, and follow_directory_symlink is ignored for directory_iterator. |
| 1202 | BOOST_ASSERT((opts & (directory_options::follow_directory_symlink | directory_options::_detail_no_follow)) != (directory_options::follow_directory_symlink | directory_options::_detail_no_follow)); |
| 1203 | |
| 1204 | if (BOOST_UNLIKELY(p.empty())) |
| 1205 | { |
| 1206 | emit_error(not_found_error_code, p, ec, "boost::filesystem::directory_iterator::construct"); |
| 1207 | return; |
| 1208 | } |
| 1209 | |
| 1210 | if (ec) |
| 1211 | ec->clear(); |
| 1212 | |
| 1213 | try |
| 1214 | { |
| 1215 | boost::intrusive_ptr< detail::dir_itr_imp > imp; |
| 1216 | path filename; |
| 1217 | file_status file_stat, symlink_file_stat; |
| 1218 | system::error_code result = dir_itr_create(imp, p, opts, params, filename, file_stat, symlink_file_stat); |
| 1219 | |
| 1220 | while (true) |
| 1221 | { |
| 1222 | if (result) |
| 1223 | { |
| 1224 | if (result != make_error_condition(system::errc::permission_denied) || |
| 1225 | (opts & directory_options::skip_permission_denied) == directory_options::none) |
| 1226 | { |
| 1227 | if (!ec) |
| 1228 | BOOST_FILESYSTEM_THROW(filesystem_error("boost::filesystem::directory_iterator::construct", p, result)); |
| 1229 | *ec = result; |
| 1230 | } |
| 1231 | |
| 1232 | return; |
| 1233 | } |
| 1234 | |
| 1235 | if (imp->handle == nullptr) // eof, make end |
| 1236 | return; |
| 1237 | |
| 1238 | // Not eof |
| 1239 | const path::string_type::value_type* filename_str = filename.c_str(); |
| 1240 | if (!(filename_str[0] == path::dot // dot or dot-dot |
| 1241 | && (filename_str[1] == static_cast< path::string_type::value_type >('\0') || |
| 1242 | (filename_str[1] == path::dot && filename_str[2] == static_cast< path::string_type::value_type >('\0'))))) |
| 1243 | { |
| 1244 | path full_path(p); |
| 1245 | path_algorithms::append_v4(full_path, filename); |
| 1246 | imp->dir_entry.assign_with_status |
| 1247 | ( |
| 1248 | static_cast< path&& >(full_path), |
| 1249 | file_stat, |
| 1250 | symlink_file_stat |
| 1251 | ); |
| 1252 | it.m_imp.swap(imp); |
| 1253 | return; |
| 1254 | } |
| 1255 |
no test coverage detected