From c6f8ebcd96cee3133d7b1151b1d30454d0fe368e Mon Sep 17 00:00:00 2001 From: Bernd Hentschel <hentschel@vr.rwth-aachen.de> Date: Mon, 25 Jun 2018 08:55:13 +0200 Subject: [PATCH] remove redundant code (file exists test) --- library/phx/resources/resource_utils.cpp | 9 +++------ library/phx/resources/resource_utils.hpp | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/library/phx/resources/resource_utils.cpp b/library/phx/resources/resource_utils.cpp index 6f0d536d..3804fae8 100644 --- a/library/phx/resources/resource_utils.cpp +++ b/library/phx/resources/resource_utils.cpp @@ -28,6 +28,8 @@ #include <string> #include <vector> +#include "boost/filesystem.hpp" + #include "phx/resources/resource_manager.hpp" #include "phx/resources_path.hpp" @@ -81,14 +83,9 @@ std::string ResourceUtils::ExtractFileExtension(const std::string& file_name) { std::string ResourceUtils::FindFileInSearchPath(const std::string& file_name) { for (auto& entry : resource_search_paths_) { auto full_name = entry + file_name; - if (FileExists(full_name)) return full_name; + if (boost::filesystem::exists(full_name.c_str())) return full_name; } return ""; } -bool ResourceUtils::FileExists(const std::string& full_file_name) { - std::fstream target_file(full_file_name.c_str()); - return target_file.is_open(); -} - } // namespace phx diff --git a/library/phx/resources/resource_utils.hpp b/library/phx/resources/resource_utils.hpp index 8dd2553f..95cba49f 100644 --- a/library/phx/resources/resource_utils.hpp +++ b/library/phx/resources/resource_utils.hpp @@ -72,7 +72,6 @@ class PHOENIX_EXPORT ResourceUtils final { private: static std::string FindFileInSearchPath(const std::string& file_name); - static bool FileExists(const std::string& full_file_name); static std::vector<std::string> resource_search_paths_; }; -- GitLab