From 23ecdc426df9f4128e68ca99348d8ad366c55f9f Mon Sep 17 00:00:00 2001 From: "liupeng298@huawei.com" Date: Sat, 29 Mar 2025 15:53:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liupeng298@huawei.com --- src/common/file.cpp | 12 +++--------- src/common/file.h | 6 ++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/common/file.cpp b/src/common/file.cpp index 48da1c66..bbe7a4d2 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -162,18 +162,12 @@ bool HdcFile::ValidateAndSetPaths(CtxFile *context, int argc, char **argv, int & context->localPath = argv[argc - 1]; context->inputLocalPath = context->localPath; } else if ((srcArgvIndex + CMD_FILE_PENULT_PARAM) == argc) { - context->remotePath = argv[argc - 1]; - context->localPath = argv[argc - CMD_FILE_PENULT_PARAM]; - context->inputLocalPath = context->localPath; + SetPathValues(context, argc, argv); } else { - context->remotePath = argv[argc - 1]; - context->localPath = argv[argc - CMD_FILE_PENULT_PARAM]; - context->inputLocalPath = context->localPath; + SetPathValues(context, argc, argv); } } else { - context->remotePath = argv[argc - 1]; - context->localPath = argv[argc - CMD_FILE_PENULT_PARAM]; - context->inputLocalPath = context->localPath; + SetPathValues(context, argc, argv); } return true; } diff --git a/src/common/file.h b/src/common/file.h index f5ff3bca..1b569b38 100644 --- a/src/common/file.h +++ b/src/common/file.h @@ -49,6 +49,12 @@ private: bool ValidateAndSetPaths(CtxFile *context, int argc, char **argv, int &srcArgvIndex); string PathSimplify(const string &path); bool IsPathInsideSandbox(const string &path, const string &appDir); + inline void SetPathValues(CtxFile *context, int argc, char **argv) + { + context->remotePath = argv[argc - 1]; + context->localPath = argv[argc - CMD_FILE_PENULT_PARAM]; + context->inputLocalPath = context->localPath; + } }; } // namespace Hdc -- Gitee