• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 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 JS_NATIVE_API_FS_IMPL_H
17 #define JS_NATIVE_API_FS_IMPL_H
18 
19 #include <stdbool.h>
20 #include <stdio.h>
21 #include <sys/stat.h>
22 #include "nativeapi_config.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif
28 #endif /* __cplusplus */
29 
30 typedef struct {
31     char fileName[FILE_NAME_MAX_LEN + 1];
32     off_t fileSize;
33     time_t fileMtime;
34     mode_t fileMode;
35 } FileMetaInfo;
36 
37 int StatImpl(const char* path, struct stat* buf);
38 int DeleteFileImpl(const char* src);
39 int CopyFileImpl(const char* src, const char* dest);
40 int WriteTextFile(const char* fileName, const void* buf, size_t len, bool append);
41 int WriteArrayFile(const char* fileName, const void* buf, size_t len, unsigned int position, bool append);
42 int ReadFileImpl(const char* fileName, void* text, size_t len, unsigned int position, size_t* actualLen);
43 int GetFileListImpl(const char* dirName, FileMetaInfo* fileList, unsigned int listNum);
44 int GetFileNum(const char* dirName);
45 int AccessImpl(const char* fileName);
46 int CreateDirImpl(const char* fileName, bool recursive);
47 int RemoveDirImpl(const char* fileName, bool recursive);
48 
49 #ifdef __cplusplus
50 #if __cplusplus
51 }
52 #endif
53 #endif /* __cplusplus */
54 
55 #endif /* JS_NATIVE_API_FS_IMPL_H */