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 "uv_fs_mock.h"
17
18 using namespace OHOS::FileManagement::ModuleFileIO;
19
uv_fs_read(uv_loop_t * loop,uv_fs_t * req,uv_file file,const uv_buf_t bufs[],unsigned int nbufs,int64_t off,uv_fs_cb cb)20 int uv_fs_read(uv_loop_t *loop, uv_fs_t *req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t off,
21 uv_fs_cb cb)
22 {
23 return Uvfs::ins->uv_fs_read(loop, req, file, bufs, nbufs, off, cb);
24 }
25
uv_fs_readlink(uv_loop_t * loop,uv_fs_t * req,const char * path,uv_fs_cb cb)26 int uv_fs_readlink(uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
27 {
28 return Uvfs::ins->uv_fs_readlink(loop, req, path, cb);
29 }
30
uv_fs_stat(uv_loop_t * loop,uv_fs_t * req,const char * path,uv_fs_cb cb)31 int uv_fs_stat(uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
32 {
33 return Uvfs::ins->uv_fs_stat(loop, req, path, cb);
34 }
35
uv_fs_utime(uv_loop_t * loop,uv_fs_t * req,const char * path,double atime,double mtime,uv_fs_cb cb)36 int uv_fs_utime(uv_loop_t *loop, uv_fs_t *req, const char *path, double atime, double mtime, uv_fs_cb cb)
37 {
38 return Uvfs::ins->uv_fs_utime(loop, req, path, atime, mtime, cb);
39 }
40
uv_fs_scandir(uv_loop_t * loop,uv_fs_t * req,const char * path,int flags,uv_fs_cb cb)41 int uv_fs_scandir(uv_loop_t *loop, uv_fs_t *req, const char *path, int flags, uv_fs_cb cb)
42 {
43 return Uvfs::ins->uv_fs_scandir(loop, req, path, flags, cb);
44 }
45
uv_fs_scandir_next(uv_fs_t * req,uv_dirent_t * ent)46 int uv_fs_scandir_next(uv_fs_t *req, uv_dirent_t *ent)
47 {
48 return Uvfs::ins->uv_fs_scandir_next(req, ent);
49 }
50
uv_fs_rmdir(uv_loop_t * loop,uv_fs_t * req,const char * path,uv_fs_cb cb)51 int uv_fs_rmdir(uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
52 {
53 return Uvfs::ins->uv_fs_rmdir(loop, req, path, cb);
54 }
55
uv_fs_symlink(uv_loop_t * loop,uv_fs_t * req,const char * path,const char * newPath,int flags,uv_fs_cb cb)56 int uv_fs_symlink(uv_loop_t *loop, uv_fs_t *req, const char *path, const char *newPath, int flags, uv_fs_cb cb)
57 {
58 return Uvfs::ins->uv_fs_symlink(loop, req, path, newPath, flags, cb);
59 }
60
uv_fs_open(uv_loop_t * loop,uv_fs_t * req,const char * path,int flags,int mode,uv_fs_cb cb)61 int uv_fs_open(uv_loop_t *loop, uv_fs_t *req, const char *path, int flags, int mode, uv_fs_cb cb)
62 {
63 return Uvfs::ins->uv_fs_open(loop, req, path, flags, mode, cb);
64 }
65
uv_fs_ftruncate(uv_loop_t * loop,uv_fs_t * req,uv_file fd,int64_t offset,uv_fs_cb cb)66 int uv_fs_ftruncate(uv_loop_t *loop, uv_fs_t *req, uv_file fd, int64_t offset, uv_fs_cb cb)
67 {
68 return Uvfs::ins->uv_fs_ftruncate(loop, req, fd, offset, cb);
69 }
70
uv_fs_write(uv_loop_t * loop,uv_fs_t * req,uv_file fd,const uv_buf_t bufs[],unsigned int nbufs,int64_t offset,uv_fs_cb cb)71 int uv_fs_write(uv_loop_t *loop, uv_fs_t *req, uv_file fd, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset,
72 uv_fs_cb cb)
73 {
74 return Uvfs::ins->uv_fs_write(loop, req, fd, bufs, nbufs, offset, cb);
75 }
76
uv_fs_realpath(uv_loop_t * loop,uv_fs_t * req,const char * path,uv_fs_cb cb)77 int uv_fs_realpath(uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
78 {
79 return Uvfs::ins->uv_fs_realpath(loop, req, path, cb);
80 }
81
uv_fs_close(uv_loop_t * loop,uv_fs_t * req,uv_file file,uv_fs_cb cb)82 int uv_fs_close(uv_loop_t *loop, uv_fs_t *req, uv_file file, uv_fs_cb cb)
83 {
84 return Uvfs::ins->uv_fs_close(loop, req, file, cb);
85 }
86
uv_fs_fdatasync(uv_loop_t * loop,uv_fs_t * req,uv_file file,uv_fs_cb cb)87 int uv_fs_fdatasync(uv_loop_t *loop, uv_fs_t *req, uv_file file, uv_fs_cb cb)
88 {
89 return Uvfs::ins->uv_fs_fdatasync(loop, req, file, cb);
90 }
91
uv_fs_mkdir(uv_loop_t * loop,uv_fs_t * req,const char * path,int mode,uv_fs_cb cb)92 int uv_fs_mkdir(uv_loop_t *loop, uv_fs_t *req, const char *path, int mode, uv_fs_cb cb)
93 {
94 return Uvfs::ins->uv_fs_mkdir(loop, req, path, mode, cb);
95 }
96
uv_fs_access(uv_loop_t * loop,uv_fs_t * req,const char * path,int flags,uv_fs_cb cb)97 int uv_fs_access(uv_loop_t *loop, uv_fs_t *req, const char *path, int flags, uv_fs_cb cb)
98 {
99 return Uvfs::ins->uv_fs_access(loop, req, path, flags, cb);
100 }
101
uv_fs_mkdtemp(uv_loop_t * loop,uv_fs_t * req,const char * tpl,uv_fs_cb cb)102 int uv_fs_mkdtemp(uv_loop_t *loop, uv_fs_t *req, const char *tpl, uv_fs_cb cb)
103 {
104 return Uvfs::ins->uv_fs_mkdtemp(loop, req, tpl, cb);
105 }
106
uv_fs_unlink(uv_loop_t * loop,uv_fs_t * req,const char * path,uv_fs_cb cb)107 int uv_fs_unlink(uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
108 {
109 return Uvfs::ins->uv_fs_unlink(loop, req, path, cb);
110 }
111
uv_fs_req_cleanup(uv_fs_t * req)112 void uv_fs_req_cleanup(uv_fs_t *req)
113 {
114 return;
115 }
116
uv_fs_rename(uv_loop_t * loop,uv_fs_t * req,const char * path,const char * newPath,uv_fs_cb cb)117 int uv_fs_rename(uv_loop_t *loop, uv_fs_t *req, const char *path, const char *newPath, uv_fs_cb cb)
118 {
119 return Uvfs::ins->uv_fs_rename(loop, req, path, newPath, cb);
120 }
121
uv_fs_fsync(uv_loop_t * loop,uv_fs_t * req,uv_file file,uv_fs_cb cb)122 int uv_fs_fsync(uv_loop_t *loop, uv_fs_t *req, uv_file file, uv_fs_cb cb)
123 {
124 return Uvfs::ins->uv_fs_fsync(loop, req, file, cb);
125 }
126
uv_fs_sendfile(uv_loop_t * loop,uv_fs_t * req,uv_file outFd,uv_file inFd,int64_t off,size_t len,uv_fs_cb cb)127 int uv_fs_sendfile(uv_loop_t *loop, uv_fs_t *req, uv_file outFd, uv_file inFd, int64_t off, size_t len, uv_fs_cb cb)
128 {
129 return Uvfs::ins->uv_fs_sendfile(loop, req, outFd, inFd, off, len, cb);
130 }
131
uv_fs_lstat(uv_loop_t * loop,uv_fs_t * req,const char * path,uv_fs_cb cb)132 int uv_fs_lstat(uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
133 {
134 return Uvfs::ins->uv_fs_lstat(loop, req, path, cb);
135 }
136