From 7f04d303f21f26e7e21bce92fcc31a3145795ea0 Mon Sep 17 00:00:00 2001 From: iaom <18504285112@163.com> Date: Wed, 7 Jul 2021 10:23:59 +0800 Subject: [PATCH] Update file-utils.cpp/isOrUnder method. --- libsearch/file-utils.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libsearch/file-utils.cpp b/libsearch/file-utils.cpp index 31f1f69..933af51 100644 --- a/libsearch/file-utils.cpp +++ b/libsearch/file-utils.cpp @@ -180,18 +180,15 @@ QString FileUtils::getSettingName(const QString& setting) { bool FileUtils::isOrUnder(QString pathA, QString pathB) { - if(!pathA.startsWith("/")) + if(pathA[0] != "/") pathA.prepend("/"); - if(!pathB.startsWith("/")) + if(pathA[0] != "/") pathB.prepend("/"); - if(pathA == pathB) - return true; - - if(pathA.length() > pathB.length()) + if(pathA.length() < pathB.length()) return false; - if(pathA.startsWith(pathB + "/")) + if(pathA == pathB || pathA.startsWith(pathB + "/")) return true; return false;