已合并
fix databackup filter png #2239
已合并
I_am__ok创建于 8月6日
共 14 个文件变更+62-14
@@ -232,11 +232,13 @@ private:
232 bool supportWithoutTar_ {false};232 bool supportWithoutTar_ {false};
233 std::vector<std::string> excludeInfos_;233 std::vector<std::string> excludeInfos_;
234 int32_t batchSize_ {500};234 int32_t batchSize_ {500};
235+ std::string callerBundleName_;
235 236
236public:237public:
237 bool GetSupportWithoutTar() const;238 bool GetSupportWithoutTar() const;
238 std::vector<std::string> GetExcludeInfos() const;239 std::vector<std::string> GetExcludeInfos() const;
239 int32_t GetBatchSize() const;240 int32_t GetBatchSize() const;
241+ std::string GetCallerBundleName() const;
240};242};
241} // namespace OHOS::FileManagement::Backup243} // namespace OHOS::FileManagement::Backup
242 244 
@@ -514,6 +514,7 @@ private:
514 bool isClearData_ {true};514 bool isClearData_ {true};
515 bool isSupportWithoutTar_ {false};515 bool isSupportWithoutTar_ {false};
516 int32_t batchSize_ {500};516 int32_t batchSize_ {500};
517+ std::string callerBundleName_;
517 bool isDebug_ {true};518 bool isDebug_ {true};
518 std::map<std::string, off_t> endFileInfos_;519 std::map<std::string, off_t> endFileInfos_;
519 std::map<std::string, std::vector<ErrCode>> errFileInfos_;520 std::map<std::string, std::vector<ErrCode>> errFileInfos_;
@@ -571,6 +572,8 @@ public:
571 bool GetSupportWithoutTar() const;572 bool GetSupportWithoutTar() const;
572 void SetBatchSize(int32_t batchSize);573 void SetBatchSize(int32_t batchSize);
573 int32_t GetBatchSize() const;574 int32_t GetBatchSize() const;
575+ void SetCallerBundleName(const std::string& callerBundleName);
576+ std::string GetCallerBundleName() const;
574 std::string cloneFileInfoDbPath_;577 std::string cloneFileInfoDbPath_;
575 std::string dbPath_;578 std::string dbPath_;
576};579};
@@ -196,10 +196,6 @@ ErrCode ExtBackup::GetParament(const AAFwk::Want &want)
196 supportWithoutTar_ = want.GetBoolParam(BConstants::EXTENSION_SUPPORT_WITHOUT_TAR_PARA, false);196 supportWithoutTar_ = want.GetBoolParam(BConstants::EXTENSION_SUPPORT_WITHOUT_TAR_PARA, false);
197 excludeInfos_ = want.GetStringArrayParam(BConstants::EXTENSION_EXCLUDE_INFOS_PARA);197 excludeInfos_ = want.GetStringArrayParam(BConstants::EXTENSION_EXCLUDE_INFOS_PARA);
198 batchSize_ = want.GetIntParam(BConstants::EXTENSION_BATCH_SIZE_PARA, DEFAULT_BATCH_SIZE);198 batchSize_ = want.GetIntParam(BConstants::EXTENSION_BATCH_SIZE_PARA, DEFAULT_BATCH_SIZE);
199- HILOGI(
200- "backupExtInfo_ is %{public}s, backupScene_ is %{public}s, supportWithoutTar_ is %{public}d, batchSize_ is "
201- "%{public}d",
202- backupExtInfo_.c_str(), backupScene_.c_str(), supportWithoutTar_, batchSize_);
203 nlohmann::json j = nlohmann::json::parse(backupExtInfo_, nullptr, false);199 nlohmann::json j = nlohmann::json::parse(backupExtInfo_, nullptr, false);
204 if (j.is_discarded()) {200 if (j.is_discarded()) {
205 HILOGE("Parse json file path failed, backupExtInfo_ is %{public}s, backupScene_ is %{public}s,"201 HILOGE("Parse json file path failed, backupExtInfo_ is %{public}s, backupScene_ is %{public}s,"
@@ -221,8 +217,10 @@ ErrCode ExtBackup::GetParament(const AAFwk::Want &want)
221 backupExtInfo_.c_str(), backupScene_.c_str(), ancoFileListClone_.c_str(),217 backupExtInfo_.c_str(), backupScene_.c_str(), ancoFileListClone_.c_str(),
222 fileManagerFileListClone_.c_str());218 fileManagerFileListClone_.c_str());
223 }219 }
220+ callerBundleName_ = want.GetStringParam(BConstants::EXTENSION_CALLER_BUNDLE_NAME_PARA);
224 /* backup don't need parament. */221 /* backup don't need parament. */
225- HILOGI("supportWithoutTar_ is %{public}d batchSize_ is %{public}d", supportWithoutTar_, batchSize_);222+ HILOGI("supportWithoutTar_ is %{public}d, batchSize_ is %{public}d, callerBundleName is %{public}s",
223+ supportWithoutTar_, batchSize_, callerBundleName_.c_str());
226 return ERR_OK;224 return ERR_OK;
227}225}
228 226 
@@ -399,4 +397,9 @@ int32_t ExtBackup::GetBatchSize() const
399{397{
400 return batchSize_;398 return batchSize_;
401}399}
400+ 
401+std::string ExtBackup::GetCallerBundleName() const
402+{
403+ return callerBundleName_;
404+}
402} // namespace OHOS::FileManagement::Backup405} // namespace OHOS::FileManagement::Backup
@@ -882,6 +882,8 @@ ErrCode BackupExtExtension::HandleBackup(bool isClearData)
882{882{
883 HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__);883 HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__);
884 SetClearDataFlag(isClearData);884 SetClearDataFlag(isClearData);
885+ std::string callerBundleName = extension_ ? extension_->GetCallerBundleName() : "";
886+ SetCallerBundleName(callerBundleName);
885 if (!IfAllowToBackupRestore()) {887 if (!IfAllowToBackupRestore()) {
886 return BError(BError::Codes::EXT_FORBID_BACKUP_RESTORE, "Application does not allow backup or restore")888 return BError(BError::Codes::EXT_FORBID_BACKUP_RESTORE, "Application does not allow backup or restore")
887 .GetCode();889 .GetCode();
@@ -2210,6 +2212,8 @@ ErrCode BackupExtExtension::HandleRestore(bool isClearData)
2210 try {2212 try {
2211 VerifyCaller();2213 VerifyCaller();
2212 SetClearDataFlag(isClearData);2214 SetClearDataFlag(isClearData);
2215+ std::string callerBundleName = extension_ ? extension_->GetCallerBundleName() : "";
2216+ SetCallerBundleName(callerBundleName);
2213 if (extension_ == nullptr) {2217 if (extension_ == nullptr) {
2214 HILOGE("Failed to handle restore, extension is nullptr");2218 HILOGE("Failed to handle restore, extension is nullptr");
2215 return BError(BError::Codes::EXT_INVAL_ARG, "Extension is nullptr").GetCode();2219 return BError(BError::Codes::EXT_INVAL_ARG, "Extension is nullptr").GetCode();
@@ -113,6 +113,8 @@ ErrCode BackupExtExtension::IncrementalOnBackup(bool isClearData)
113 SetSupportWithoutTar(isSupportWithoutTar);113 SetSupportWithoutTar(isSupportWithoutTar);
114 int32_t batchSize = extension_ ? extension_->GetBatchSize() : 0;114 int32_t batchSize = extension_ ? extension_->GetBatchSize() : 0;
115 SetBatchSize(batchSize);115 SetBatchSize(batchSize);
116+ std::string callerBundleName = extension_ ? extension_->GetCallerBundleName() : "";
117+ SetCallerBundleName(callerBundleName);
116 if (!IfAllowToBackupRestore()) {118 if (!IfAllowToBackupRestore()) {
117 return BError(BError::Codes::EXT_FORBID_BACKUP_RESTORE, "Application does not allow backup or restore")119 return BError(BError::Codes::EXT_FORBID_BACKUP_RESTORE, "Application does not allow backup or restore")
118 .GetCode();120 .GetCode();
@@ -190,7 +192,18 @@ int32_t BackupExtExtension::GetBatchSize() const
190{192{
191 return batchSize_;193 return batchSize_;
192}194}
195+ 
196+void BackupExtExtension::SetCallerBundleName(const std::string& callerBundleName)
197+{
198+ callerBundleName_ = callerBundleName;
199+ ScanFileSingleton::GetInstance().SetCallerBundleName(callerBundleName);
200+ HILOGI("set callerBundleName:%{public}s", callerBundleName.c_str());
201+}
193 202
203+std::string BackupExtExtension::GetCallerBundleName() const
204+{
205+ return callerBundleName_;
206+}
194 207 
195string BackupExtExtension::GetBundlePath()208string BackupExtExtension::GetBundlePath()
196{209{
@@ -630,6 +630,7 @@ void Service::SetWant(AAFwk::Want &want, const BundleName &bundleName, const BCo
630 want.SetParam(BConstants::EXTENSION_SUPPORT_WITHOUT_TAR_PARA, session_->GetSupportWithoutTar(bundleName));630 want.SetParam(BConstants::EXTENSION_SUPPORT_WITHOUT_TAR_PARA, session_->GetSupportWithoutTar(bundleName));
631 want.SetParam(BConstants::EXTENSION_EXCLUDE_INFOS_PARA, session_->GetExcludeInfos(bundleName));631 want.SetParam(BConstants::EXTENSION_EXCLUDE_INFOS_PARA, session_->GetExcludeInfos(bundleName));
632 want.SetParam(BConstants::EXTENSION_BATCH_SIZE_PARA, session_->GetBatchSize(bundleName));632 want.SetParam(BConstants::EXTENSION_BATCH_SIZE_PARA, session_->GetBatchSize(bundleName));
633+ want.SetParam(BConstants::EXTENSION_CALLER_BUNDLE_NAME_PARA, GetCallerName());
633}634}
634 635 
635std::vector<std::string> Service::GetSupportBackupBundleNames(vector<BJsonEntityCaps::BundleInfo> &backupInfos,636std::vector<std::string> Service::GetSupportBackupBundleNames(vector<BJsonEntityCaps::BundleInfo> &backupInfos,
@@ -59,6 +59,7 @@ public:
59 virtual bool GetSupportWithoutTar() const = 0;59 virtual bool GetSupportWithoutTar() const = 0;
60 virtual std::vector<std::string> GetExcludeInfos() const = 0;60 virtual std::vector<std::string> GetExcludeInfos() const = 0;
61 virtual int32_t GetBatchSize() const = 0;61 virtual int32_t GetBatchSize() const = 0;
62+ virtual std::string GetCallerBundleName() const = 0;
62public:63public:
63 virtual std::unique_ptr<NativeReference> LoadSystemModuleByEngine(napi_env, const std::string&, const napi_value*,64 virtual std::unique_ptr<NativeReference> LoadSystemModuleByEngine(napi_env, const std::string&, const napi_value*,
64 size_t) = 0;65 size_t) = 0;
@@ -111,6 +112,7 @@ public:
111 MOCK_METHOD(bool, GetSupportWithoutTar, (), (const));112 MOCK_METHOD(bool, GetSupportWithoutTar, (), (const));
112 MOCK_METHOD((std::vector<std::string>), GetExcludeInfos, (), (const));113 MOCK_METHOD((std::vector<std::string>), GetExcludeInfos, (), (const));
113 MOCK_METHOD(int32_t, GetBatchSize, (), (const));114 MOCK_METHOD(int32_t, GetBatchSize, (), (const));
115+ MOCK_METHOD(std::string, GetCallerBundleName, (), (const));
114public:116public:
115 MOCK_METHOD((std::unique_ptr<NativeReference>), LoadSystemModuleByEngine, (napi_env, const std::string&,117 MOCK_METHOD((std::unique_ptr<NativeReference>), LoadSystemModuleByEngine, (napi_env, const std::string&,
116 const napi_value*, size_t));118 const napi_value*, size_t));
@@ -175,4 +175,9 @@ int32_t ExtBackup::GetBatchSize() const
175{175{
176 return BExtBackup::extBackup->GetBatchSize();176 return BExtBackup::extBackup->GetBatchSize();
177}177}
178+ 
179+std::string ExtBackup::GetCallerBundleName() const
180+{
181+ return BExtBackup::extBackup->GetCallerBundleName();
182+}
178} // namespace OHOS::FileManagement::Backup183} // namespace OHOS::FileManagement::Backup
@@ -21,6 +21,7 @@
21#include <file_ex.h>21#include <file_ex.h>
22#include <gtest/gtest.h>22#include <gtest/gtest.h>
23 23 
24+#include "b_resources/b_constants.h"
24#include "b_utils/scan_result_manager.h"25#include "b_utils/scan_result_manager.h"
25#include "b_utils/scan_file_singleton.h"26#include "b_utils/scan_file_singleton.h"
26#include "test_manager.h"27#include "test_manager.h"
@@ -180,6 +181,7 @@ HWTEST_F(ScanResultManagerTest, ADD_BIG_FILE_TEST_001, testing::ext::TestSize.Le
180{181{
181 GTEST_LOG_(INFO) << "ScanResultManagerTest-begin: ADD_BIG_FILE_TEST_001";182 GTEST_LOG_(INFO) << "ScanResultManagerTest-begin: ADD_BIG_FILE_TEST_001";
182 GTEST_LOG_(INFO) << "1. test restorePath empty";183 GTEST_LOG_(INFO) << "1. test restorePath empty";
184+ manager_.SetCallerBundleName(BConstants::BUNDLE_DATA_CLONE);
183 std::string filePath = "abc/aaa/test1";185 std::string filePath = "abc/aaa/test1";
184 std::string restorePath = "";186 std::string restorePath = "";
185 struct stat sta = {};187 struct stat sta = {};
@@ -223,6 +225,7 @@ HWTEST_F(ScanResultManagerTest, ADD_BIG_FILE_TEST_002, testing::ext::TestSize.Le
223HWTEST_F(ScanResultManagerTest, ADD_BIG_FILE_TEST_003, testing::ext::TestSize.Level1)225HWTEST_F(ScanResultManagerTest, ADD_BIG_FILE_TEST_003, testing::ext::TestSize.Level1)
224{226{
225 GTEST_LOG_(INFO) << "ScanResultManagerTest-begin: ADD_BIG_FILE_TEST_003";227 GTEST_LOG_(INFO) << "ScanResultManagerTest-begin: ADD_BIG_FILE_TEST_003";
228+ manager_.SetCallerBundleName(BConstants::BUNDLE_DATA_CLONE);
226 std::string filePath = "abc/aaa/test3.txt";229 std::string filePath = "abc/aaa/test3.txt";
227 std::string restorePath = "";230 std::string restorePath = "";
228 struct stat sta = {};231 struct stat sta = {};
@@ -265,6 +268,7 @@ HWTEST_F(ScanResultManagerTest, ADD_BIG_FILE_TEST_004, testing::ext::TestSize.Le
265HWTEST_F(ScanResultManagerTest, ADD_BIG_FILE_TEST_005, testing::ext::TestSize.Level1)268HWTEST_F(ScanResultManagerTest, ADD_BIG_FILE_TEST_005, testing::ext::TestSize.Level1)
266{269{
267 GTEST_LOG_(INFO) << "ScanResultManagerTest-begin: ADD_BIG_FILE_TEST_005";270 GTEST_LOG_(INFO) << "ScanResultManagerTest-begin: ADD_BIG_FILE_TEST_005";
271+ manager_.SetCallerBundleName(BConstants::BUNDLE_DATA_CLONE);
268 std::string filePath = "abc/aaa/test5.txt_anco_aaa";272 std::string filePath = "abc/aaa/test5.txt_anco_aaa";
269 std::string restorePath = "";273 std::string restorePath = "";
270 struct stat sta = {};274 struct stat sta = {};
@@ -549,6 +553,7 @@ HWTEST_F(ScanResultManagerTest, ADD_ANCO_BIGFILE_TEST_002, testing::ext::TestSiz
549 std::string restorePath = "";553 std::string restorePath = "";
550 struct stat sta = {};554 struct stat sta = {};
551 555 
556+ manager_.SetCallerBundleName(BConstants::BUNDLE_DATA_CLONE);
552 manager_.AddAncoBigFile(filePath, restorePath, sta);557 manager_.AddAncoBigFile(filePath, restorePath, sta);
553 558 
554 auto fileInfo = manager_.GetFileInfo();559 auto fileInfo = manager_.GetFileInfo();
@@ -573,6 +578,7 @@ HWTEST_F(ScanResultManagerTest, ADD_ANCO_BIGFILE_TEST_003, testing::ext::TestSiz
573 std::string restorePath = "";578 std::string restorePath = "";
574 struct stat sta = {};579 struct stat sta = {};
575 580 
581+ manager_.SetCallerBundleName(BConstants::BUNDLE_DATA_CLONE);
576 manager_.AddAncoBigFile(filePath, restorePath, sta);582 manager_.AddAncoBigFile(filePath, restorePath, sta);
577 583 
578 auto fileInfo = manager_.GetFileInfo();584 auto fileInfo = manager_.GetFileInfo();
@@ -597,12 +597,12 @@ HWTEST_F(StringUtilsTest, STRINGUTILS_IS_SUBDIRECTORY_TEST_001, testing::ext::Te
597*/597*/
598HWTEST_F(StringUtilsTest, STRINGUTILS_GET_FILE_NAME_TEST_001, testing::ext::TestSize.Level1) {598HWTEST_F(StringUtilsTest, STRINGUTILS_GET_FILE_NAME_TEST_001, testing::ext::TestSize.Level1) {
599 // 1. 基础场景:包含路径分隔符的标准路径599 // 1. 基础场景:包含路径分隔符的标准路径
600- EXPECT_EQ(StringUtils::GetFileName("/a/b/c.txt"), "c.txt");600+ EXPECT_EQ(StringUtils::GetFileName("C:\\Program Files\\app.exe"), "C:\\Program Files\\app.exe");
601- EXPECT_EQ(StringUtils::GetFileName("/usr/local/bin"), "bin");601+ EXPECT_EQ(StringUtils::GetFileName("D:\\Data\\file"), "D:\\Data\\file");
602 602 
603 // 2. 基础场景:包含反斜杠的路径603 // 2. 基础场景:包含反斜杠的路径
604 EXPECT_EQ(StringUtils::GetFileName("C:\\Program Files\\app.exe"), "app.exe");604 EXPECT_EQ(StringUtils::GetFileName("C:\\Program Files\\app.exe"), "app.exe");
605- EXPECT_EQ(StringUtils::GetFileName("D:\\Data\\file"), "file");605+ EXPECT_EQ(StringUtils::GetFileName("C:\\a\\b\\"), "C:\\a\\b\\");
606 606 
607 // 3. 混合场景:路径末尾包含分隔符607 // 3. 混合场景:路径末尾包含分隔符
608 // 注意:根据实现逻辑,find_last_of 找到最后一个分隔符,substr 取其后内容。608 // 注意:根据实现逻辑,find_last_of 找到最后一个分隔符,substr 取其后内容。
@@ -619,7 +619,7 @@ HWTEST_F(StringUtilsTest, STRINGUTILS_GET_FILE_NAME_TEST_001, testing::ext::Test
619 619 
620 // 6. 边缘场景:只有分隔符620 // 6. 边缘场景:只有分隔符
621 EXPECT_EQ(StringUtils::GetFileName("/"), "");621 EXPECT_EQ(StringUtils::GetFileName("/"), "");
622- EXPECT_EQ(StringUtils::GetFileName("\\"), "");622+ EXPECT_EQ(StringUtils::GetFileName("\\"), "\\");
623 EXPECT_EQ(StringUtils::GetFileName("////"), "");623 EXPECT_EQ(StringUtils::GetFileName("////"), "");
624 624 
625 // 7. 边缘场景:文件名中包含点(测试是否只取最后一段)625 // 7. 边缘场景:文件名中包含点(测试是否只取最后一段)
@@ -639,8 +639,8 @@ HWTEST_F(StringUtilsTest, STRINGUTILS_IS_PATH_WITH_DIRECTORY_TEST_001, testing::
639 // 1. 基础场景:包含路径分隔符的路径639 // 1. 基础场景:包含路径分隔符的路径
640 EXPECT_TRUE(StringUtils::IsPathWithDirectory("/a/b/c.txt"));640 EXPECT_TRUE(StringUtils::IsPathWithDirectory("/a/b/c.txt"));
641 EXPECT_TRUE(StringUtils::IsPathWithDirectory("/usr/local/bin"));641 EXPECT_TRUE(StringUtils::IsPathWithDirectory("/usr/local/bin"));
642- EXPECT_TRUE(StringUtils::IsPathWithDirectory("C:\\Program Files\\app.exe"));642+ EXPECT_FALSE(StringUtils::IsPathWithDirectory("C:\\Program Files\\app.exe"));
643- EXPECT_TRUE(StringUtils::IsPathWithDirectory("D:\\Data\\file"));643+ EXPECT_FALSE(StringUtils::IsPathWithDirectory("D:\\Data\\file"));
644 644 
645 // 2. 基础场景:相对路径645 // 2. 基础场景:相对路径
646 EXPECT_TRUE(StringUtils::IsPathWithDirectory("./config.ini"));646 EXPECT_TRUE(StringUtils::IsPathWithDirectory("./config.ini"));
@@ -656,7 +656,7 @@ HWTEST_F(StringUtilsTest, STRINGUTILS_IS_PATH_WITH_DIRECTORY_TEST_001, testing::
656 656 
657 // 5. 边缘场景:只有分隔符(根据实现逻辑,这会被视为包含路径)657 // 5. 边缘场景:只有分隔符(根据实现逻辑,这会被视为包含路径)
658 EXPECT_TRUE(StringUtils::IsPathWithDirectory("/"));658 EXPECT_TRUE(StringUtils::IsPathWithDirectory("/"));
659- EXPECT_TRUE(StringUtils::IsPathWithDirectory("\\"));659+ EXPECT_FALSE(StringUtils::IsPathWithDirectory("\\"));
660 EXPECT_TRUE(StringUtils::IsPathWithDirectory("////"));660 EXPECT_TRUE(StringUtils::IsPathWithDirectory("////"));
661}661}
662 662 
@@ -41,6 +41,7 @@ static inline const char *EXTENSION_BACKUP_SCENE_PARA = "backupScene";
41static inline const char *EXTENSION_SUPPORT_WITHOUT_TAR_PARA = "supportWithoutTar";41static inline const char *EXTENSION_SUPPORT_WITHOUT_TAR_PARA = "supportWithoutTar";
42static inline const char *EXTENSION_EXCLUDE_INFOS_PARA = "excludeInfos";42static inline const char *EXTENSION_EXCLUDE_INFOS_PARA = "excludeInfos";
43static inline const char *EXTENSION_BATCH_SIZE_PARA = "batchSize";43static inline const char *EXTENSION_BATCH_SIZE_PARA = "batchSize";
44+static inline const char *EXTENSION_CALLER_BUNDLE_NAME_PARA = "callerBundleName";
44 45 
45enum class ExtensionAction {46enum class ExtensionAction {
46 INVALID = 0,47 INVALID = 0,
@@ -130,6 +130,8 @@ public:
130 130 
131 void SetCompletedFlag(bool value);131 void SetCompletedFlag(bool value);
132 132 
133+ void SetCallerBundleName(const std::string& callerBundleName);
134+ 
133 void WaitForFiles();135 void WaitForFiles();
134 void WaitForCompleted();136 void WaitForCompleted();
135 137 
@@ -155,6 +157,7 @@ public:
155 std::mutex mutexPacket_;157 std::mutex mutexPacket_;
156 std::condition_variable waitPacketFlag_;158 std::condition_variable waitPacketFlag_;
157 std::mutex allFileMutex_;159 std::mutex allFileMutex_;
160+ std::string callerBundleName_;
158};161};
159} // namespace OHOS::FileManagement::Backup162} // namespace OHOS::FileManagement::Backup
160#endif // OHOS_FILEMGMT_BACKUP_SCAN_RESULT_MANAGER_H163#endif // OHOS_FILEMGMT_BACKUP_SCAN_RESULT_MANAGER_H
@@ -245,6 +245,11 @@ void ScanResultManager::SetCompletedFlag(bool isCompleted)
245 }245 }
246}246}
247 247 
248+void ScanResultManager::SetCallerBundleName(const std::string& callerBundleName)
249+{
250+ callerBundleName_ = callerBundleName;
251+}
252+ 
248void ScanResultManager::WaitForFiles()253void ScanResultManager::WaitForFiles()
249{254{
250 std::unique_lock<std::mutex> lock(mutexLock_);255 std::unique_lock<std::mutex> lock(mutexLock_);
@@ -335,7 +335,7 @@ std::string StringUtils::RemoveTrailingSlash(const std::string &path)
335 335 
336std::string StringUtils::GetFileName(const std::string& filePath)336std::string StringUtils::GetFileName(const std::string& filePath)
337{337{
338- size_t lastSlashPos = filePath.find_last_of("/\\");338+ size_t lastSlashPos = filePath.find_last_of("/");
rainlost
rainlostrainlost8月7日

删除\,会导致误判吗,需要确认清楚

likedislike
I_am__ok
I_am__ok
8月7日 评论:
339 if (lastSlashPos == std::string::npos) {339 if (lastSlashPos == std::string::npos) {
340 return filePath;340 return filePath;
341 }341 }
@@ -344,7 +344,7 @@ std::string StringUtils::GetFileName(const std::string& filePath)
344 344 
345bool StringUtils::IsPathWithDirectory(const std::string& filePath)345bool StringUtils::IsPathWithDirectory(const std::string& filePath)
346{346{
347- size_t lastSlashPos = filePath.find_last_of("/\\");347+ size_t lastSlashPos = filePath.find_last_of("/");
rainlost
rainlostrainlost8月7日

删除\,会导致误判吗,需要确认清楚

likedislike
I_am__ok
I_am__ok
8月7日 评论:
348 return (lastSlashPos != std::string::npos);348 return (lastSlashPos != std::string::npos);
349}349}
350} // namespace OHOS::FileManagement::Backup350} // namespace OHOS::FileManagement::Backup