2011-05-05 17:00:00 +00:00
|
|
|
#ifndef COMPONENTS_FILES_COLLECTION_HPP
|
|
|
|
#define COMPONENTS_FILES_COLLECTION_HPP
|
|
|
|
|
2022-06-08 21:25:50 +00:00
|
|
|
#include <filesystem>
|
2011-08-19 19:06:09 +00:00
|
|
|
|
2011-05-05 17:00:00 +00:00
|
|
|
#include "multidircollection.hpp"
|
|
|
|
|
|
|
|
namespace Files
|
|
|
|
{
|
|
|
|
class Collections
|
|
|
|
{
|
|
|
|
public:
|
2011-05-05 17:32:42 +00:00
|
|
|
Collections();
|
|
|
|
|
2011-05-05 17:00:00 +00:00
|
|
|
///< Directories are listed with increasing priority.
|
2023-05-31 21:11:03 +00:00
|
|
|
Collections(const Files::PathContainer& directories);
|
2011-05-05 17:00:00 +00:00
|
|
|
|
|
|
|
///< Return a file collection for the given extension. Extension must contain the
|
|
|
|
/// leading dot and must be all lower-case.
|
2011-08-19 19:06:09 +00:00
|
|
|
const MultiDirCollection& getCollection(const std::string& extension) const;
|
2011-05-05 17:00:00 +00:00
|
|
|
|
2022-07-02 22:02:29 +00:00
|
|
|
std::filesystem::path getPath(const std::string& file) const;
|
2013-03-09 20:08:08 +00:00
|
|
|
///< Return full path (including filename) of \a file.
|
|
|
|
///
|
|
|
|
/// If the file does not exist in any of the collection's
|
|
|
|
/// directories, an exception is thrown. \a file must include the
|
|
|
|
/// extension.
|
|
|
|
|
2022-07-02 22:02:29 +00:00
|
|
|
bool doesExist(const std::string& file) const;
|
2013-03-09 20:08:08 +00:00
|
|
|
///< \return Does a file with the given name exist?
|
|
|
|
|
2012-03-30 12:45:32 +00:00
|
|
|
const Files::PathContainer& getPaths() const;
|
|
|
|
|
2011-08-19 19:06:09 +00:00
|
|
|
private:
|
|
|
|
typedef std::map<std::string, MultiDirCollection> MultiDirCollectionContainer;
|
2011-09-02 20:45:21 +00:00
|
|
|
Files::PathContainer mDirectories;
|
2011-08-19 19:06:09 +00:00
|
|
|
|
|
|
|
mutable MultiDirCollectionContainer mCollections;
|
2011-05-05 17:00:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|