From 38f7687b2c27788e0c09a613911a0498c7a50eb8 Mon Sep 17 00:00:00 2001 From: SCG82 Date: Fri, 27 Dec 2019 22:05:59 -0800 Subject: [PATCH] add filePrefix function --- src/Dependency.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Dependency.cpp b/src/Dependency.cpp index 9f33de5..5b4baf9 100644 --- a/src/Dependency.cpp +++ b/src/Dependency.cpp @@ -21,6 +21,11 @@ #include "Settings.h" #include "Utils.h" +static inline std::string filePrefix(std::string in) +{ + return in.substr(0, in.rfind("/")+1); +} + static inline std::string stripPrefix(std::string in) { return in.substr(in.rfind("/")+1); @@ -108,12 +113,12 @@ Dependency::Dependency(std::string path) // check if given path is a symlink if (original_file != rtrim(path)) { filename = stripPrefix(original_file); - prefix = original_file.substr(0, original_file.rfind("/")+1); + prefix = filePrefix(original_file); addSymlink(path); } else { filename = stripPrefix(path); - prefix = path.substr(0, path.rfind("/")+1); + prefix = filePrefix(path); } // check if this dependency is in /usr/lib, /System/Library, or in ignored list @@ -126,7 +131,7 @@ Dependency::Dependency(std::string path) std::string framework_path = getFrameworkPath(original_file); std::string framework_name = stripPrefix(framework_root); filename = framework_name + "/" + framework_path; - prefix = framework_root.substr(0, framework_root.rfind("/")+1); + prefix = filePrefix(framework_root); } // check if the lib is in a known location