Gromacs
2025-dev-20241002-88a4191
|
#include <gromacs/utility/include/gromacs/utility/fileredirector.h>
Allows overriding file existence checks from code that supports it.
The calling code should take in this interface and use the methods in it all file system operations that need to support this redirection.
This allows tests to override the file existence checks without actually using the file system. See IFileOutputRedirector for notes on a typical usage pattern.
With some further refactoring of the File class, this could also support redirecting input files from in-memory buffers as well, but for now the current capabilities are sufficient.
Public Member Functions | |
virtual bool | fileExists (const std::filesystem::path &filename, const File::NotFoundHandler &onNotFound) const =0 |
Checks whether the provided path exists (and is a file). More... | |
|
pure virtual |
Checks whether the provided path exists (and is a file).
The onNotFound
can be used to influence the behavior on error conditions. Functions to pass as this parameter are provided as members of gmx::File.
Implemented in gmx::test::TestFileInputRedirector, and gmx::anonymous_namespace{fileredirector.cpp}::DefaultInputRedirector.