yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1#ifndef SLANG_DIRECTORY_UTIL_H 2#define SLANG_DIRECTORY_UTIL_H 3 4#include "../../source/core/slang-io.h" 5 6class CombinePathVisitor :public Slang ::Path ::Visitor 7{ 8public : 9virtual void accept (Slang ::Path ::Type type ,const Slang ::UnownedStringSlice & filename ) 10SLANG_OVERRIDE 11 { 12using namespace Slang ; 13const Path ::TypeFlags flags = Path ::TypeFlags (1 ) <<int (type ); 14if (flags & m_allowedFlags ) 15 { 16m_paths .add (Path ::combine (m_directoryPath ,filename )); 17 } 18 } 19 20/// Ctor 21CombinePathVisitor (const Slang ::String & directoryPath ,Slang ::Path ::TypeFlags allowedFlags ) 22 :m_directoryPath (directoryPath ),m_allowedFlags (allowedFlags ) 23 { 24 } 25 26Slang ::List < Slang ::String > m_paths ; 27 28protected : 29Slang ::Path ::TypeFlags m_allowedFlags ; 30Slang ::String m_directoryPath ; 31}; 32 33/* A helper class for finding the contents of directories */ 34class DirectoryUtil 35{ 36public : 37/// Enumerate subdirectories in the given `directoryPath`, storing in outPaths. 38/// @return SLANG_OK on success or SLANG_E_NOT_FOUND if directory is not found. 39static SlangResult findDirectories ( 40const Slang ::String & directoryPath , 41Slang ::List < Slang ::String >& outPaths ); 42 43/// Enumerate files in the given `directoryPath` that match the provided 44/// `pattern` as a simplified regex for files to return (e.g., "*.txt") 45/// Note that the specifics of the pattern matching are *target specific* 46/// @return SLANG_OK on success or SLANG_E_NOT_FOUND if directory is not found. 47static SlangResult findFilesMatchingPattern ( 48const Slang ::String & directoryPath , 49const char * pattern , 50Slang ::List < Slang ::String >& outPaths ); 51 52/// Enumerate files in the given `directoryPath`, storing in outPaths. 53/// @return SLANG_OK on success or SLANG_E_NOT_FOUND if directory is not found. 54static SlangResult findFiles ( 55const Slang ::String & directoryPath , 56Slang ::List < Slang ::String >& outPaths ); 57}; 58 59#endif // SLANG_DIRECTORY_UTIL_H