Open an Ogawa or HDF5 archive and index its streams.
The file is checked first: a missing path or a file that is not an archive fails with one logged line, without Alembic being involved.
305{
307
309
310 std::error_code ec;
311 if (!std::filesystem::is_regular_file(resolved, ec)) {
312 set_error(
"open: no such file: " + resolved);
314 "SpatialReader::open: '{}' does not exist", resolved);
315 return false;
316 }
317
318 const auto format = sniff_format(resolved);
320 set_error(
"open: not an Alembic archive: " + resolved);
322 "SpatialReader::open: '{}' is not an Alembic archive", resolved);
323 return false;
324 }
325
326 try {
327 IArchive archive = *
format == ArchiveFormat::Ogawa
328 ? IArchive(Alembic::AbcCoreOgawa::ReadArchive(), resolved)
329 : Alembic::AbcCoreFactory::IFactory().getArchive(resolved);
330 if (!archive.valid()) {
331 set_error(
"open: archive could not be read: " + resolved);
333 "SpatialReader::open: '{}' could not be read as an archive", resolved);
334 return false;
335 }
336
337 m_impl->archive = archive;
339 } catch (const std::exception& e) {
341 set_error(std::string(
"open: ") + e.what());
343 "SpatialReader::open: failed for '{}': {}", resolved, e.what());
344 return false;
345 }
346
348 "SpatialReader: opened '{}', {} stream(s)", resolved,
m_impl->names.size());
349 return true;
350}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
static std::string resolve_path(const std::string &filepath)
Resolve a filepath against the project source root if not found as-is.
void set_error(std::string msg) const
void close()
Release the archive.
std::unique_ptr< Impl > m_impl
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.