diff --git a/interfaces/kits/js/src/common/fs_file_filter.h b/interfaces/kits/js/src/common/fs_file_filter.h index f16c178213255dd738a7c62d64419e0d7adf6271..00fcff4d88d765bb4027ac6c5addb84672e13339 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 f16c178213255dd738a7c62d64419e0d7adf6271..0000000000000000000000000000000000000000 --- 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 e4a1969f3e493328008e81f49cd5fafe169c3a13..d03004b21a44fb87a0f6dbb9e19ee27ea5aea9f1 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 ddb5d4eb18b6a4e141b16cffe3bc31ece2f9d7ed..8f6985150e1b7c0eae3fe0d59f5bed97c5d5d051 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); }