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_STORAGE_MANAGER_STORAGE_TOTAL_STATUS_SERVICE_H 17 #define OHOS_STORAGE_MANAGER_STORAGE_TOTAL_STATUS_SERVICE_H 18 19 #include <vector> 20 #include <nocopyable.h> 21 #include <singleton.h> 22 #include <iostream> 23 24 namespace OHOS { 25 namespace StorageManager { 26 static const char *PATH_DEV_BLOCK = "/dev/block"; 27 static const char *PATH_MNT = "/mnt"; 28 static const char *PATH_DATA = "/data"; 29 static const char *PATH_ROOT = "/"; 30 31 enum SizeType { 32 TOTAL, 33 FREE, 34 USED 35 }; 36 class StorageTotalStatusService : public NoCopyable { 37 DECLARE_DELAYED_SINGLETON(StorageTotalStatusService); 38 39 public: 40 int32_t GetSystemSize(int64_t &systemSize); 41 int32_t GetTotalSize(int64_t &totalSize); 42 int32_t GetFreeSize(int64_t &freeSize); 43 private: 44 int32_t GetSizeOfPath(const char *path, int32_t type, int64_t &size); 45 const std::vector<std::string> mountDir = {"/debug_ramdisk", "/patch_hw", 46 "/metadata", "/", "/cust", "/hw_product", "/odm", "/preas", "/vendor", 47 "/vendor/modem/modem_driver", "/data"}; 48 }; 49 } // StorageManager 50 } // OHOS 51 52 #endif // OHOS_STORAGE_MANAGER_STORAGE_TOTAL_STATUS_SERVICE_H 53 54