summaryrefslogtreecommitdiff
path: root/src/plugins/filesystem
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-20 18:57:31 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-20 18:57:31 +0100
commite0e9a556d99fc7e719497c546479450e7556ae0b (patch)
tree6004826985be4d8e0eba1d74d8ada42ec05e9f32 /src/plugins/filesystem
parent72ed112a9348561038e8bdcfa14e36512990ed5f (diff)
some cosmetic changed to FileLocator.cpp
Diffstat (limited to 'src/plugins/filesystem')
-rw-r--r--src/plugins/filesystem/FileLocator.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/plugins/filesystem/FileLocator.cpp b/src/plugins/filesystem/FileLocator.cpp
index 9a558eb..467363b 100644
--- a/src/plugins/filesystem/FileLocator.cpp
+++ b/src/plugins/filesystem/FileLocator.cpp
@@ -49,7 +49,7 @@ void FileLocator::addSearchPath(const std::string &path,
std::set<ResourceType> types)
{
// Skip empty or non-existant paths
- if (path.empty() || !fs::exists(path)) {
+ if (path.empty() || !fs::exists(path) || !fs::is_directory(path)) {
return;
}
@@ -80,17 +80,13 @@ void FileLocator::addSearchPath(const std::string &path, ResourceType type)
void FileLocator::addDefaultSearchPaths(const std::string &relativeTo)
{
// Abort if the base directory is empty
- if (relativeTo.empty()) {
- return;
- }
-
- // Abort if the base directory does not exist or is not a directory
- fs::path base(relativeTo);
- if (!fs::exists(base) || !fs::is_directory(base)) {
+ if (relativeTo.empty() || !fs::exists(relativeTo) ||
+ !fs::is_directory(relativeTo)) {
return;
}
// Add the search paths
+ fs::path base{relativeTo};
addSearchPath(base.generic_string(), ResourceType::UNKNOWN);
addSearchPath((base / "domain").generic_string(),
ResourceType::DOMAIN_DESC);
@@ -107,10 +103,12 @@ void FileLocator::addDefaultSearchPaths()
#endif
}
-void FileLocator::addUnittestSearchPath(const std::string &subdir, ResourceType type)
+void FileLocator::addUnittestSearchPath(const std::string &subdir,
+ ResourceType type)
{
addSearchPath((fs::path{SpecialPaths::getDebugTestdataDir()} / subdir)
- .generic_string(), type);
+ .generic_string(),
+ type);
}
bool FileLocator::doLocate(Resource &resource, const std::string &path,
@@ -173,7 +171,6 @@ bool FileLocator::doLocate(Resource &resource, const std::string &path,
std::unique_ptr<std::istream> FileLocator::doStream(
const std::string &location) const
{
- std::unique_ptr<std::istream> ifs{new std::ifstream(location)};
- return std::move(ifs);
+ return std::unique_ptr<std::istream>{new std::ifstream(location)};
}
}