@tarojs/plugin-platform-harmony-cpp 4.1.0 → 4.1.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/dist/index.js +1237 -0
  2. package/dist/runtime/apis/apis.ts +20 -0
  3. package/dist/runtime/apis/base/crypto.ts +4 -0
  4. package/dist/runtime/apis/base/debug.ts +5 -0
  5. package/dist/runtime/apis/base/index.ts +13 -0
  6. package/dist/runtime/apis/base/performance.ts +8 -0
  7. package/dist/runtime/apis/base/system.ts +181 -0
  8. package/dist/runtime/apis/base/update.ts +5 -0
  9. package/dist/runtime/apis/base/weapp/app-event.ts +75 -0
  10. package/dist/runtime/apis/base/weapp/life-cycle.ts +21 -0
  11. package/dist/runtime/apis/canvas/index.ts +27 -0
  12. package/dist/runtime/apis/data-analysis/index.ts +6 -0
  13. package/dist/runtime/apis/device/accelerometer.ts +79 -0
  14. package/dist/runtime/apis/device/accessibility.ts +4 -0
  15. package/dist/runtime/apis/device/battery.ts +24 -0
  16. package/dist/runtime/apis/device/bluetooth-ble.ts +19 -0
  17. package/dist/runtime/apis/device/bluetooth-peripheral.ts +6 -0
  18. package/dist/runtime/apis/device/bluetooth.ts +16 -0
  19. package/dist/runtime/apis/device/calendar.ts +5 -0
  20. package/dist/runtime/apis/device/clipboard.ts +85 -0
  21. package/dist/runtime/apis/device/compass.ts +21 -0
  22. package/dist/runtime/apis/device/contact.ts +5 -0
  23. package/dist/runtime/apis/device/crypto.ts +4 -0
  24. package/dist/runtime/apis/device/gyroscope.ts +77 -0
  25. package/dist/runtime/apis/device/iBeacon.ts +10 -0
  26. package/dist/runtime/apis/device/index.ts +24 -0
  27. package/dist/runtime/apis/device/keyboard.ts +63 -0
  28. package/dist/runtime/apis/device/memory.ts +11 -0
  29. package/dist/runtime/apis/device/motion.ts +6 -0
  30. package/dist/runtime/apis/device/network.ts +123 -0
  31. package/dist/runtime/apis/device/nfc.ts +10 -0
  32. package/dist/runtime/apis/device/phone.ts +44 -0
  33. package/dist/runtime/apis/device/scan.ts +4 -0
  34. package/dist/runtime/apis/device/screen.ts +80 -0
  35. package/dist/runtime/apis/device/sms.ts +4 -0
  36. package/dist/runtime/apis/device/vibrate.ts +32 -0
  37. package/dist/runtime/apis/device/wifi.ts +15 -0
  38. package/dist/runtime/apis/ext/index.ts +5 -0
  39. package/dist/runtime/apis/files/index.ts +136 -0
  40. package/dist/runtime/apis/files/manager.ts +942 -0
  41. package/dist/runtime/apis/framework/index.ts +48 -0
  42. package/dist/runtime/apis/harmony/task-pool.ts +39 -0
  43. package/dist/runtime/apis/index.ts +61 -0
  44. package/dist/runtime/apis/location/index.ts +133 -0
  45. package/dist/runtime/apis/media/EditorContext.ts +32 -0
  46. package/dist/runtime/apis/media/audio/index.ts +36 -0
  47. package/dist/runtime/apis/media/background-audio/index.ts +16 -0
  48. package/dist/runtime/apis/media/camera.ts +16 -0
  49. package/dist/runtime/apis/media/common.ts +58 -0
  50. package/dist/runtime/apis/media/image/index.ts +291 -0
  51. package/dist/runtime/apis/media/index.ts +13 -0
  52. package/dist/runtime/apis/media/live.ts +5 -0
  53. package/dist/runtime/apis/media/map.ts +4 -0
  54. package/dist/runtime/apis/media/media-recorder.ts +4 -0
  55. package/dist/runtime/apis/media/recorder.ts +6 -0
  56. package/dist/runtime/apis/media/video/VideoContext.ts +67 -0
  57. package/dist/runtime/apis/media/video/index.ts +45 -0
  58. package/dist/runtime/apis/media/video-decoder.ts +4 -0
  59. package/dist/runtime/apis/media/video-processing.ts +4 -0
  60. package/dist/runtime/apis/media/voip.ts +19 -0
  61. package/dist/runtime/apis/navigate/index.ts +8 -0
  62. package/dist/runtime/apis/network/downloadFile.ts +85 -0
  63. package/dist/runtime/apis/network/index.ts +7 -0
  64. package/dist/runtime/apis/network/mdns.ts +13 -0
  65. package/dist/runtime/apis/network/request.ts +140 -0
  66. package/dist/runtime/apis/network/tcp.ts +4 -0
  67. package/dist/runtime/apis/network/udp.ts +4 -0
  68. package/dist/runtime/apis/network/uploadFile.ts +105 -0
  69. package/dist/runtime/apis/network/webSocket.ts +126 -0
  70. package/dist/runtime/apis/open-api/account.ts +4 -0
  71. package/dist/runtime/apis/open-api/address.ts +4 -0
  72. package/dist/runtime/apis/open-api/authorize.ts +5 -0
  73. package/dist/runtime/apis/open-api/card.ts +5 -0
  74. package/dist/runtime/apis/open-api/channels-live.ts +11 -0
  75. package/dist/runtime/apis/open-api/customer-service.ts +4 -0
  76. package/dist/runtime/apis/open-api/device-voip.ts +5 -0
  77. package/dist/runtime/apis/open-api/facial.ts +7 -0
  78. package/dist/runtime/apis/open-api/favorites.ts +5 -0
  79. package/dist/runtime/apis/open-api/group.ts +4 -0
  80. package/dist/runtime/apis/open-api/index.ts +21 -0
  81. package/dist/runtime/apis/open-api/invoice.ts +5 -0
  82. package/dist/runtime/apis/open-api/license-plate.ts +4 -0
  83. package/dist/runtime/apis/open-api/login.ts +6 -0
  84. package/dist/runtime/apis/open-api/my-miniprogram.ts +4 -0
  85. package/dist/runtime/apis/open-api/privacy.ts +7 -0
  86. package/dist/runtime/apis/open-api/red-package.ts +4 -0
  87. package/dist/runtime/apis/open-api/settings.ts +5 -0
  88. package/dist/runtime/apis/open-api/soter.ts +6 -0
  89. package/dist/runtime/apis/open-api/subscribe-message.ts +6 -0
  90. package/dist/runtime/apis/open-api/user-info.ts +70 -0
  91. package/dist/runtime/apis/open-api/werun.ts +5 -0
  92. package/dist/runtime/apis/payment/index.ts +6 -0
  93. package/dist/runtime/apis/route/index.ts +88 -0
  94. package/dist/runtime/apis/share/index.ts +33 -0
  95. package/dist/runtime/apis/storage/background-fetch.ts +7 -0
  96. package/dist/runtime/apis/storage/cache-manager.ts +4 -0
  97. package/dist/runtime/apis/storage/index.ts +203 -0
  98. package/dist/runtime/apis/ui/animation/animation.ts +264 -0
  99. package/dist/runtime/apis/ui/animation/index.ts +7 -0
  100. package/dist/runtime/apis/ui/background.ts +20 -0
  101. package/dist/runtime/apis/ui/custom-component.ts +1 -0
  102. package/dist/runtime/apis/ui/fonts.ts +4 -0
  103. package/dist/runtime/apis/ui/index.ts +12 -0
  104. package/dist/runtime/apis/ui/interaction/index.ts +198 -0
  105. package/dist/runtime/apis/ui/menu.ts +4 -0
  106. package/dist/runtime/apis/ui/navigation-bar/index.ts +72 -0
  107. package/dist/runtime/apis/ui/pull-down-refresh.ts +47 -0
  108. package/dist/runtime/apis/ui/scroll/index.ts +82 -0
  109. package/dist/runtime/apis/ui/sticky.ts +4 -0
  110. package/dist/runtime/apis/ui/tab-bar.ts +144 -0
  111. package/dist/runtime/apis/ui/window.ts +20 -0
  112. package/dist/runtime/apis/utils/constant.ts +1 -0
  113. package/dist/runtime/apis/utils/handler.ts +117 -0
  114. package/dist/runtime/apis/utils/index.ts +105 -0
  115. package/dist/runtime/apis/utils/permissions.ts +6 -0
  116. package/dist/runtime/apis/utils/types.ts +12 -0
  117. package/dist/runtime/apis/utils/unit.ts +104 -0
  118. package/dist/runtime/apis/utils/validate.ts +87 -0
  119. package/dist/runtime/apis/worker/index.ts +4 -0
  120. package/dist/runtime/apis/wxml/index.ts +17 -0
  121. package/dist/runtime/apis/wxml/intersectionObserver.ts +100 -0
  122. package/dist/runtime/apis/wxml/nodesRef.ts +58 -0
  123. package/dist/runtime/apis/wxml/selectorQuery.ts +221 -0
  124. package/dist/runtime/apischunk/index.d.ts +802 -0
  125. package/dist/runtime/apischunk/index.js +5054 -0
  126. package/dist/runtime/components/deprecated.ets +43 -0
  127. package/dist/runtime/components/index.ets +49 -0
  128. package/dist/runtime/components/innerHtml.ets +16 -0
  129. package/dist/runtime/components/navigationBar.ets +65 -0
  130. package/dist/runtime/components/pageMeta.ets +94 -0
  131. package/dist/runtime/components/richText.ets +24 -0
  132. package/dist/runtime/components/slider.ets +119 -0
  133. package/dist/runtime/components/style.ets +286 -0
  134. package/dist/runtime/components/switch.ets +73 -0
  135. package/dist/runtime/components/tag.ts +58 -0
  136. package/dist/runtime/components/utils/AttributeManager.ets +252 -0
  137. package/dist/runtime/components/utils/DynamicCenter.ts +41 -0
  138. package/dist/runtime/components/utils/constant/event.ets +25 -0
  139. package/dist/runtime/components/utils/constant/style.ets +91 -0
  140. package/dist/runtime/components/utils/events.ts +26 -0
  141. package/dist/runtime/components/utils/flexManager.ets +49 -0
  142. package/dist/runtime/components/utils/helper.ets +51 -0
  143. package/dist/runtime/components/utils/htmlParser/HarmonyHTMLParser.ts +100 -0
  144. package/dist/runtime/components/utils/htmlParser/index.ts +58 -0
  145. package/dist/runtime/components/utils/index.ts +77 -0
  146. package/dist/runtime/components/utils/styles.ets +41 -0
  147. package/dist/runtime/components/video.ets +119 -0
  148. package/dist/runtime/components/webView.ets +55 -0
  149. package/dist/runtime/components/xComponent.ets +89 -0
  150. package/dist/runtime/framework/app.ts +248 -0
  151. package/dist/runtime/framework/connect.ts +24 -0
  152. package/dist/runtime/framework/constant.ts +3 -0
  153. package/dist/runtime/framework/hooks.ts +99 -0
  154. package/dist/runtime/framework/index.ts +15 -0
  155. package/dist/runtime/framework/native-page.ts +511 -0
  156. package/dist/runtime/framework/page.ts +256 -0
  157. package/dist/runtime/framework/utils/index.ts +17 -0
  158. package/dist/runtime/framework/utils/is.ts +26 -0
  159. package/dist/runtime/framework-reconciler/componentTree.ts +81 -0
  160. package/dist/runtime/framework-reconciler/constant.ts +86 -0
  161. package/dist/runtime/framework-reconciler/domInput.ts +90 -0
  162. package/dist/runtime/framework-reconciler/event.ts +108 -0
  163. package/dist/runtime/framework-reconciler/index.ts +99 -0
  164. package/dist/runtime/framework-reconciler/inputValueTracking.ts +106 -0
  165. package/dist/runtime/framework-reconciler/props.ts +132 -0
  166. package/dist/runtime/framework-reconciler/reconciler.ts +202 -0
  167. package/dist/runtime/framework-reconciler/render.ts +139 -0
  168. package/dist/runtime/framework-reconciler/workTags.ts +53 -0
  169. package/dist/runtime/runtime-cpp/bom/URL.ts +2 -0
  170. package/dist/runtime/runtime-cpp/bom/document.ts +45 -0
  171. package/dist/runtime/runtime-cpp/bom/history.ts +1 -0
  172. package/dist/runtime/runtime-cpp/bom/location.ts +1 -0
  173. package/dist/runtime/runtime-cpp/bom/navigator.ts +1 -0
  174. package/dist/runtime/runtime-cpp/bom/raf.ts +1 -0
  175. package/dist/runtime/runtime-cpp/bom/window.ts +57 -0
  176. package/dist/runtime/runtime-cpp/constant.ts +29 -0
  177. package/dist/runtime/runtime-cpp/current.ts +48 -0
  178. package/dist/runtime/runtime-cpp/dom/class-list.ts +41 -0
  179. package/dist/runtime/runtime-cpp/dom/comment.ts +9 -0
  180. package/dist/runtime/runtime-cpp/dom/dataSource.ts +87 -0
  181. package/dist/runtime/runtime-cpp/dom/document.ts +113 -0
  182. package/dist/runtime/runtime-cpp/dom/element/canvas.ts +285 -0
  183. package/dist/runtime/runtime-cpp/dom/element/element.ts +262 -0
  184. package/dist/runtime/runtime-cpp/dom/element/form.ts +371 -0
  185. package/dist/runtime/runtime-cpp/dom/element/index.ts +129 -0
  186. package/dist/runtime/runtime-cpp/dom/element/movable.ts +250 -0
  187. package/dist/runtime/runtime-cpp/dom/element/normal.ts +123 -0
  188. package/dist/runtime/runtime-cpp/dom/element/scroll_view.ts +32 -0
  189. package/dist/runtime/runtime-cpp/dom/element/text.ts +9 -0
  190. package/dist/runtime/runtime-cpp/dom/element/video.ts +66 -0
  191. package/dist/runtime/runtime-cpp/dom/element/web_view.ts +72 -0
  192. package/dist/runtime/runtime-cpp/dom/event-source.ts +1 -0
  193. package/dist/runtime/runtime-cpp/dom/event.ts +187 -0
  194. package/dist/runtime/runtime-cpp/dom/eventTarget.ts +81 -0
  195. package/dist/runtime/runtime-cpp/dom/node.ts +307 -0
  196. package/dist/runtime/runtime-cpp/dom/style.ts +44 -0
  197. package/dist/runtime/runtime-cpp/dom/stylesheet/index.ts +379 -0
  198. package/dist/runtime/runtime-cpp/dom/stylesheet/type.ts +212 -0
  199. package/dist/runtime/runtime-cpp/dom/stylesheet/util.ts +186 -0
  200. package/dist/runtime/runtime-cpp/emitter/emitter.ts +29 -0
  201. package/dist/runtime/runtime-cpp/env.ts +1 -0
  202. package/dist/runtime/runtime-cpp/harmony-library.ts +1 -0
  203. package/dist/runtime/runtime-cpp/index.ts +79 -0
  204. package/dist/runtime/runtime-cpp/interface/event.ts +10 -0
  205. package/dist/runtime/runtime-cpp/interface/index.ts +7 -0
  206. package/dist/runtime/runtime-cpp/next-tick.ts +14 -0
  207. package/dist/runtime/runtime-cpp/system.ts +213 -0
  208. package/dist/runtime/runtime-cpp/utils/index.ts +63 -0
  209. package/dist/runtime/runtime-cpp/utils/info.ts +123 -0
  210. package/dist/runtime/runtime-cpp/utils/page.ts +12 -0
  211. package/dist/runtime/runtime-cpp/utils/router.ts +1 -0
  212. package/dist/runtime/runtime-harmony/apis/helper.ets +33 -0
  213. package/dist/runtime/runtime-harmony/apis/network/common.ets +41 -0
  214. package/dist/runtime/runtime-harmony/apis/network/downloadFile.ets +327 -0
  215. package/dist/runtime/runtime-harmony/apis/network/index.ets +58 -0
  216. package/dist/runtime/runtime-harmony/apis/network/request.ets +206 -0
  217. package/dist/runtime/runtime-harmony/apis/network/uploadFile.ets +190 -0
  218. package/dist/runtime/runtime-harmony/apis/route.ets +110 -0
  219. package/dist/runtime/runtime-harmony/apis/taskpool.ets +149 -0
  220. package/dist/runtime/runtime-harmony/index.ets +41 -0
  221. package/dist/runtime/runtime-harmony/utils.ts +53 -0
  222. package/package.json +24 -23
  223. package/LICENSE +0 -174
@@ -0,0 +1,942 @@
1
+ /**
2
+ * HarmonyOS 文档:
3
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-fileio-0000001168366687
4
+ *
5
+ * WX 文档:
6
+ * https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.html
7
+ *
8
+ * Taro.js 文档
9
+ * https://taro-docs.jd.com/taro/docs/apis/files/FileSystemManager
10
+ *
11
+ * HarmonyOS 不支持接口:
12
+ * readCompressedFile
13
+ * readCompressedFileSync
14
+ * readdirSync
15
+ * readZipEntry
16
+ *
17
+ * HarmonyOS 差异性接口:
18
+ * readFile:encoding 仅支持 utf-8
19
+ * readFileSync:encoding 仅支持 utf-8
20
+ * write:encoding 仅支持 utf-8
21
+ * writeSync:encoding 仅支持 utf-8
22
+ * rmdirSync:recursive 参数无效(即不支持递归删除)
23
+ * statSync:recursive 参数无效(即不支持递归获取目录下的每个文件的 Stats 信息)
24
+ * getSavedFileList:返回值 fileList 中的每一项不包含 createTime 属性
25
+ */
26
+
27
+ import fileio from '@ohos.fileio'
28
+ import zlib from '@ohos.zlib'
29
+ import app from '@system.app'
30
+ import file from '@system.file'
31
+ import { isNumber, isString } from '@tarojs/shared'
32
+
33
+ import { callCallbackFail, callCallbackSuccess, temporarilyNotSupport, validateParams } from '../utils'
34
+
35
+ import type Taro from '@tarojs/taro/types'
36
+
37
+ const rootDataPath = `/data/data/${app.getInfo()?.appID || 'app'}`
38
+ const rootSavedFilePath = `${rootDataPath}/files`
39
+
40
+ const pathSchema = {
41
+ path: 'String'
42
+ }
43
+
44
+ const copyFileSchema = {
45
+ srcPath: 'String',
46
+ destPath: 'String'
47
+ }
48
+
49
+ const filePathSchema = {
50
+ filePath: 'String'
51
+ }
52
+
53
+ const dirPathSchema = {
54
+ dirPath: 'String'
55
+ }
56
+
57
+ const readSchema = {
58
+ fd: 'String',
59
+ arrayBuffer: 'Object'
60
+ }
61
+
62
+ const writeSchema = {
63
+ fd: 'String',
64
+ data: 'String'
65
+ }
66
+
67
+ const renameSchema = {
68
+ newPath: 'String',
69
+ oldPath: 'String'
70
+ }
71
+
72
+ const fdSchema = {
73
+ fd: 'String'
74
+ }
75
+
76
+ const saveFileSchema = {
77
+ tempFilePath: 'String'
78
+ }
79
+
80
+ const unzipSchema = {
81
+ targetPath: 'String',
82
+ zipFilePath: 'String'
83
+ }
84
+ interface ReadOption {
85
+ offset?: number
86
+ length?: number
87
+ position?: number
88
+ }
89
+
90
+ interface WriteOption extends ReadOption {
91
+ encoding: 'utf-8'
92
+ }
93
+
94
+ interface ReadFileOption {
95
+ position?: number
96
+ length?: number
97
+ encoding: 'utf-8'
98
+ }
99
+ interface ReadResult {
100
+ bytesRead: number
101
+ arrayBuffer: ArrayBuffer
102
+ }
103
+
104
+ interface WriteResult {
105
+ bytesWritten: number
106
+ }
107
+
108
+ interface StatWithFdResult {
109
+ stats: Taro.Stats | null
110
+ error: Taro.FileSystemManager.StatFailCallbackResult | null
111
+ }
112
+
113
+ interface GetDirFilesResult {
114
+ files: string[]
115
+ dirs: string[]
116
+ }
117
+
118
+ function convertFilePathToUri (filePath: string): string {
119
+ let uri = filePath.replace(/\/+/g, '/').replace(rootDataPath, 'internal:').replace('internal:/files', 'internal:/app')
120
+ uri = /\/$/.test(uri) ? uri : `${uri}/`
121
+ return uri.replace(/\//g, '//')
122
+ }
123
+
124
+ function convertUriToFilePath (uri: string): string {
125
+ return uri.replace(/\/+/g, '/').replace('internal:/app', 'internal:/files').replace('internal:', rootDataPath)
126
+ }
127
+
128
+ function convertDataToString (data: string | ArrayBuffer): string {
129
+ if (isString(data)) {
130
+ return data
131
+ }
132
+ return String.fromCharCode.apply(null, new Uint8Array(data))
133
+ }
134
+
135
+ function convertReadOption (option: Taro.FileSystemManager.ReadOption | Taro.FileSystemManager.ReadSyncOption): ReadOption {
136
+ const result: ReadOption = {}
137
+ const { offset, length, position } = option
138
+ if (isNumber(offset)) {
139
+ result.offset = offset
140
+ }
141
+ if (isNumber(length)) {
142
+ result.length = length
143
+ }
144
+ if (isNumber(position)) {
145
+ result.position = position
146
+ }
147
+ return result
148
+ }
149
+
150
+ function convertWriteOption (option: Taro.FileSystemManager.WriteOption | Taro.FileSystemManager.WriteSyncOption): WriteOption {
151
+ const result: WriteOption = {
152
+ encoding: 'utf-8'
153
+ }
154
+ const { offset, length, position } = option
155
+ if (isNumber(offset)) {
156
+ result.offset = offset
157
+ }
158
+ if (isNumber(length)) {
159
+ result.length = length
160
+ }
161
+ if (isNumber(position)) {
162
+ result.position = position
163
+ }
164
+ return result
165
+ }
166
+
167
+ function convertReadFileOption (option: Taro.FileSystemManager.ReadFileOption): ReadFileOption {
168
+ const result: ReadFileOption = {
169
+ encoding: 'utf-8'
170
+ }
171
+ const { position, length } = option
172
+ if (isNumber(position)) {
173
+ result.position = position
174
+ }
175
+ if (isNumber(length)) {
176
+ result.length = length
177
+ }
178
+ return result
179
+ }
180
+
181
+ function convertFd (fd: string): number {
182
+ return parseInt(fd, 10)
183
+ }
184
+
185
+ /**
186
+ * HarmonyOS flag 详情参见:
187
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-fileio-0000001168366687#section1153565865716
188
+ */
189
+ function convertOpenFlag (flag?: keyof Taro.FileSystemManager.flag): number {
190
+ if (typeof flag === 'string') {
191
+ switch (flag) {
192
+ case 'a':
193
+ return 0o1 | 0o100 | 0o2000
194
+ case 'ax':
195
+ return 0o1 | 0o100 | 0o2000 | 0o200
196
+ case 'a+':
197
+ return 0o2 | 0o100 | 0o2000
198
+ case 'ax+':
199
+ return 0o2 | 0o100 | 0o2000 | 0o200
200
+ case 'as':
201
+ return 0o1 | 0o100 | 0o2000 | 0o4010000
202
+ case 'as+':
203
+ return 0o2 | 0o100 | 0o2000 | 0o4010000
204
+ case 'r':
205
+ return 0o0
206
+ case 'r+':
207
+ return 0o2
208
+ case 'w':
209
+ return 0o1 | 0o100 | 0o1000
210
+ case 'wx':
211
+ return 0o1 | 0o100 | 0o200
212
+ case 'w+':
213
+ return 0o2 | 0o100 | 0o1000
214
+ case 'wx+':
215
+ return 0o2 | 0o100 | 0o200
216
+ default:
217
+ return 0o0
218
+ }
219
+ } else {
220
+ return 0o0
221
+ }
222
+ }
223
+
224
+ export function validateSavedFilePath (savedFilePath: string) {
225
+ if (savedFilePath.indexOf(rootSavedFilePath) !== 0) {
226
+ throw new Error(`The filePath should in ${rootSavedFilePath}`)
227
+ }
228
+ }
229
+
230
+ function parseSavedFilePath (srcPath: string, savedFilePath: string | undefined) : string {
231
+ if (isString(savedFilePath) && savedFilePath.length > 0) {
232
+ validateSavedFilePath(savedFilePath)
233
+ return savedFilePath
234
+ }
235
+ return `${rootSavedFilePath}/${srcPath.split('/').pop()}`
236
+ }
237
+
238
+ function isFileExist (filePath: string): boolean {
239
+ try {
240
+ accessSync(filePath)
241
+ return true
242
+ } catch (_) {
243
+ return false
244
+ }
245
+ }
246
+
247
+ function getDirFiles (dirPath: string): Promise<GetDirFilesResult> {
248
+ return new Promise((resolve, reject) => {
249
+ file.list({
250
+ uri: convertFilePathToUri(dirPath),
251
+ success: ({ fileList }) => {
252
+ resolve({
253
+ files: fileList.filter(({ type }) => type.toLowerCase() === 'file').map(({ uri }) => convertUriToFilePath(uri)),
254
+ dirs: fileList.filter(({ type }) => type.toLowerCase() === 'dir').map(({ uri }) => convertUriToFilePath(uri))
255
+ })
256
+ },
257
+ fail: (error) => {
258
+ reject(new Error(error))
259
+ }
260
+ })
261
+ })
262
+ }
263
+
264
+ const readCompressedFile = temporarilyNotSupport('readCompressedFile')
265
+
266
+ function readCompressedFileSync (_: Taro.FileSystemManager.readCompressedFileSync.Option): ArrayBuffer {
267
+ temporarilyNotSupport('readCompressedFileSync')(_)
268
+ return new ArrayBuffer(0)
269
+ }
270
+
271
+ function readdirSync (_: string): string[] {
272
+ temporarilyNotSupport('readdirSync')(_)
273
+ return []
274
+ }
275
+
276
+ const readZipEntry = temporarilyNotSupport('readZipEntry')
277
+
278
+ function access (option: Taro.FileSystemManager.AccessOption) {
279
+ try {
280
+ validateParams('access', option, pathSchema)
281
+ } catch (error) {
282
+ const res = { errMsg: error.message }
283
+ return callCallbackFail(res, option)
284
+ }
285
+ fileio.access(option.path, (error) => {
286
+ if (error) {
287
+ const res = { errMsg: error.message ? error.message : error }
288
+ callCallbackFail(res, option)
289
+ } else {
290
+ callCallbackSuccess(undefined, option)
291
+ }
292
+ })
293
+ }
294
+
295
+ function accessSync (path: string) {
296
+ fileio.accessSync(path)
297
+ }
298
+
299
+ function mkdir (option: Taro.FileSystemManager.MkdirOption) {
300
+ try {
301
+ validateParams('mkdir', option, dirPathSchema)
302
+ } catch (error) {
303
+ const res = { errMsg: error.message }
304
+ return callCallbackFail(res, option)
305
+ }
306
+ file.mkdir({
307
+ uri: convertFilePathToUri(option.dirPath),
308
+ recursive: option.recursive,
309
+ success: () => callCallbackSuccess(undefined, option),
310
+ fail: (error, code) => {
311
+ const res = { errMsg: `mkdir invoke failed, code: ${code}, error: ${error}` }
312
+ callCallbackFail(res, option)
313
+ }
314
+ })
315
+ }
316
+
317
+ function mkdirSync (dirPath: string, recursive?: boolean) {
318
+ if (recursive === true) {
319
+ const pathParts = dirPath.split('/')
320
+ for (let index = 0; index < pathParts.length; index++) {
321
+ const filePath = pathParts.slice(0, index + 1).join('/')
322
+ if (filePath.length === 0 || isFileExist(filePath)) {
323
+ continue
324
+ }
325
+ fileio.mkdirSync(filePath)
326
+ }
327
+ } else {
328
+ fileio.mkdirSync(dirPath)
329
+ }
330
+ }
331
+
332
+ function rmdir (option: Taro.FileSystemManager.RmdirOption) {
333
+ try {
334
+ validateParams('rmdir', option, dirPathSchema)
335
+ } catch (error) {
336
+ const res = { errMsg: error.message }
337
+ return callCallbackFail(res, option)
338
+ }
339
+ file.rmdir({
340
+ uri: convertFilePathToUri(option.dirPath),
341
+ recursive: option.recursive,
342
+ success: () => callCallbackSuccess(undefined, option),
343
+ fail: (error, code) => {
344
+ const res = { errMsg: `rmdir invoke failed, code: ${code}, error: ${error}` }
345
+ callCallbackFail(res, option)
346
+ }
347
+ })
348
+ }
349
+
350
+ function rmdirSync (dirPath: string, recursive?: boolean) {
351
+ if (recursive === true) {
352
+ temporarilyNotSupport('rmdirSync recursive')(dirPath)
353
+ } else {
354
+ fileio.rmdirSync(dirPath)
355
+ }
356
+ }
357
+
358
+ function readdir (option: Taro.FileSystemManager.ReaddirOption) {
359
+ try {
360
+ validateParams('readdir', option, dirPathSchema)
361
+ } catch (error) {
362
+ const res = { errMsg: error.message }
363
+ return callCallbackFail(res, option)
364
+ }
365
+
366
+ getDirFiles(option.dirPath).then(({ files, dirs }) => {
367
+ callCallbackSuccess({ files: [...files, ...dirs] }, option)
368
+ }).catch((error) => {
369
+ const res = { errMsg: error.message }
370
+ callCallbackFail(res, option)
371
+ })
372
+ }
373
+
374
+ function copyFile (option: Taro.FileSystemManager.CopyFileOption) {
375
+ try {
376
+ validateParams('copyFile', option, copyFileSchema)
377
+ } catch (error) {
378
+ const res = { errMsg: error.message }
379
+ return callCallbackFail(res, option)
380
+ }
381
+ fileio.copyFile(option.srcPath, option.destPath, 0, (error) => {
382
+ if (error) {
383
+ const res = { errMsg: error.message ? error.message : error }
384
+ callCallbackFail(res, option)
385
+ } else {
386
+ callCallbackSuccess(undefined, option)
387
+ }
388
+ })
389
+ }
390
+
391
+ function copyFileSync (srcPath: string, destPath: string) {
392
+ fileio.copyFileSync(srcPath, destPath, 0)
393
+ }
394
+
395
+ function open (option: Taro.FileSystemManager.OpenOption) {
396
+ try {
397
+ validateParams('open', option, filePathSchema)
398
+ } catch (error) {
399
+ const res = { errMsg: error.message }
400
+ return callCallbackFail(res, option)
401
+ }
402
+ // 由于 HarmonyOS 异步方法 fileio.open 在【文件不存在则创建】模式下依旧抛出 No such file or directory 异常,
403
+ // 为保证接口的可用性,此处降级使用 fileio.openSync 方法。
404
+ const openPromise = new Promise((resolve, reject) => {
405
+ try {
406
+ const fd = fileio.openSync(option.filePath, convertOpenFlag(option.flag), 0o666)
407
+ resolve({ fd: fd.toString() })
408
+ } catch (error) {
409
+ reject(new Error(error.message ? error.message : error))
410
+ }
411
+ })
412
+ openPromise.then((res) => callCallbackSuccess(res, option))
413
+ .catch((error) => callCallbackFail({ errMsg: error.message }, option))
414
+ }
415
+
416
+ function openSync (option: Taro.FileSystemManager.OpenSyncOption): string {
417
+ validateParams('openSync', option, filePathSchema)
418
+ return fileio.openSync(option.filePath, convertOpenFlag(option.flag), 0o666).toString()
419
+ }
420
+
421
+ function read (option: Taro.FileSystemManager.ReadOption) {
422
+ try {
423
+ validateParams('read', option, readSchema)
424
+ } catch (error) {
425
+ const res = { errMsg: error.message }
426
+ return callCallbackFail(res, option)
427
+ }
428
+
429
+ fileio.read(convertFd(option.fd), option.arrayBuffer, convertReadOption(option), (error, readOut) => {
430
+ if (error) {
431
+ const res = { errMsg: error.message ? error.message : error }
432
+ callCallbackFail(res, option)
433
+ } else {
434
+ callCallbackSuccess({ bytesRead: readOut.bytesRead, arrayBuffer: readOut.buffer }, option)
435
+ }
436
+ })
437
+ }
438
+
439
+ function readSync (option: Taro.FileSystemManager.ReadSyncOption): ReadResult {
440
+ validateParams('readSync', option, readSchema)
441
+ return {
442
+ bytesRead: fileio.readSync(convertFd(option.fd), option.arrayBuffer, convertReadOption(option)),
443
+ arrayBuffer: option.arrayBuffer
444
+ }
445
+ }
446
+
447
+ /**
448
+ * HarmonyOS encoding 目前仅支持 utf-8,详情参见:
449
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-fileio-0000001168366687#section17477155374810
450
+ */
451
+ function readFile (option: Taro.FileSystemManager.ReadFileOption) {
452
+ try {
453
+ validateParams('readFile', option, filePathSchema)
454
+ } catch (error) {
455
+ const res = { errMsg: error.message }
456
+ return callCallbackFail(res, option)
457
+ }
458
+
459
+ fileio.readText(option.filePath, convertReadFileOption(option), (error, data) => {
460
+ if (error) {
461
+ const res = { errMsg: error.message ? error.message : error }
462
+ callCallbackFail(res, option)
463
+ } else {
464
+ callCallbackSuccess({ data }, option)
465
+ }
466
+ })
467
+ }
468
+
469
+ /**
470
+ * HarmonyOS encoding 目前仅支持 utf-8,详情参见:
471
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-fileio-0000001168366687#section4147155065718
472
+ */
473
+ function readFileSync (filePath: string, encoding?: keyof Taro.FileSystemManager.Encoding, position?: number, length?: number): string | ArrayBuffer {
474
+ return fileio.readTextSync(filePath, convertReadFileOption({ filePath, encoding, length, position }))
475
+ }
476
+
477
+ /**
478
+ * HarmonyOS encoding 目前仅支持 utf-8,详情参见:
479
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-fileio-0000001168366687#section140547195118
480
+ */
481
+ function write (option: Taro.FileSystemManager.WriteOption) {
482
+ const data = convertDataToString(option.data)
483
+ try {
484
+ validateParams('write', { ...option, data }, writeSchema)
485
+ } catch (error) {
486
+ const res = { errMsg: error.message }
487
+ return callCallbackFail(res, option)
488
+ }
489
+ fileio.write(convertFd(option.fd), data, convertWriteOption(option), (error, bytesWritten) => {
490
+ if (error) {
491
+ const res = { errMsg: error.message ? error.message : error }
492
+ callCallbackFail(res, option)
493
+ } else {
494
+ callCallbackSuccess({ bytesWritten }, option)
495
+ }
496
+ })
497
+ }
498
+
499
+ /**
500
+ * HarmonyOS encoding 目前仅支持 utf-8,详情参见:
501
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-fileio-0000001168366687#section144923345218
502
+ */
503
+ function writeSync (option: Taro.FileSystemManager.WriteSyncOption): WriteResult {
504
+ const data = convertDataToString(option.data)
505
+ validateParams('writeSync', { ...option, data }, writeSchema)
506
+ return {
507
+ bytesWritten: fileio.writeSync(convertFd(option.fd), data, convertWriteOption(option))
508
+ }
509
+ }
510
+
511
+ function writeFileWithFlag (option: Taro.FileSystemManager.WriteFileOption, flag: keyof Taro.FileSystemManager.flag) {
512
+ open({
513
+ flag,
514
+ filePath: option.filePath,
515
+ success: ({ fd }) => {
516
+ const writePromise = new Promise((resolve) => {
517
+ write({
518
+ fd,
519
+ data: option.data,
520
+ success: (res) => resolve({
521
+ error: null,
522
+ res
523
+ }),
524
+ fail: (res) => resolve({
525
+ error: res,
526
+ res: null
527
+ })
528
+ })
529
+ })
530
+ writePromise.then(({ error, res }) => {
531
+ close({
532
+ fd,
533
+ success: () => {
534
+ if (error === null) {
535
+ callCallbackSuccess(res, option)
536
+ } else {
537
+ callCallbackFail(error, option)
538
+ }
539
+ },
540
+ fail: (res) => callCallbackFail(res, option)
541
+ })
542
+ })
543
+ },
544
+ fail: (res) => callCallbackFail(res, option)
545
+ })
546
+ }
547
+
548
+ function writeFile (option: Taro.FileSystemManager.WriteFileOption) {
549
+ writeFileWithFlag(option, 'w')
550
+ }
551
+
552
+ function writeFileSyncWithFlag (filePath: string, data: string | ArrayBuffer, flag: keyof Taro.FileSystemManager.flag) {
553
+ const fd = openSync({ filePath, flag })
554
+ writeSync({ fd, data })
555
+ closeSync({ fd })
556
+ }
557
+
558
+ function writeFileSync (filePath: string, data: string | ArrayBuffer) {
559
+ writeFileSyncWithFlag(filePath, data, 'w')
560
+ }
561
+
562
+ function appendFile (option: Taro.FileSystemManager.AppendFileOption) {
563
+ writeFileWithFlag(option, 'a')
564
+ }
565
+
566
+ function appendFileSync (filePath: string, data: string | ArrayBuffer) {
567
+ writeFileSyncWithFlag(filePath, data, 'a')
568
+ }
569
+
570
+ function rename (option: Taro.FileSystemManager.RenameOption) {
571
+ try {
572
+ validateParams('rename', option, renameSchema)
573
+ } catch (error) {
574
+ const res = { errMsg: error.message }
575
+ return callCallbackFail(res, option)
576
+ }
577
+ fileio.rename(option.oldPath, option.newPath, (error) => {
578
+ if (error) {
579
+ const res = { errMsg: error.message ? error.message : error }
580
+ callCallbackFail(res, option)
581
+ } else {
582
+ callCallbackSuccess(undefined, option)
583
+ }
584
+ })
585
+ }
586
+
587
+ function renameSync (oldPath: string, newPath: string) {
588
+ fileio.renameSync(oldPath, newPath)
589
+ }
590
+
591
+ function unlink (option: Taro.FileSystemManager.UnlinkOption) {
592
+ try {
593
+ validateParams('unlink', option, filePathSchema)
594
+ } catch (error) {
595
+ const res = { errMsg: error.message }
596
+ return callCallbackFail(res, option)
597
+ }
598
+
599
+ fileio.unlink(option.filePath, (error) => {
600
+ if (error) {
601
+ const res = { errMsg: error.message ? error.message : error }
602
+ callCallbackFail(res, option)
603
+ } else {
604
+ callCallbackSuccess(undefined, option)
605
+ }
606
+ })
607
+ }
608
+
609
+ function unlinkSync (filePath: string) {
610
+ fileio.unlinkSync(filePath)
611
+ }
612
+
613
+ function fstat (option: Taro.FileSystemManager.FstatOption) {
614
+ try {
615
+ validateParams('fstat', option, fdSchema)
616
+ } catch (error) {
617
+ const res = { errMsg: error.message }
618
+ return callCallbackFail(res, option)
619
+ }
620
+ fileio.fstat(convertFd(option.fd), (error, stats) => {
621
+ if (error) {
622
+ const res = { errMsg: error.message ? error.message : error }
623
+ callCallbackFail(res, option)
624
+ } else {
625
+ const res = {
626
+ mode: stats.mode.toString(),
627
+ size: stats.size,
628
+ lastAccessedTime: stats.atime,
629
+ lastModifiedTime: stats.mtime,
630
+ isDirectory: () => stats.isDirectory(),
631
+ isFile: () => stats.isFile()
632
+ }
633
+ callCallbackSuccess({ stats: res }, option)
634
+ }
635
+ })
636
+ }
637
+
638
+ function fstatSync (option: Taro.FileSystemManager.FstatSyncOption): Taro.Stats {
639
+ validateParams('fstatSync', option, fdSchema)
640
+ const stats = fileio.fstatSync(convertFd(option.fd))
641
+ return {
642
+ mode: stats.mode.toString(),
643
+ size: stats.size,
644
+ lastAccessedTime: stats.atime,
645
+ lastModifiedTime: stats.mtime,
646
+ isDirectory: () => stats.isDirectory(),
647
+ isFile: () => stats.isFile()
648
+ }
649
+ }
650
+
651
+ function statWithFd (fd: string): Promise<StatWithFdResult> {
652
+ return new Promise((resolve) => {
653
+ fstat({
654
+ fd,
655
+ success: ({ stats }) => resolve({
656
+ stats,
657
+ error: null
658
+ }),
659
+ fail: (error) => resolve({
660
+ error,
661
+ stats: null
662
+ })
663
+ })
664
+ })
665
+ }
666
+
667
+ function statWithPath (path: string): Promise<Taro.Stats> {
668
+ return new Promise((resolve, reject) => {
669
+ open({
670
+ filePath: path,
671
+ flag: 'r',
672
+ success: ({ fd }) => {
673
+ statWithFd(fd).then(({ error, stats }) => {
674
+ close({
675
+ fd,
676
+ success: () => {
677
+ if (error === null) {
678
+ resolve(stats!)
679
+ } else {
680
+ reject(error)
681
+ }
682
+ },
683
+ fail: (error) => reject(error)
684
+ })
685
+ })
686
+ },
687
+ fail: (error) => reject(error)
688
+ })
689
+ })
690
+ }
691
+
692
+ async function statWithRecursive (rootPath: string): Promise<Record<string, Taro.Stats>> {
693
+ let result: Record<string, Taro.Stats> = {}
694
+ const { files, dirs } = await getDirFiles(rootPath)
695
+ for (const dir of dirs) {
696
+ result[dir] = await statWithPath(dir)
697
+ result = {
698
+ ...result,
699
+ ...(await statWithRecursive(dir))
700
+ }
701
+ }
702
+ for (const file of files) {
703
+ result[file] = await statWithPath(file)
704
+ }
705
+ return result
706
+ }
707
+
708
+ function stat (option: Taro.FileSystemManager.StatOption) {
709
+ try {
710
+ validateParams('fstat', option, pathSchema)
711
+ } catch (error) {
712
+ const res = { errMsg: error.message }
713
+ return callCallbackFail(res, option)
714
+ }
715
+
716
+ const statPromise = option.recursive === true ? statWithRecursive(option.path) : statWithPath(option.path)
717
+ statPromise.then((stats) => {
718
+ callCallbackSuccess({ stats }, option)
719
+ }).catch((error) => {
720
+ const res = { errMsg: error.message ? error.message : error }
721
+ callCallbackFail(res, option)
722
+ })
723
+ }
724
+
725
+ function statSync (path: string, recursive?: boolean): Taro.Stats | any {
726
+ if (recursive === true) {
727
+ return temporarilyNotSupport('statSync recursive')(path)
728
+ }
729
+ const fd = openSync({ filePath: path, flag: 'r' })
730
+ const stats = fstatSync({ fd })
731
+ closeSync({ fd })
732
+ return stats
733
+ }
734
+
735
+ function getFileInfo (option: Taro.FileSystemManager.getFileInfoOption) {
736
+ statWithPath(option.filePath).then((stats) => {
737
+ callCallbackSuccess({ size: stats.size }, option)
738
+ }).catch((error) => {
739
+ const res = { errMsg: error.message ? error.message : error }
740
+ callCallbackFail(res, option)
741
+ })
742
+ }
743
+
744
+ function getSavedFileList (option: Taro.FileSystemManager.getSavedFileListOption) {
745
+ statWithRecursive(rootSavedFilePath).then((stats) => {
746
+ const fileList = Object.keys(stats).map((filePath) => {
747
+ const file = stats[filePath]
748
+ if (file.isFile()) {
749
+ return {
750
+ filePath,
751
+ size: file.size
752
+ }
753
+ }
754
+ return null
755
+ }).filter((file) => file !== null)
756
+ callCallbackSuccess({ fileList }, option)
757
+ }).catch((error) => {
758
+ const res = { errMsg: error.message ? error.message : error }
759
+ callCallbackFail(res, option)
760
+ })
761
+ }
762
+
763
+ function ftruncate (option: Taro.FileSystemManager.FtruncateOption) {
764
+ try {
765
+ validateParams('ftruncate', option, fdSchema)
766
+ } catch (error) {
767
+ const res = { errMsg: error.message }
768
+ return callCallbackFail(res, option)
769
+ }
770
+
771
+ fileio.ftruncate(convertFd(option.fd), option.length ?? 0, (error) => {
772
+ if (error) {
773
+ const res = { errMsg: error.message ? error.message : error }
774
+ callCallbackFail(res, option)
775
+ } else {
776
+ callCallbackSuccess(undefined, option)
777
+ }
778
+ })
779
+ }
780
+
781
+ function ftruncateSync (option: Taro.FileSystemManager.FtruncateSyncOption) {
782
+ validateParams('ftruncateSync', option, fdSchema)
783
+ fileio.ftruncateSync(convertFd(option.fd), option.length ?? 0)
784
+ }
785
+
786
+ function truncate (option: Taro.FileSystemManager.TruncateOption) {
787
+ try {
788
+ validateParams('truncate', option, filePathSchema)
789
+ } catch (error) {
790
+ const res = { errMsg: error.message }
791
+ return callCallbackFail(res, option)
792
+ }
793
+
794
+ fileio.truncate(option.filePath, option.length ?? 0, (error) => {
795
+ if (error) {
796
+ const res = { errMsg: error.message ? error.message : error }
797
+ callCallbackFail(res, option)
798
+ } else {
799
+ callCallbackSuccess(undefined, option)
800
+ }
801
+ })
802
+ }
803
+
804
+ function truncateSync (option: Taro.FileSystemManager.TruncateSyncOption) {
805
+ validateParams('truncateSync', option, filePathSchema)
806
+ fileio.truncateSync(option.filePath, option.length ?? 0)
807
+ }
808
+
809
+ function close (option: Taro.FileSystemManager.CloseOption) {
810
+ try {
811
+ validateParams('close', option, fdSchema)
812
+ } catch (error) {
813
+ const res = { errMsg: error.message }
814
+ return callCallbackFail(res, option)
815
+ }
816
+ fileio.close(convertFd(option.fd), (error) => {
817
+ if (error) {
818
+ const res = { errMsg: error.message ? error.message : error }
819
+ callCallbackFail(res, option)
820
+ } else {
821
+ callCallbackSuccess(undefined, option)
822
+ }
823
+ })
824
+ }
825
+
826
+ function closeSync (option: Taro.FileSystemManager.CloseSyncOption) {
827
+ validateParams('closeSync', option, fdSchema)
828
+ fileio.closeSync(convertFd(option.fd))
829
+ }
830
+
831
+ function saveFile (option: Taro.FileSystemManager.SaveFileOption) {
832
+ try {
833
+ validateParams('saveFile', option, saveFileSchema)
834
+ } catch (error) {
835
+ const res = { errMsg: error.message }
836
+ return callCallbackFail(res, option)
837
+ }
838
+
839
+ try {
840
+ const savedFilePath = parseSavedFilePath(option.tempFilePath, option.filePath)
841
+ rename({
842
+ oldPath: option.tempFilePath,
843
+ newPath: savedFilePath,
844
+ success: () => {
845
+ callCallbackSuccess({ savedFilePath }, option)
846
+ },
847
+ fail: (res) => {
848
+ callCallbackFail(res, option)
849
+ }
850
+ })
851
+ } catch (error) {
852
+ const res = { errMsg: error.message }
853
+ return callCallbackFail(res, option)
854
+ }
855
+ }
856
+
857
+ function saveFileSync (tempFilePath: string, filePath?: string): string {
858
+ const savedFilePath = parseSavedFilePath(tempFilePath, filePath)
859
+ renameSync(tempFilePath, savedFilePath)
860
+ return savedFilePath
861
+ }
862
+
863
+ function removeSavedFile (option: Taro.FileSystemManager.RemoveSavedFileOption) {
864
+ try {
865
+ validateParams('removeSavedFile', option, filePathSchema)
866
+ } catch (error) {
867
+ const res = { errMsg: error.message }
868
+ return callCallbackFail(res, option)
869
+ }
870
+ try {
871
+ validateSavedFilePath(option.filePath)
872
+ } catch (error) {
873
+ const res = { errMsg: error.message }
874
+ return callCallbackFail(res, option)
875
+ }
876
+ unlink(option)
877
+ }
878
+
879
+ function unzip (option: Taro.FileSystemManager.UnzipOption) {
880
+ try {
881
+ validateParams('unzip', option, unzipSchema)
882
+ } catch (error) {
883
+ const res = { errMsg: error.message }
884
+ return callCallbackFail(res, option)
885
+ }
886
+ zlib.unzipFile(option.zipFilePath, option.targetPath).then(() => {
887
+ callCallbackSuccess(undefined, option)
888
+ }).catch(error => {
889
+ const res = { errMsg: error.message ? error.message : error }
890
+ callCallbackFail(res, option)
891
+ })
892
+ }
893
+
894
+ export function getFileSystemManager (): Taro.FileSystemManager {
895
+ return {
896
+ access,
897
+ accessSync,
898
+ appendFile,
899
+ appendFileSync,
900
+ close,
901
+ closeSync,
902
+ copyFile,
903
+ copyFileSync,
904
+ fstat,
905
+ fstatSync,
906
+ ftruncate,
907
+ ftruncateSync,
908
+ getFileInfo,
909
+ getSavedFileList,
910
+ mkdir,
911
+ mkdirSync,
912
+ open,
913
+ openSync,
914
+ read,
915
+ readCompressedFile,
916
+ readCompressedFileSync,
917
+ readdir,
918
+ readdirSync,
919
+ readFile,
920
+ readFileSync,
921
+ readSync,
922
+ readZipEntry,
923
+ removeSavedFile,
924
+ rename,
925
+ renameSync,
926
+ rmdir,
927
+ rmdirSync,
928
+ saveFile,
929
+ saveFileSync,
930
+ stat,
931
+ statSync,
932
+ truncate,
933
+ truncateSync,
934
+ unlink,
935
+ unlinkSync,
936
+ unzip,
937
+ write,
938
+ writeFile,
939
+ writeFileSync,
940
+ writeSync
941
+ }
942
+ }