1 /* 2 * Copyright (C) 2021-2022 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_MTP_STORAGE_MANAGER 17 #define OHOS_MTP_STORAGE_MANAGER 18 19 #include <string> 20 #include <iostream> 21 #include <memory> 22 #include <vector> 23 24 #include "mtp_constants.h" 25 #include "storage.h" 26 27 namespace OHOS { 28 namespace Media { 29 class MtpStorageManager { 30 public: 31 ~MtpStorageManager() = default; 32 static std::shared_ptr<MtpStorageManager> GetInstance(); 33 int64_t GetTotalSize(const std::string &path = std::string("")); 34 int64_t GetFreeSize(const std::string &path = std::string("")); 35 static std::mutex mutex_; 36 static std::shared_ptr<MtpStorageManager> instance_; 37 void AddStorage(std::shared_ptr<Storage> &storage); 38 void RemoveStorage(std::shared_ptr<Storage> &storage); 39 void ClearStorages(); 40 std::shared_ptr<Storage> GetStorage(uint32_t id); 41 bool HasStorage(uint32_t id = MTP_STORAGE_ID_ALL2); 42 std::vector<std::shared_ptr<Storage>> GetStorages(); 43 std::string GetSystemLanguage(); 44 std::string GetStorageDescription(const uint16_t type); 45 private: 46 MtpStorageManager() = default; 47 std::vector<std::shared_ptr<Storage>> storages; 48 }; 49 } // namespace Media 50 } // namespace OHOS 51 #endif // OHOS_MTP_STORAGE_MANAGER 52