From e0e9a556d99fc7e719497c546479450e7556ae0b Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 20 Jan 2015 18:57:31 +0100 Subject: some cosmetic changed to FileLocator.cpp --- src/plugins/filesystem/FileLocator.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/plugins/filesystem/FileLocator.cpp') 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 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 FileLocator::doStream( const std::string &location) const { - std::unique_ptr ifs{new std::ifstream(location)}; - return std::move(ifs); + return std::unique_ptr{new std::ifstream(location)}; } } -- cgit v1.2.3