1 /* 2 * Copyright (c) 2025 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 #include "statvfs_ffi.h" 17 #include <cinttypes> 18 #include <sys/statvfs.h> 19 #include "macro.h" 20 21 using namespace OHOS::FFI; 22 23 namespace OHOS { 24 namespace CJSystemapi { 25 namespace Statvfs { 26 extern "C" { FfiOHOSStatvfsGetFreeSize(char * path)27RetDataI64 FfiOHOSStatvfsGetFreeSize(char* path) 28 { 29 LOGI("OHOS::CJSystemapi::FfiOHOSStatvfsGetFreeSize"); 30 RetDataI64 ret = { .code = ERR_INVALID_INSTANCE_CODE, .data = 0 }; 31 auto [state, size] = StatvfsImpl::GetFreeSize(path); 32 ret.code = state; 33 ret.data = size; 34 LOGI("OHOS::CJSystemapi::FfiOHOSStatvfsGetFreeSize success"); 35 return ret; 36 } 37 FfiOHOSStatvfsGetTotalSize(char * path)38RetDataI64 FfiOHOSStatvfsGetTotalSize(char* path) 39 { 40 LOGI("OHOS::CJSystemapi::FfiOHOSStatvfsGetTotalSize"); 41 RetDataI64 ret = { .code = ERR_INVALID_INSTANCE_CODE, .data = 0 }; 42 auto [state, size] = StatvfsImpl::GetTotalSize(path); 43 ret.code = state; 44 ret.data = size; 45 LOGI("OHOS::CJSystemapi::FfiOHOSStatvfsGetTotalSize success"); 46 return ret; 47 } 48 } 49 } // namespace Statvfs 50 } // namespace CJSystemapi 51 } // namespace OHOS