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

◆ eval_file()

MAYAFLUX_HOST_API Result< void > MayaFlux::Host::eval_file ( const std::filesystem::path & path)

Evaluate a source file by including it.

The file is checked at call time. Before start_session the include is staged and evaluated at start.

Parameters
pathPath to an existing regular file, absolute or relative to the working directory.
Returns
Success, or the reason the file was refused or failed to evaluate.

Definition at line 364 of file Session.cpp.

365{
366 auto located = Platform::acquire_library(Platform::LibraryFromPath { .path = path });
367 if (!located) {
368 return std::unexpected(detail::to_failure(located.error()));
369 }
370
371 const std::string file = located->path.generic_string();
372 if (file.find_first_of("\"\r\n") != std::string::npos) {
373 return refuse("path cannot be included: " + file);
374 }
375
376 return eval("#include \"" + file + "\"");
377}
Failure to_failure(const Platform::AcquireFailure &failure)
Definition Session.cpp:165
Result< void > eval(const std::string &code)
Evaluate a code snippet.
Definition Session.cpp:342
Acquired< LibraryLocation > acquire_library(const LibrarySource &source)
Resolve a library request to a location the loader can open.
A shared library at an explicit file path, absolute or relative to the working directory.

References MayaFlux::Platform::acquire_library(), eval(), and MayaFlux::Host::detail::to_failure().

Referenced by add_header().

Here is the call graph for this function:
Here is the caller graph for this function: