From d723c0e64c27b9e5cf13158f120dd9887053cea0 Mon Sep 17 00:00:00 2001 From: zxl <1554188414@qq.com> Date: Fri, 1 Aug 2025 18:50:44 +0800 Subject: [PATCH] =?UTF-8?q?create=5Frandomaccessfile=20close=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zxl <1554188414@qq.com> --- .../kits/js/src/common/fs_file_filter.h | 2 +- interfaces/kits/js/src/common/fs_filefiter.h | 117 ------------------ .../create_randomaccessfile_core.cpp | 1 - .../js/src/mod_fs/properties/dup_core.cpp | 2 +- 4 files changed, 2 insertions(+), 120 deletions(-) delete mode 100644 interfaces/kits/js/src/common/fs_filefiter.h diff --git a/interfaces/kits/js/src/common/fs_file_filter.h b/interfaces/kits/js/src/common/fs_file_filter.h index f16c17821..00fcff4d8 100644 --- a/interfaces/kits/js/src/common/fs_file_filter.h +++ b/interfaces/kits/js/src/common/fs_file_filter.h @@ -71,7 +71,7 @@ public: return fileSizeOver_; } - void SetLastModifiedAfter(const std::optional &lastModifiedAfter) + void SetLastModifiedAfter(const std::optional &lastModifiedAfter) { lastModifiedAfter_ = std::move(lastModifiedAfter); } diff --git a/interfaces/kits/js/src/common/fs_filefiter.h b/interfaces/kits/js/src/common/fs_filefiter.h deleted file mode 100644 index f16c17821..000000000 --- a/interfaces/kits/js/src/common/fs_filefiter.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef FS_FILE_FILTER_H -#define FS_FILE_FILTER_H - -#include -#include -#include - -namespace OHOS { -namespace FileManagement { -namespace ModuleFileIO { - -class FsFileFilter { -public: - FsFileFilter() = default; - ~FsFileFilter() = default; - - FsFileFilter(const FsFileFilter &filter) = default; - FsFileFilter &operator=(const FsFileFilter &filter) = default; - - void SetSuffix(const std::optional> &suffix) - { - suffix_ = std::move(suffix); - } - - const std::optional> &GetSuffix() const - { - return suffix_; - } - - void SetDisplayName(const std::optional> &displayName) - { - displayName_ = std::move(displayName); - } - - const std::optional> &GetDisplayName() const - { - return displayName_; - } - - void SetMimeType(const std::optional> &mimeType) - { - mimeType_ = std::move(mimeType); - } - - const std::optional> &GetMimeType() const - { - return mimeType_; - } - - void SetFileSizeOver(const std::optional &fileSizeOver) - { - fileSizeOver_ = std::move(fileSizeOver); - } - - const std::optional &GetFileSizeOver() const - { - return fileSizeOver_; - } - - void SetLastModifiedAfter(const std::optional &lastModifiedAfter) - { - lastModifiedAfter_ = std::move(lastModifiedAfter); - } - - const std::optional &GetLastModifiedAfter() const - { - return lastModifiedAfter_; - } - - void SetExcludeMedia(const bool &excludeMedia) - { - excludeMedia_ = excludeMedia; - } - - bool GetExcludeMedia() const - { - return excludeMedia_; - } - - void SetHasFilter(const bool &hasFilter) - { - hasFilter_ = hasFilter; - } - - bool GetHasFilter() const - { - return hasFilter_; - } - -private: - std::optional> suffix_ = std::nullopt; - std::optional> displayName_ = std::nullopt; - std::optional> mimeType_ = std::nullopt; - std::optional fileSizeOver_ = std::nullopt; - std::optional lastModifiedAfter_ = std::nullopt; - bool excludeMedia_ = false; - bool hasFilter_ = false; -}; - -} // namespace ModuleFileIO -} // namespace FileManagement -} // namespace OHOS -#endif // FS_FILE_FILTER_H \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/create_randomaccessfile_core.cpp b/interfaces/kits/js/src/mod_fs/properties/create_randomaccessfile_core.cpp index e4a1969f3..d03004b21 100644 --- a/interfaces/kits/js/src/mod_fs/properties/create_randomaccessfile_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/create_randomaccessfile_core.cpp @@ -34,7 +34,6 @@ static tuple ParseStringToFileInfo(const string &path) auto fdg = CreateUniquePtr(sfd, false); if (fdg == nullptr) { HILOGE("Failed to request heap memory."); - close(sfd); return { false, FileInfo { false, nullptr, nullptr }, ENOMEM}; } size_t length = path.length() + 1; diff --git a/interfaces/kits/js/src/mod_fs/properties/dup_core.cpp b/interfaces/kits/js/src/mod_fs/properties/dup_core.cpp index ddb5d4eb1..8f6985150 100644 --- a/interfaces/kits/js/src/mod_fs/properties/dup_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/dup_core.cpp @@ -57,7 +57,7 @@ FsResult DupCore::DoDup(const int32_t &fd) } string path = "/proc/self/fd/" + to_string(dstFd); int ret = uv_fs_readlink(nullptr, readLinkReq.get(), path.c_str(), nullptr); - if (ret < 0) { + if (ret < 0 || readLinkReq->ptr != nullptr) { HILOGE("Failed to readlink fd, ret: %{public}d", ret); return FsResult::Error(ret); } -- Gitee