std::vector<std::string> resource::searchPaths_;
-resource::resource(const std::string& name) throw(exception)
-{
- filePath_ = getPathToResource(name);
-
- if (!filePath_.empty())
- {
- throw exception("cannot find resource file " + name);
- }
-}
-
resource::~resource() {}
-const std::string& resource::getPathToFile()
-{
- return filePath_;
-}
-
void resource::addSearchPath(const std::string& directory)
{
+ // add a slash if there isn't one already
if (directory[directory.length() - 1] != '/')
{
searchPaths_.push_back(directory + '/');
for (i = searchPaths_.begin(); i != searchPaths_.end(); i++)
{
- const char* fullPath = ((*i) + name).c_str();
- if (access(fullPath, R_OK) == 0)
+ std::string fullPath(*i);
+ fullPath += name;
+
+ // TODO access(2) is not all that portable
+ if (access(fullPath.c_str(), R_OK) == 0)
{
- return std::string(fullPath);
+ return fullPath;
}
}
+ // empty string
return std::string();
}
} // namespace dc
+/** vim: set ts=4 sw=4 tw=80: *************************************************/
+