• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
16import { paramMock } from "../utils"
17
18export function mockFileio() {
19  const StatMock = {
20    dev: '[PC preview] unknow dev',
21    ino: '[PC preview] unknow ino',
22    mode: '[PC preview] unknow mode',
23    nlink: '[PC preview] unknow nlink',
24    uid: '[PC preview] unknow uid',
25    gid: '[PC preview] unknow gid',
26    rdev: '[PC preview] unknow rdev',
27    size: '[PC preview] unknow size',
28    blocks: '[PC preview] unknow blocks',
29    atime: '[PC preview] unknow atime',
30    mtime: '[PC preview] unknow mtime',
31    ctime: '[PC preview] unknow ctime',
32    isBlockDevice: function () {
33      console.warn("Stat.isBlockDevice interface mocked in the Previewer. How this interface works on the Previewer" +
34        " may be different from that on a real device.")
35      return paramMock.paramBooleanMock
36    },
37    isCharacterDevice: function () {
38      console.warn("Stat.isCharacterDevice interface mocked in the Previewer. How this interface works on the" +
39        " Previewer may be different from that on a real device.")
40      return paramMock.paramBooleanMock
41    },
42    isDirectory: function () {
43      console.warn("Stat.isDirectory interface mocked in the Previewer. How this interface works on the Previewer" +
44        " may be different from that on a real device.")
45      return paramMock.paramBooleanMock
46    },
47    isFIFO: function () {
48      console.warn("Stat.isFIFO interface mocked in the Previewer. How this interface works on the Previewer may be" +
49        " different from that on a real device.")
50      return paramMock.paramBooleanMock
51    },
52    isFile: function () {
53      console.warn("Stat.isFile interface mocked in the Previewer. How this interface works on the Previewer may be" +
54        " different from that on a real device.")
55      return paramMock.paramBooleanMock
56    },
57    isSocket: function () {
58      console.warn("Stat.isSocket interface mocked in the Previewer. How this interface works on the Previewer may" +
59        " be different from that on a real device.")
60      return paramMock.paramBooleanMock
61    },
62    isSymbolicLink: function () {
63      console.warn("Stat.isSymbolicLink interface mocked in the Previewer. How this interface works on the Previewer" +
64        " may be different from that on a real device.")
65      return paramMock.paramBooleanMock
66    }
67  };
68  const DirMock = {
69    close: function (...args) {
70      console.warn("Dir.close interface mocked in the Previewer. How this interface works on the Previewer may be" +
71        " different from that on a real device.")
72      const len = args.length
73      if (typeof args[len - 1] === 'function') {
74        args[len - 1].call(this, paramMock.businessErrorMock);
75      } else {
76        return new Promise((resolve, reject) => {
77          resolve();
78        })
79      }
80    },
81    closeSync: function (...args) {
82      console.warn("Dir.closeSync interface mocked in the Previewer. How this interface works on the Previewer may" +
83        " be different from that on a real device.")
84    },
85    read: function (...args) {
86      console.warn("Dir.read interface mocked in the Previewer. How this interface works on the Previewer may be" +
87        " different from that on a real device.")
88      const len = args.length
89      if (typeof args[len - 1] === 'function') {
90        args[len - 1].call(this, paramMock.businessErrorMock, DirentMock);
91      } else {
92        return new Promise((resolve, reject) => {
93          resolve(DirentMock);
94        })
95      }
96    },
97    readSync: function (...args) {
98      console.warn("Dir.readSync interface mocked in the Previewer. How this interface works on the Previewer may be" +
99        " different from that on a real device.")
100      return DirentMock
101    }
102  };
103  const StreamMock = {
104    close: function (...args) {
105      console.warn("Stream.close interface mocked in the Previewer. How this interface works on the Previewer may be" +
106        " different from that on a real device.")
107      const len = args.length
108      if (typeof args[len - 1] === 'function') {
109        args[len - 1].call(this, paramMock.businessErrorMock);
110      } else {
111        return new Promise((resolve, reject) => {
112          resolve();
113        })
114      }
115    },
116    closeSync: function (...args) {
117      console.warn("Stream.closeSync interface mocked in the Previewer. How this interface works on the Previewer may" +
118        " be different from that on a real device.")
119    },
120    flush: function (...args) {
121      console.warn("Stream.flush interface mocked in the Previewer. How this interface works on the Previewer may be" +
122        " different from that on a real device.")
123      const len = args.length
124      if (typeof args[len - 1] === 'function') {
125        args[len - 1].call(this, paramMock.businessErrorMock);
126      } else {
127        return new Promise((resolve, reject) => {
128          resolve();
129        })
130      }
131    },
132    flushSync: function (...args) {
133      console.warn("Stream.flushSync interface mocked in the Previewer. How this interface works on the Previewer may" +
134        " be different from that on a real device.")
135    },
136    read: function (...args) {
137      console.warn("Stream.read interface mocked in the Previewer. How this interface works on the Previewer may be" +
138        " different from that on a real device.")
139      const len = args.length
140      if (typeof args[len - 1] === 'function') {
141        args[len - 1].call(this, paramMock.businessErrorMock, ReadOutMock)
142      } else {
143        return new Promise((resolve, reject) => {
144          resolve(ReadOutMock);
145        })
146      }
147    },
148    readSync: function (...args) {
149      console.warn("Stream.readSync interface mocked in the Previewer. How this interface works on the Previewer may" +
150        " be different from that on a real device.")
151      return paramMock.paramNumberMock;
152    },
153    write: function (...args) {
154      console.warn("Stream.write interface mocked in the Previewer. How this interface works on the Previewer may be" +
155        " different from that on a real device.")
156      const len = args.length
157      if (typeof args[len - 1] === 'function') {
158        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
159      } else {
160        return new Promise((resolve, reject) => {
161          resolve(paramMock.paramNumberMock);
162        })
163      }
164    },
165    writeSync: function (...args) {
166      console.warn("Stream.writeSync interface mocked in the Previewer. How this interface works on the Previewer" +
167        " may be different from that on a real device.")
168      return paramMock.paramNumberMock;
169    }
170  };
171  const DirentMock = {
172    name: "[PC Preview]: unknow name",
173    isBlockDevice: function () {
174      console.warn("Dirent.isBlockDevice interface mocked in the Previewer. How this interface works on the" +
175        " Previewer may be different from that on a real device.")
176      return paramMock.paramBooleanMock
177    },
178    isCharacterDevice: function () {
179      console.warn("Dirent.isCharacterDevice interface mocked in the Previewer. How this interface works on the" +
180        " Previewer may be different from that on a real device.")
181      return paramMock.paramBooleanMock
182    },
183    isDirectory: function () {
184      console.warn("Dirent.isDirectory interface mocked in the Previewer. How this interface works on the Previewer" +
185        " may be different from that on a real device.")
186      return paramMock.paramBooleanMock
187    },
188    isFIFO: function () {
189      console.warn("Dirent.isFIFO interface mocked in the Previewer. How this interface works on the Previewer may" +
190        " be different from that on a real device.")
191      return paramMock.paramBooleanMock
192    },
193    isFile: function () {
194      console.warn("Dirent.isFile interface mocked in the Previewer. How this interface works on the Previewer may" +
195        " be different from that on a real device.")
196      return paramMock.paramBooleanMock
197    },
198    isSocket: function () {
199      console.warn("Dirent.isSocket interface mocked in the Previewer. How this interface works on the Previewer may" +
200        " be different from that on a real device.")
201      return paramMock.paramBooleanMock
202    },
203    isSymbolicLink: function () {
204      console.warn("Dirent.isSymbolicLink interface mocked in the Previewer. How this interface works on the" +
205        " Previewer may be different from that on a real device.")
206      return paramMock.paramBooleanMock
207    }
208  };
209  const ReadOutMock = {
210    bytesRead: "[PC Preview]: unknow bytesRead",
211    offset: "[PC Preview]: unknow offset",
212    buffer: "[PC Preview]: unknow buffer"
213  };
214  const WatcherMock = {
215    stop: function () {
216      console.warn("Watcher.stop interface mocked in the Previewer. How this interface works on the Previewer" +
217        " may be different from that on a real device.")
218    }
219  };
220  const fileioMock = {
221    Dir: DirMock,
222    Dirent: DirentMock,
223    Stat: StatMock,
224    Stream: StreamMock,
225    ReadOut: ReadOutMock,
226    Watcher: WatcherMock,
227    access: function (...args) {
228      console.warn("fileio.access interface mocked in the Previewer. How this interface works on the Previewer may" +
229        " be different from that on a real device.")
230      const len = args.length
231      if (typeof args[len - 1] === 'function') {
232        args[len - 1].call(this, paramMock.businessErrorMock);
233      } else {
234        return new Promise((resolve, reject) => {
235          resolve();
236        })
237      }
238    },
239    accessSync: function (...args) {
240      console.warn("fileio.accessSync interface mocked in the Previewer. How this interface works on the Previewer" +
241        " may be different from that on a real device.")
242    },
243    chmod: function (...args) {
244      console.warn("fileio.chmod interface mocked in the Previewer. How this interface works on the Previewer may" +
245        " be different from that on a real device.")
246      const len = args.length
247      if (typeof args[len - 1] === 'function') {
248        args[len - 1].call(this, paramMock.businessErrorMock);
249      } else {
250        return new Promise((resolve, reject) => {
251          resolve();
252        })
253      }
254    },
255    chmodSync: function (...args) {
256      console.warn("fileio.chmodSync interface mocked in the Previewer. How this interface works on the Previewer" +
257        " may be different from that on a real device.")
258    },
259    chown: function (...args) {
260      console.warn("fileio.chown interface mocked in the Previewer. How this interface works on the Previewer may" +
261        " be different from that on a real device.")
262      const len = args.length
263      if (typeof args[len - 1] === 'function') {
264        args[len - 1].call(this, paramMock.businessErrorMock);
265      } else {
266        return new Promise((resolve, reject) => {
267          resolve();
268        })
269      }
270    },
271    chownSync: function (...args) {
272      console.warn("fileio.chownSync interface mocked in the Previewer. How this interface works on the Previewer" +
273        " may be different from that on a real device.")
274    },
275    close: function (...args) {
276      console.warn("fileio.close interface mocked in the Previewer. How this interface works on the Previewer may" +
277        " be different from that on a real device.")
278      const len = args.length
279      if (typeof args[len - 1] === 'function') {
280        args[len - 1].call(this, paramMock.businessErrorMock);
281      } else {
282        return new Promise((resolve, reject) => {
283          resolve();
284        })
285      }
286    },
287    closeSync: function (...args) {
288      console.warn("fileio.closeSync interface mocked in the Previewer. How this interface works on the Previewer" +
289        " may be different from that on a real device.")
290    },
291    copyFile: function (...args) {
292      console.warn("fileio.copyFile interface mocked in the Previewer. How this interface works on the Previewer may" +
293        " be different from that on a real device.")
294      const len = args.length
295      if (typeof args[len - 1] === 'function') {
296        args[len - 1].call(this, paramMock.businessErrorMock);
297      } else {
298        return new Promise((resolve, reject) => {
299          resolve();
300        })
301      }
302    },
303    copyFileSync: function (...args) {
304      console.warn("fileio.copyFileSync interface mocked in the Previewer. How this interface works on the Previewer" +
305        " may be different from that on a real device.")
306    },
307    createStream: function (...args) {
308      console.warn("fileio.createStream interface mocked in the Previewer. How this interface works on the Previewer may be" +
309        " different from that on a real device.")
310      const len = args.length
311      if (typeof args[len - 1] === 'function') {
312        args[len - 1].call(this, paramMock.businessErrorMock, StreamMock)
313      } else {
314        return new Promise((resolve, reject) => {
315          resolve(StreamMock);
316        })
317      }
318    },
319    createStreamSync: function (...args) {
320      console.warn("fileio.createStreamSync interface mocked in the Previewer. How this interface works on the Previewer" +
321        " may be different from that on a real device.")
322      return StreamMock;
323    },
324    createWatcher: function (...args) {
325      console.warn("fileio.createWatcher interface mocked in the Previewer. How this interface works on the Previewer may be" +
326        " different from that on a real device.")
327      const len = args.length
328      if (typeof args[len - 1] === 'function') {
329        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
330      } else {
331        return WatcherMock;
332      }
333    },
334    fchmod: function (...args) {
335      console.warn("fileio.fchmod interface mocked in the Previewer. How this interface works on the Previewer may" +
336        " be different from that on a real device.")
337      const len = args.length
338      if (typeof args[len - 1] === 'function') {
339        args[len - 1].call(this, paramMock.businessErrorMock);
340      } else {
341        return new Promise((resolve, reject) => {
342          resolve();
343        })
344      }
345    },
346    fchmodSync: function (...args) {
347      console.warn("fileio.fchmodSync interface mocked in the Previewer. How this interface works on the Previewer" +
348        " may be different from that on a real device.")
349    },
350    fchown: function (...args) {
351      console.warn("fileio.fchown interface mocked in the Previewer. How this interface works on the Previewer may" +
352        " be different from that on a real device.")
353      const len = args.length
354      if (typeof args[len - 1] === 'function') {
355        args[len - 1].call(this, paramMock.businessErrorMock);
356      } else {
357        return new Promise((resolve, reject) => {
358          resolve();
359        })
360      }
361    },
362    fchownSync: function (...args) {
363      console.warn("fileio.fchownSync interface mocked in the Previewer. How this interface works on the Previewer" +
364        " may be different from that on a real device.")
365    },
366    fdatasync: function (...args) {
367      console.warn("fileio.fdatasync interface mocked in the Previewer. How this interface works on the Previewer may" +
368        " be different from that on a real device.")
369      const len = args.length
370      if (typeof args[len - 1] === 'function') {
371        args[len - 1].call(this, paramMock.businessErrorMock);
372      } else {
373        return new Promise((resolve, reject) => {
374          resolve();
375        })
376      }
377    },
378    fdatasyncSync: function (...args) {
379      console.warn("fileio.fdatasyncSync interface mocked in the Previewer. How this interface works on the Previewer" +
380        " may be different from that on a real device.")
381    },
382    fdopenStream: function (...args) {
383      console.warn("fileio.fdopenStream interface mocked in the Previewer. How this interface works on the Previewer may be" +
384        " different from that on a real device.")
385      const len = args.length
386      if (typeof args[len - 1] === 'function') {
387        args[len - 1].call(this, paramMock.businessErrorMock, StreamMock)
388      } else {
389        return new Promise((resolve, reject) => {
390          resolve(StreamMock);
391        })
392      }
393    },
394    fdopenStreamSync: function (...args) {
395      console.warn("fileio.fdopenStreamSync interface mocked in the Previewer. How this interface works on the Previewer" +
396        " may be different from that on a real device.")
397      return StreamMock;
398    },
399    fstat: function (...args) {
400      console.warn("fileio.fstat interface mocked in the Previewer. How this interface works on the Previewer may be" +
401        " different from that on a real device.")
402      const len = args.length
403      if (typeof args[len - 1] === 'function') {
404        args[len - 1].call(this, paramMock.businessErrorMock, StatMock)
405      } else {
406        return new Promise((resolve, reject) => {
407          resolve(StatMock);
408        })
409      }
410    },
411    fstatSync: function (...args) {
412      console.warn("fileio.fstatSync interface mocked in the Previewer. How this interface works on the Previewer" +
413        " may be different from that on a real device.")
414      return StatMock;
415    },
416    fsync: function (...args) {
417      console.warn("fileio.fsync interface mocked in the Previewer. How this interface works on the Previewer may" +
418        " be different from that on a real device.")
419      const len = args.length
420      if (typeof args[len - 1] === 'function') {
421        args[len - 1].call(this, paramMock.businessErrorMock);
422      } else {
423        return new Promise((resolve, reject) => {
424          resolve();
425        })
426      }
427    },
428    fsyncSync: function (...args) {
429      console.warn("fileio.fsyncSync interface mocked in the Previewer. How this interface works on the Previewer" +
430        " may be different from that on a real device.")
431    },
432    ftruncate: function (...args) {
433      console.warn("fileio.ftruncate interface mocked in the Previewer. How this interface works on the Previewer may" +
434        " be different from that on a real device.")
435      const len = args.length
436      if (typeof args[len - 1] === 'function') {
437        args[len - 1].call(this, paramMock.businessErrorMock);
438      } else {
439        return new Promise((resolve, reject) => {
440          resolve();
441        })
442      }
443    },
444    ftruncateSync: function (...args) {
445      console.warn("fileio.ftruncateSync interface mocked in the Previewer. How this interface works on the Previewer" +
446        " may be different from that on a real device.")
447    },
448    hash: function (...args) {
449      console.warn("fileio.hash interface mocked in the Previewer. How this interface works on the Previewer may be" +
450        " different from that on a real device.")
451      const len = args.length
452      if (typeof args[len - 1] === 'function') {
453        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
454      } else {
455        return new Promise((resolve, reject) => {
456          resolve(paramMock.paramStringMock);
457        })
458      }
459    },
460    lchown: function (...args) {
461      console.warn("fileio.lchown interface mocked in the Previewer. How this interface works on the Previewer may" +
462        " be different from that on a real device.")
463      const len = args.length
464      if (typeof args[len - 1] === 'function') {
465        args[len - 1].call(this, paramMock.businessErrorMock);
466      } else {
467        return new Promise((resolve, reject) => {
468          resolve();
469        })
470      }
471    },
472    lchownSync: function (...args) {
473      console.warn("fileio.lchownSync interface mocked in the Previewer. How this interface works on the Previewer" +
474        " may be different from that on a real device.")
475    },
476    lstat: function (...args) {
477      console.warn("fileio.lstat interface mocked in the Previewer. How this interface works on the Previewer may be" +
478        " different from that on a real device.")
479      const len = args.length
480      if (typeof args[len - 1] === 'function') {
481        args[len - 1].call(this, paramMock.businessErrorMock, StatMock)
482      } else {
483        return new Promise((resolve, reject) => {
484          resolve(StatMock);
485        })
486      }
487    },
488    lstatSync: function (...args) {
489      console.warn("fileio.lstatSync interface mocked in the Previewer. How this interface works on the Previewer" +
490        " may be different from that on a real device.")
491      return StatMock;
492    },
493    mkdir: function (...args) {
494      console.warn("fileio.mkdir interface mocked in the Previewer. How this interface works on the Previewer may be" +
495        " different from that on a real device.")
496      const len = args.length
497      if (typeof args[len - 1] === 'function') {
498        args[len - 1].call(this, paramMock.businessErrorMock);
499      } else {
500        return new Promise((resolve, reject) => {
501          resolve();
502        })
503      }
504    },
505    mkdirSync: function (...args) {
506      console.warn("fileio.mkdirSync interface mocked in the Previewer. How this interface works on the Previewer" +
507        " may be different from that on a real device.")
508    },
509    mkdtemp: function (...args) {
510      console.warn("fileio.mkdtemp interface mocked in the Previewer. How this interface works on the Previewer may be" +
511        " different from that on a real device.")
512      const len = args.length
513      if (typeof args[len - 1] === 'function') {
514        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock)
515      } else {
516        return new Promise((resolve, reject) => {
517          resolve(paramMock.paramStringMock);
518        })
519      }
520    },
521    mkdtempSync: function (...args) {
522      console.warn("fileio.mkdtempSync interface mocked in the Previewer. How this interface works on the Previewer" +
523        " may be different from that on a real device.")
524      return paramMock.paramStringMock;
525    },
526    open: function (...args) {
527      console.warn("fileio.open interface mocked in the Previewer. How this interface works on the Previewer may be" +
528        " different from that on a real device.")
529      const len = args.length
530      if (typeof args[len - 1] === 'function') {
531        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
532      } else {
533        return new Promise((resolve, reject) => {
534          resolve(paramMock.paramNumberMock);
535        })
536      }
537    },
538    openSync: function (...args) {
539      console.warn("fileio.openSync interface mocked in the Previewer. How this interface works on the Previewer may" +
540        " be different from that on a real device.")
541      return paramMock.paramNumberMock;
542    },
543    opendir: function (...args) {
544      console.warn("fileio.opendir interface mocked in the Previewer. How this interface works on the Previewer may" +
545        " be different from that on a real device.")
546      const len = args.length
547      if (typeof args[len - 1] === 'function') {
548        args[len - 1].call(this, paramMock.businessErrorMock, DirMock)
549      } else {
550        return new Promise((resolve, reject) => {
551          resolve(DirMock);
552        })
553      }
554    },
555    opendirSync: function (...args) {
556      console.warn("fileio.opendirSync interface mocked in the Previewer. How this interface works on the Previewer" +
557        " may be different from that on a real device.")
558      return DirMock;
559    },
560    read: function (...args) {
561      console.warn("fileio.read interface mocked in the Previewer. How this interface works on the Previewer may be" +
562        " different from that on a real device.")
563      const len = args.length
564      if (typeof args[len - 1] === 'function') {
565        args[len - 1].call(this, paramMock.businessErrorMock, ReadOutMock)
566      } else {
567        return new Promise((resolve, reject) => {
568          resolve(ReadOutMock);
569        })
570      }
571    },
572    readSync: function (...args) {
573      console.warn("fileio.readSync interface mocked in the Previewer. How this interface works on the Previewer may" +
574        " be different from that on a real device.")
575      return paramMock.paramNumberMock;
576    },
577    readText: function (...args) {
578      console.warn("fileio.readText interface mocked in the Previewer. How this interface works on the Previewer may" +
579        " be different from that on a real device.")
580      const len = args.length
581      if (typeof args[len - 1] === 'function') {
582        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
583      } else {
584        return new Promise((resolve, reject) => {
585          resolve(paramMock.paramStringMock);
586        })
587      }
588    },
589    readTextSync: function (...args) {
590      console.warn("fileio.readTextSync interface mocked in the Previewer. How this interface works on the Previewer" +
591        " may be different from that on a real device.")
592      return paramMock.paramStringMock;
593    },
594    rename: function (...args) {
595      console.warn("fileio.rename interface mocked in the Previewer. How this interface works on the Previewer may" +
596        " be different from that on a real device.")
597      const len = args.length
598      if (typeof args[len - 1] === 'function') {
599        args[len - 1].call(this, paramMock.businessErrorMock);
600      } else {
601        return new Promise((resolve, reject) => {
602          resolve();
603        })
604      }
605    },
606    renameSync: function (...args) {
607      console.warn("fileio.renameSync interface mocked in the Previewer. How this interface works on the Previewer" +
608        " may be different from that on a real device.")
609    },
610    rmdir: function (...args) {
611      console.warn("fileio.rmdir interface mocked in the Previewer. How this interface works on the Previewer may" +
612        " be different from that on a real device.")
613      const len = args.length
614      if (typeof args[len - 1] === 'function') {
615        args[len - 1].call(this, paramMock.businessErrorMock);
616      } else {
617        return new Promise((resolve, reject) => {
618          resolve();
619        })
620      }
621    },
622    rmdirSync: function (...args) {
623      console.warn("fileio.rmdirSync interface mocked in the Previewer. How this interface works on the Previewer" +
624        " may be different from that on a real device.")
625    },
626    stat: function (...args) {
627      console.warn("fileio.stat interface mocked in the Previewer. How this interface works on the Previewer may be" +
628        " different from that on a real device.")
629      const len = args.length
630      if (typeof args[len - 1] === 'function') {
631        args[len - 1].call(this, paramMock.businessErrorMock, StatMock)
632      } else {
633        return new Promise((resolve, reject) => {
634          resolve(StatMock);
635        })
636      }
637    },
638    statSync: function (...args) {
639      console.warn("fileio.statSync interface mocked in the Previewer. How this interface works on the Previewer may" +
640        " be different from that on a real device.")
641      return StatMock;
642    },
643    symlink: function (...args) {
644      console.warn("fileio.symlink interface mocked in the Previewer. How this interface works on the Previewer may" +
645        " be different from that on a real device.")
646      const len = args.length
647      if (typeof args[len - 1] === 'function') {
648        args[len - 1].call(this, paramMock.businessErrorMock);
649      } else {
650        return new Promise((resolve, reject) => {
651          resolve();
652        })
653      }
654    },
655    symlinkSync: function (...args) {
656      console.warn("fileio.symlinkSync interface mocked in the Previewer. How this interface works on the Previewer" +
657        " may be different from that on a real device.")
658    },
659    truncate: function (...args) {
660      console.warn("fileio.truncate interface mocked in the Previewer. How this interface works on the Previewer may" +
661        " be different from that on a real device.")
662      const len = args.length
663      if (typeof args[len - 1] === 'function') {
664        args[len - 1].call(this, paramMock.businessErrorMock);
665      } else {
666        return new Promise((resolve, reject) => {
667          resolve();
668        })
669      }
670    },
671    truncateSync: function (...args) {
672      console.warn("fileio.truncateSync interface mocked in the Previewer. How this interface works on the Previewer" +
673        " may be different from that on a real device.")
674    },
675    unlink: function (...args) {
676      console.warn("fileio.unlink interface mocked in the Previewer. How this interface works on the Previewer may" +
677        " be different from that on a real device.")
678      const len = args.length
679      if (typeof args[len - 1] === 'function') {
680        args[len - 1].call(this, paramMock.businessErrorMock);
681      } else {
682        return new Promise((resolve, reject) => {
683          resolve();
684        })
685      }
686    },
687    unlinkSync: function (...args) {
688      console.warn("fileio.unlinkSync interface mocked in the Previewer. How this interface works on the Previewer" +
689        " may be different from that on a real device.")
690    },
691    write: function (...args) {
692      console.warn("fileio.write interface mocked in the Previewer. How this interface works on the Previewer may be" +
693        " different from that on a real device.")
694      const len = args.length
695      if (typeof args[len - 1] === 'function') {
696        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock)
697      } else {
698        return new Promise((resolve, reject) => {
699          resolve(paramMock.paramNumberMock);
700        })
701      }
702    },
703    writeSync: function (...args) {
704      console.warn("fileio.writeSync interface mocked in the Previewer. How this interface works on the Previewer" +
705        " may be different from that on a real device.")
706      return paramMock.paramNumberMock;
707    }
708  }
709  return fileioMock
710}