]> Dogcows Code - chaz/yoink/blobdiff - src/resource.cc
big batch of progress
[chaz/yoink] / src / resource.cc
index 758827cada59d731bea82a6387c7657fabf33cdc..16b5f213489ae39ed9448901e5f06d0b2a901160 100644 (file)
@@ -37,26 +37,12 @@ namespace dc {
 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 + '/');
@@ -73,16 +59,22 @@ std::string resource::getPathToResource(const std::string& name)
 
        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: *************************************************/
+
This page took 0.019114 seconds and 4 git commands to generate.