From 73ca80674fa231e3a94e76a2a264e454cb28d7f9 Mon Sep 17 00:00:00 2001 From: tianp Date: Mon, 4 Aug 2025 10:16:06 +0800 Subject: [PATCH] =?UTF-8?q?file=E7=B1=BB=E5=B1=9E=E6=80=A7=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tianp Change-Id: Iddeb386ca4e96da6e5afb47c8ffc76ad3fae9a2c --- interfaces/kits/js/src/mod_fs/class_file/fs_file.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interfaces/kits/js/src/mod_fs/class_file/fs_file.cpp b/interfaces/kits/js/src/mod_fs/class_file/fs_file.cpp index 45cb2d418..ededa8afe 100644 --- a/interfaces/kits/js/src/mod_fs/class_file/fs_file.cpp +++ b/interfaces/kits/js/src/mod_fs/class_file/fs_file.cpp @@ -60,10 +60,12 @@ FsResult FsFile::GetPath() const HILOGE("Failed to get file entity"); return FsResult::Error(EINVAL); } + if (fileEntity->uri_.length() != 0) { AppFileService::ModuleFileUri::FileUri fileUri(fileEntity->uri_); return FsResult::Success(fileUri.GetPath()); } + auto [realPathRes, realPath] = RealPathCore(fileEntity->path_); if (realPathRes != ERRNO_NOERR) { HILOGE("Failed to get real path"); @@ -78,15 +80,18 @@ FsResult FsFile::GetName() const HILOGE("Failed to get file entity"); return FsResult::Error(EINVAL); } + if (fileEntity->uri_.length() != 0) { AppFileService::ModuleFileUri::FileUri fileUri(fileEntity->uri_); return FsResult::Success(fileUri.GetName()); } + auto [realPathRes, realPath] = RealPathCore(fileEntity->path_); if (realPathRes != ERRNO_NOERR) { HILOGE("Failed to get real path"); return FsResult::Error(realPathRes); } + string path(static_cast(realPath->ptr)); auto pos = path.find_last_of('/'); if (pos == string::npos) { -- Gitee