1 /* 2 * Copyright (C) 2024-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_MEDIA_PHOTO_FILE_OPERATIOIN_H 17 #define OHOS_MEDIA_PHOTO_FILE_OPERATIOIN_H 18 19 #include <string> 20 21 #include "rdb_store.h" 22 23 namespace OHOS::Media { 24 class PhotoFileOperation { 25 private: 26 struct PhotoAssetInfo { 27 std::string displayName; 28 std::string filePath; 29 int64_t dateModified{0}; 30 int32_t subtype{0}; 31 std::string videoFilePath; 32 std::string editDataFolder; 33 std::string thumbnailFolder; 34 }; 35 36 public: 37 int32_t CopyPhoto(const std::shared_ptr<NativeRdb::ResultSet> &resultSet, const std::string &targetPath); 38 int32_t CopyThumbnail(const std::shared_ptr<NativeRdb::ResultSet> &resultSet, const std::string &targetPath, 39 int64_t &newAssetId); 40 41 private: 42 std::string GetVideoFilePath(const PhotoAssetInfo &photoInfo); 43 std::string FindVideoFilePath(const PhotoAssetInfo &photoInfo); 44 std::string FindRelativePath(const std::string &filePath); 45 std::string FindPrefixOfEditDataFolder(const std::string &filePath); 46 std::string FindPrefixOfThumbnailFolder(const std::string &filePath); 47 std::string FindPrefixDataFolder(const std::string &filePath, const std::string &dataName); 48 std::string BuildEditDataFolder(const PhotoFileOperation::PhotoAssetInfo &photoInfo); 49 std::string BuildThumbnailFolder(const PhotoFileOperation::PhotoAssetInfo &photoInfo); 50 std::string FindEditDataFolder(const PhotoAssetInfo &photoInfo); 51 std::string FindThumbnailFolder(const PhotoAssetInfo &photoInfo); 52 int32_t CopyPhotoFile(const PhotoAssetInfo &sourcePhotoInfo, const PhotoAssetInfo &targetPhotoInfo); 53 int32_t CopyPhotoRelatedVideoFile(const PhotoAssetInfo &sourcePhotoInfo, const PhotoAssetInfo &targetPhotoInfo); 54 int32_t CopyPhotoRelatedExtraData(const PhotoAssetInfo &sourcePhotoInfo, const PhotoAssetInfo &targetPhotoInfo); 55 int32_t CopyPhotoRelatedThumbnail(const PhotoAssetInfo &sourcePhotoInfo, const PhotoAssetInfo &targetPhotoInfo); 56 int32_t CopyPhotoRelatedData(const PhotoAssetInfo &sourcePhotoInfo, const PhotoAssetInfo &targetPhotoInfo, 57 const std::string &srcFolder, const std::string &targetFolder); 58 int32_t CopyPhoto(const PhotoAssetInfo &sourcePhotoInfo, const PhotoAssetInfo &targetPhotoInfo); 59 int32_t CopyFile(const std::string &srcPath, std::string &targetPath); 60 std::string ToString(const PhotoAssetInfo &photoInfo); 61 int32_t HandleThumbnailAstcData(const std::string &dateTaken, const std::string &oldAssetId, 62 const std::string &newAssetId); 63 }; 64 } // namespace OHOS::Media 65 #endif // FRAMEWORKS_INNERKITSIMPL_MEDIA_LIBRARY_INCLUDE_PHOTO_FILE_H_