MaterialX 1.38.2
Functions
Util.h File Reference

Format utility methods. More...

#include <MaterialXCore/Document.h>
#include <MaterialXCore/Element.h>
#include <MaterialXCore/Interface.h>
#include <MaterialXFormat/Export.h>
#include <MaterialXFormat/File.h>
#include <MaterialXFormat/XmlIo.h>

Go to the source code of this file.

Functions

string readFile (const FilePath &file)
 Read the given file and return a string containing its contents; if the read is not successful, then the empty string is returned.
 
void getSubdirectories (const FilePathVec &rootDirectories, const FileSearchPath &searchPath, FilePathVec &subDirectories)
 Get all subdirectories for a given set of directories and search paths.
 
void loadDocuments (const FilePath &rootPath, const FileSearchPath &searchPath, const StringSet &skipFiles, const StringSet &includeFiles, vector< DocumentPtr > &documents, StringVec &documentsPaths, const XmlReadOptions *readOptions=nullptr, StringVec *errors=nullptr)
 Scans for all documents under a root path and returns documents which can be loaded.
 
void loadLibrary (const FilePath &file, DocumentPtr doc, const FileSearchPath &searchPath=FileSearchPath(), const XmlReadOptions *readOptions=nullptr)
 Load a given MaterialX library into a document.
 
StringSet loadLibraries (const FilePathVec &libraryFolders, const FileSearchPath &searchPath, DocumentPtr doc, const StringSet &excludeFiles=StringSet(), const XmlReadOptions *readOptions=nullptr)
 Load all MaterialX files within the given library folders into a document, using the given search path to locate the folders on the file system.
 
void flattenFilenames (DocumentPtr doc, const FileSearchPath &searchPath=FileSearchPath(), StringResolverPtr customResolver=nullptr)
 Flatten all filenames in the given document, applying string resolvers at the scope of each element and removing all fileprefix attributes. More...
 

Detailed Description

Format utility methods.

Function Documentation

◆ flattenFilenames()

MX_FORMAT_API void flattenFilenames ( DocumentPtr  doc,
const FileSearchPath searchPath = FileSearchPath(),
StringResolverPtr  customResolver = nullptr 
)

Flatten all filenames in the given document, applying string resolvers at the scope of each element and removing all fileprefix attributes.

Parameters
docThe document to modify.
searchPathAn optional search path for relative to absolute path conversion.
customResolverAn optional custom resolver to apply.