MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ open()

bool MayaFlux::IO::SpatialReader::open ( const std::string &  filepath)

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.

Parameters
filepathPath to the file. Resolved the same way other readers do.
Returns
True on success. On failure the error is logged and available from get_last_error().

Definition at line 304 of file SpatialReader.cpp.

305{
306 close();
307
308 const auto resolved = FileReader::resolve_path(filepath);
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);
319 if (!format) {
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;
338 m_impl->index_streams();
339 } catch (const std::exception& e) {
340 close();
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,...)
bool format
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.

References MayaFlux::Journal::FileIO, format, MayaFlux::Journal::IO, MF_ERROR, MF_INFO, and MayaFlux::IO::FileReader::resolve_path().

+ Here is the call graph for this function: