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 "stat_instantiator.h" 17 18 namespace OHOS { 19 namespace FileManagement { 20 namespace ModuleFileIO { 21 using namespace std; 22 23 #if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) InstantiateStat(const uv_stat_t & buf,shared_ptr<FileInfo> fileInfo)24FsStat* StatInstantiator::InstantiateStat(const uv_stat_t &buf, shared_ptr<FileInfo> fileInfo) 25 { 26 auto stat = FsStat::Constructor(); 27 if (stat == nullptr) { 28 return nullptr; 29 } 30 31 auto entity = stat->GetStatEntity(); 32 entity->stat_ = buf; 33 entity->fileInfo_ = fileInfo; 34 35 return stat; 36 } 37 #endif 38 InstantiateStat(const uv_stat_t & buf)39FsStat* StatInstantiator::InstantiateStat(const uv_stat_t &buf) 40 { 41 auto stat = FsStat::Constructor(); 42 if (stat == nullptr) { 43 return nullptr; 44 } 45 46 auto entity = stat->GetStatEntity(); 47 entity->stat_ = buf; 48 49 return stat; 50 } 51 } // namespace ModuleFileIO 52 } // namespace FileManagement 53 } // namespace OHOS