10e98b08fSopenharmony_ci/* 20e98b08fSopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd. 30e98b08fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 40e98b08fSopenharmony_ci * you may not use this file except in compliance with the License. 50e98b08fSopenharmony_ci * You may obtain a copy of the License at 60e98b08fSopenharmony_ci * 70e98b08fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 80e98b08fSopenharmony_ci * 90e98b08fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 100e98b08fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 110e98b08fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120e98b08fSopenharmony_ci * See the License for the specific language governing permissions and 130e98b08fSopenharmony_ci * limitations under the License. 140e98b08fSopenharmony_ci */ 150e98b08fSopenharmony_ci 160e98b08fSopenharmony_ci#ifndef JS_NATIVE_API_FS_IMPL_H 170e98b08fSopenharmony_ci#define JS_NATIVE_API_FS_IMPL_H 180e98b08fSopenharmony_ci 190e98b08fSopenharmony_ci#include <stdbool.h> 200e98b08fSopenharmony_ci#include <stdio.h> 210e98b08fSopenharmony_ci#include <sys/stat.h> 220e98b08fSopenharmony_ci#include "nativeapi_config.h" 230e98b08fSopenharmony_ci 240e98b08fSopenharmony_ci#ifdef __cplusplus 250e98b08fSopenharmony_ci#if __cplusplus 260e98b08fSopenharmony_ciextern "C" { 270e98b08fSopenharmony_ci#endif 280e98b08fSopenharmony_ci#endif /* __cplusplus */ 290e98b08fSopenharmony_ci 300e98b08fSopenharmony_citypedef struct { 310e98b08fSopenharmony_ci char fileName[FILE_NAME_MAX_LEN + 1]; 320e98b08fSopenharmony_ci off_t fileSize; 330e98b08fSopenharmony_ci time_t fileMtime; 340e98b08fSopenharmony_ci mode_t fileMode; 350e98b08fSopenharmony_ci} FileMetaInfo; 360e98b08fSopenharmony_ci 370e98b08fSopenharmony_ciint StatImpl(const char* path, struct stat* buf); 380e98b08fSopenharmony_ciint DeleteFileImpl(const char* src); 390e98b08fSopenharmony_ciint CopyFileImpl(const char* src, const char* dest); 400e98b08fSopenharmony_ciint WriteTextFile(const char* fileName, const void* buf, size_t len, bool append); 410e98b08fSopenharmony_ciint WriteArrayFile(const char* fileName, const void* buf, size_t len, unsigned int position, bool append); 420e98b08fSopenharmony_ciint ReadFileImpl(const char* fileName, void* text, size_t len, unsigned int position, size_t* actualLen); 430e98b08fSopenharmony_ciint GetFileListImpl(const char* dirName, FileMetaInfo* fileList, unsigned int listNum); 440e98b08fSopenharmony_ciint GetFileNum(const char* dirName); 450e98b08fSopenharmony_ciint AccessImpl(const char* fileName); 460e98b08fSopenharmony_ciint CreateDirImpl(const char* fileName, bool recursive); 470e98b08fSopenharmony_ciint RemoveDirImpl(const char* fileName, bool recursive); 480e98b08fSopenharmony_ci 490e98b08fSopenharmony_ci#ifdef __cplusplus 500e98b08fSopenharmony_ci#if __cplusplus 510e98b08fSopenharmony_ci} 520e98b08fSopenharmony_ci#endif 530e98b08fSopenharmony_ci#endif /* __cplusplus */ 540e98b08fSopenharmony_ci 550e98b08fSopenharmony_ci#endif /* JS_NATIVE_API_FS_IMPL_H */