]>
Dogcows Code - chaz/yoink/blob - src/Moof/Resource.cc
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
10 **************************************************************************/
14 #include <boost/algorithm/string.hpp>
17 #include "Resource.hh"
24 std::vector
<std::string
> Resource::gSearchPaths
;
27 void Resource::addSearchPaths(const std::string
& path
)
29 std::vector
<std::string
> paths
;
30 boost::split(paths
, path
, boost::is_any_of(":"));
32 addSearchPaths(paths
);
35 void Resource::addSearchPaths(const std::vector
<std::string
>& path
)
37 std::vector
<std::string
>::const_iterator it
;
39 for (it
= path
.begin(); it
!= path
.end(); ++it
)
41 std::string
onePath(*it
);
43 ASSERT(!onePath
.empty() && "empty search path string");
45 // add a slash if there isn't one already
46 if (*onePath
.rbegin() != '/')
51 #if defined(_WIN32) || defined(__WIN32__)
52 boost::replace_all(onePath
, "/", "\\");
55 gSearchPaths
.push_back(onePath
);
56 logInfo
<< "added search path " << onePath
<< std::endl
;
61 std::string
Resource::getPath(const std::string
& name
)
63 std::vector
<std::string
>::iterator it
;
65 std::string
path(name
);
67 #if defined(_WIN32) || defined(__WIN32__)
68 boost::replace_all(path
, "/", "\\");
71 for (it
= gSearchPaths
.begin(); it
!= gSearchPaths
.end(); ++it
)
73 std::string
fullPath(*it
);
76 if (access(fullPath
.c_str(), R_OK
) == 0) return fullPath
;
79 logWarning
<< "cannot find resource " << name
<< std::endl
;
This page took 0.03624 seconds and 4 git commands to generate.