/** * @file include/ActivMiddleware/ActivBase/DirectoryWalker.h * * @brief Directory walker class. */ #if (!defined ACTIV_BASE_DIRECTORY_WALKER_H) #define ACTIV_BASE_DIRECTORY_WALKER_H #include "ActivMiddleware/ActivBase/External.h" //! Activ namespace. namespace Activ { /** * @brief Directory walker class. * * Do not assume any ordering of OnDirectory() or OnFile() callbacks. */ class DirectoryWalker { public: /** * @brief Constructor. */ ACTIV_BASE_API DirectoryWalker(); /** * @brief Destructor. */ ACTIV_BASE_API virtual ~DirectoryWalker(); /** * @brief Walk a directory. * * To recursively walk a directory, override OnDirectory() and call Walk() again, passing * File::MakePath(path, name) as the path parameter. This is assuming your derived DirectoryWalker class is * re-entrant in such a manner (the DirectoryWalker class itself is). * * @param path the path to the directory to walk. * @param wildcardPattern only return files/directories matching this wildcard pattern (leave blank to return everything) * * @retval STATUS_CODE_SUCCESS * @retval STATUS_CODE_FAILURE * @retval STATUS_CODE_NOT_FOUND * @retval STATUS_CODE_INTERRUPTED */ ACTIV_BASE_API StatusCode Walk(const String &path, const String &wildcardPattern = String()); protected: /** * @brief Callback function for when directories are located in the directory walk. * * @param path the path to the directory, not including the directory's name. I.e. the value of @a path passed to Walk(). * @param name the name of the directory. * * @return true to continue, false to stop (interrupt) the walk. */ ACTIV_BASE_API virtual bool OnDirectory(const String &path, const String &name); /** * @brief Callback function for when files are located in a directory walk. * * @param path the path to the directory, not including the file's name. I.e. the value of @a path passed to Walk(). * @param name the name of the file. * * @return true to continue, false to stop (interrupt) the walk. */ ACTIV_BASE_API virtual bool OnFile(const String &path, const String &name); #if (defined ACTIV_PLATFORM_POSIX) /** * @brief Callback function for when symlinks are located in a directory walk. * * @param path the path to the directory, not including the symlink's name. I.e. the value of @a path passed to Walk(). * @param name the name of the symlink. * @param linkTarget the target of the link (absolute path). * * @return true to continue, false to stop (interrupt) the walk. */ ACTIV_BASE_API virtual bool OnLink(const String &path, const String &name, const String &linkTarget); #endif }; } // namespace Activ #endif // (!defined ACTIV_BASE_DIRECTORY_WALKER_H)