• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Rawfile
2
3
4## 概述
5
6提供操作rawfile目录和rawfile文件的功能,包括遍历、打开、搜索、读取和关闭。rawfile是非线程安全的,close和open相关接口是线程安全的。
7
8**起始版本:** 8
9
10
11## 汇总
12
13
14### 文件
15
16| 名称 | 描述 |
17| -------- | -------- |
18| [raw_dir.h](raw__dir_8h.md) | 提供rawfile目录相关功能。 |
19| [raw_file.h](raw__file_8h.md) | 提供rawfile文件相关功能,功能包括搜索、读取和关闭。 |
20| [raw_file_manager.h](raw__file__manager_8h.md) | 提供资源管理rawfile相关功能,可以使用ResourceManager打开rawfile进行后续相关操作,像搜索和读取等。 |
21
22
23### 结构体
24
25| 名称 | 描述 |
26| -------- | -------- |
27| struct  [RawFileDescriptor](_raw_file_descriptor.md) | 提供rawfile文件描述符信息。 |
28| struct  [RawFileDescriptor64](_raw_file_descriptor64.md) | 提供较大rawfile文件描述符信息。 |
29
30
31### 类型定义
32
33| 名称 | 描述 |
34| -------- | -------- |
35| typedef struct [RawDir](#rawdir) [RawDir](#rawdir) | 提供对rawfile目录的访问。 |
36| typedef struct [RawFile](#rawfile) [RawFile](#rawfile) | 提供对rawfile的访问功能。 |
37| typedef struct [RawFile64](#rawfile64) [RawFile64](#rawfile64) | 提供对较大rawfile的访问功能。 |
38| typedef struct [NativeResourceManager](#nativeresourcemanager) [NativeResourceManager](#nativeresourcemanager) | 代表native侧的ResourceManager。 |
39
40
41### 函数
42
43| 名称 | 描述 |
44| -------- | -------- |
45| const char \* [OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename) ([RawDir](#rawdir) \*rawDir, int index) | 通过索引获取rawfile文件名称。 |
46| int [OH_ResourceManager_GetRawFileCount](#oh_resourcemanager_getrawfilecount) ([RawDir](#rawdir) \*rawDir) | 获取[RawDir](#rawdir)中的rawfile数量。 |
47| void [OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir) ([RawDir](#rawdir) \*rawDir) | 关闭已打开的[RawDir](#rawdir)并释放所有相关联资源。 |
48| int [OH_ResourceManager_ReadRawFile](#oh_resourcemanager_readrawfile) (const [RawFile](#rawfile) \*rawFile, void \*buf, size_t length) | 读取rawfile内容,从当前位置读取指定长度的数据。 |
49| int [OH_ResourceManager_SeekRawFile](#oh_resourcemanager_seekrawfile) (const [RawFile](#rawfile) \*rawFile, long offset, int whence) | 基于指定的偏移量,在rawfile文件内搜索读写数据的位置。 |
50| long [OH_ResourceManager_GetRawFileSize](#oh_resourcemanager_getrawfilesize) ([RawFile](#rawfile) \*rawFile) | 获取rawfile长度,单位为long。 |
51| long [OH_ResourceManager_GetRawFileRemainingLength](#oh_resourcemanager_getrawfileremaininglength) (const [RawFile](#rawfile) \*rawFile) | 获取rawfile的剩余长度,单位为long。 |
52| void [OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile) ([RawFile](#rawfile) \*rawFile) | 关闭已打开的[RawFile](#rawfile) 以及释放所有相关联的资源。 |
53| long [OH_ResourceManager_GetRawFileOffset](#oh_resourcemanager_getrawfileoffset) (const [RawFile](#rawfile) \*rawFile) | 获取rawfile当前的偏移量,单位为long。 |
54| bool [OH_ResourceManager_GetRawFileDescriptor](#oh_resourcemanager_getrawfiledescriptor) (const [RawFile](#rawfile) \*rawFile, [RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | 基于偏移量(单位为long)和文件长度(单位为long)打开rawfile,并获取rawfile文件描述符。 |
55| bool [OH_ResourceManager_ReleaseRawFileDescriptor](#oh_resourcemanager_releaserawfiledescriptor) (const [RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | 关闭rawfile文件描述符。 |
56| bool [OH_ResourceManager_ReleaseRawFileDescriptorData](rawfile.md#oh_resourcemanager_releaserawfiledescriptordata) (const [RawFileDescriptor](_raw_file_descriptor.md) \*descriptor) | 关闭rawfile文件描述符。 |
57| int64_t [OH_ResourceManager_ReadRawFile64](#oh_resourcemanager_readrawfile64) (const [RawFile64](#rawfile64) \*rawFile, void \*buf, int64_t length) | 读取较大的rawfile文件内容,从当前位置读取指定长度的数据。 |
58| int [OH_ResourceManager_SeekRawFile64](#oh_resourcemanager_seekrawfile64) (const [RawFile64](#rawfile64) \*rawFile, int64_t offset, int whence) | 基于指定的偏移量,在较大的rawfile文件内搜索读写数据的位置。 |
59| int64_t [OH_ResourceManager_GetRawFileSize64](#oh_resourcemanager_getrawfilesize64) ([RawFile64](#rawfile64) \*rawFile) | 获取较大rawfile文件的长度,单位为int64_t。 |
60| int64_t [OH_ResourceManager_GetRawFileRemainingLength64](#oh_resourcemanager_getrawfileremaininglength64) (const [RawFile64](#rawfile64) \*rawFile) | 获取较大rawfile的剩余长度,单位为int64_t。 |
61| void [OH_ResourceManager_CloseRawFile64](#oh_resourcemanager_closerawfile64) ([RawFile64](#rawfile64) \*rawFile) | 关闭已打开的[RawFile64](#rawfile64) 以及释放所有相关联的资源。 |
62| int64_t [OH_ResourceManager_GetRawFileOffset64](#oh_resourcemanager_getrawfileoffset64) (const [RawFile64](#rawfile64) \*rawFile) | 获取较大rawfile文件的偏移量,单位为int64_t。 |
63| bool [OH_ResourceManager_GetRawFileDescriptor64](#oh_resourcemanager_getrawfiledescriptor64) (const [RawFile64](#rawfile64) \*rawFile, [RawFileDescriptor64](_raw_file_descriptor64.md) \*descriptor) | 基于偏移量(单位为int64_t)和文件长度(单位为int64_t)打开较大的rawfile,并获取文件描述符。 |
64| bool [OH_ResourceManager_ReleaseRawFileDescriptor64](#oh_resourcemanager_releaserawfiledescriptor64) (const [RawFileDescriptor64](_raw_file_descriptor64.md) \*descriptor) | 关闭rawfile文件描述符。 |
65| [NativeResourceManager](#nativeresourcemanager) \* [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager) (napi_env env, napi_value jsResMgr) | 基于JavaScipt侧的ResourceManager获取native侧的ResourceManager,用来完成rawfile相关功能。 |
66| void [OH_ResourceManager_ReleaseNativeResourceManager](#oh_resourcemanager_releasenativeresourcemanager) ([NativeResourceManager](#nativeresourcemanager) \*resMgr) | 释放native侧ResourceManager。 |
67| [RawDir](#rawdir) \* [OH_ResourceManager_OpenRawDir](#oh_resourcemanager_openrawdir) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*dirName) | 打开rawfile目录,打开后可以遍历对应目录下的rawfile文件。 |
68| [RawFile](#rawfile) \* [OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*fileName) | 打开rawfile文件,打开后可以读取它的数据。 |
69| [RawFile64](#rawfile64) \* [OH_ResourceManager_OpenRawFile64](#oh_resourcemanager_openrawfile64) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*fileName) | 打开较大的rawfile文件,打开后可以读取它的数据。 |
70| bool [OH_ResourceManager_IsRawDir](#oh_resourcemanager_israwdir) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*path) | 判断路径是否是rawfile下的目录。 |
71
72
73## 类型定义说明
74
75
76### NativeResourceManager
77
78```
79typedef struct NativeResourceManager NativeResourceManager
80```
81
82**描述**
83
84代表native侧的ResourceManager。
85
86此类封装了JavaScript resource manager的native实现, **ResourceManager**指针可以通过调用[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)方法获取。
87
88**起始版本:** 8
89
90
91### RawDir
92
93```
94typedef struct RawDir RawDir
95```
96
97**描述**
98
99提供对rawfile目录的访问。
100
101**起始版本:** 8
102
103
104### RawFile
105
106```
107typedef struct RawFile RawFile
108```
109
110**描述**
111
112提供对rawfile的访问功能。
113
114**起始版本:** 8
115
116
117### RawFile64
118
119```
120typedef struct RawFile64 RawFile64
121```
122
123**描述**
124
125提供对较大rawfile的访问功能。
126
127**起始版本:** 11
128
129
130## 函数说明
131
132
133### OH_ResourceManager_CloseRawDir()
134
135```
136void OH_ResourceManager_CloseRawDir (RawDir * rawDir)
137```
138
139**描述**
140
141关闭已打开的[RawDir](#rawdir)并释放所有相关联资源。
142
143**起始版本:** 8
144
145**参数:**
146
147| 名称 | 描述 |
148| -------- | -------- |
149| rawDir | 表示指向[RawDir](#rawdir)的指针。 |
150
151**参见:**
152
153[OH_ResourceManager_OpenRawDir](#oh_resourcemanager_openrawdir)
154
155
156### OH_ResourceManager_CloseRawFile()
157
158```
159void OH_ResourceManager_CloseRawFile (RawFile * rawFile)
160```
161
162**描述**
163
164关闭已打开的[RawFile](#rawfile) 以及释放所有相关联的资源。
165
166**起始版本:** 8
167
168**参数:**
169
170| 名称 | 描述 |
171| -------- | -------- |
172| rawFile | 表示指向[RawFile](#rawfile)的指针。 |
173
174**参见:**
175
176[OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile)
177
178
179### OH_ResourceManager_CloseRawFile64()
180
181```
182void OH_ResourceManager_CloseRawFile64 (RawFile64 * rawFile)
183```
184
185**描述**
186
187关闭已打开的[RawFile64](#rawfile64) 以及释放所有相关联的资源。
188
189**起始版本:** 11
190
191**参数:**
192
193| 名称 | 描述 |
194| -------- | -------- |
195| rawFile | 表示指向[RawFile64](#rawfile64)的指针。 |
196
197**参见:**
198
199[OH_ResourceManager_OpenRawFile64](#oh_resourcemanager_openrawfile64)
200
201
202### OH_ResourceManager_GetRawFileCount()
203
204```
205int OH_ResourceManager_GetRawFileCount (RawDir * rawDir)
206```
207
208**描述**
209
210获取[RawDir](#rawdir)中的rawfile数量。
211
212通过此方法可以获取[OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename)中可用的索引。
213
214**起始版本:** 8
215
216**参数:**
217
218| 名称 | 描述 |
219| -------- | -------- |
220| rawDir | 表示指向[RawDir](#rawdir)的指针。 |
221
222**参见:**
223
224[OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename)
225
226**返回:**
227
228返回rawDir下的文件个数。如果rawDir为空时返回0。
229
230
231### OH_ResourceManager_GetRawFileDescriptor()
232
233```
234bool OH_ResourceManager_GetRawFileDescriptor (const RawFile * rawFile, RawFileDescriptor & descriptor )
235```
236
237**描述**
238
239基于偏移量(单位为long)和文件长度(单位为long)打开rawfile,并获取rawfile文件描述符。
240
241打开的文件描述符被用于读取rawfile。
242
243**起始版本:** 8
244
245**参数:**
246
247| 名称 | 描述 |
248| -------- | -------- |
249| rawFile | 表示指向[RawFile](#rawfile)的指针。 |
250| descriptor | 显示rawfile文件描述符,以及在HAP包中的起始位置和长度。 |
251
252**返回:**
253
254返回true表示打开rawfile文件描述符成功,返回false表示rawfile不允许被访问。
255
256
257### OH_ResourceManager_GetRawFileDescriptor64()
258
259```
260bool OH_ResourceManager_GetRawFileDescriptor64 (const RawFile64 * rawFile, RawFileDescriptor64 * descriptor )
261```
262
263**描述**
264
265基于偏移量(单位为int64_t)和文件长度(单位为int64_t)打开较大的rawfile,并获取文件描述符。
266
267打开的文件描述符被用于读取rawfile。
268
269**起始版本:** 11
270
271**参数:**
272
273| 名称 | 描述 |
274| -------- | -------- |
275| rawFile | 表示指向[RawFile64](#rawfile64)的指针。 |
276| descriptor | 显示rawfile文件描述符,以及在HAP包中的起始位置和长度。 |
277
278**返回:**
279
280返回true表示打开rawfile文件描述符成功,返回false表示rawfile不允许被访问。
281
282
283### OH_ResourceManager_GetRawFileName()
284
285```
286const char* OH_ResourceManager_GetRawFileName (RawDir * rawDir, int index )
287```
288
289**描述**
290
291通过索引获取rawfile文件名称。
292
293可以使用此方法遍历rawfile目录。
294
295**起始版本:** 8
296
297**参数:**
298
299| 名称 | 描述 |
300| -------- | -------- |
301| rawDir | 表示指向[RawDir](#rawdir)的指针。 |
302| index | 表示文件在[RawDir](#rawdir)中的索引位置。 |
303
304**返回:**
305
306通过索引返回文件名称,此返回值可以作为[OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile)的输入参数, 如果遍历完所有文件仍未找到,则返回NULL。
307
308**参见:**
309
310[OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile)
311
312
313### OH_ResourceManager_GetRawFileOffset()
314
315```
316long OH_ResourceManager_GetRawFileOffset (const RawFile * rawFile)
317```
318
319**描述**
320
321获取rawfile当前的偏移量,单位为long。
322
323rawfile当前的偏移量。
324
325**起始版本:** 8
326
327**参数:**
328
329| 名称 | 描述 |
330| -------- | -------- |
331| rawFile | 表示指向[RawFile](#rawfile)的指针。 |
332
333**返回:**
334
335返回rawfile当前的偏移量,如果rawfile为空时返回0。
336
337
338### OH_ResourceManager_GetRawFileOffset64()
339
340```
341int64_t OH_ResourceManager_GetRawFileOffset64 (const RawFile64 * rawFile)
342```
343
344**描述**
345
346获取较大rawfile文件的偏移量,单位为int64_t。
347
348**起始版本:** 11
349
350**参数:**
351
352| 名称 | 描述 |
353| -------- | -------- |
354| rawFile | 表示指向[RawFile64](#rawfile64)的指针。 |
355
356**返回:**
357
358返回rawfile当前的偏移量,如果rawfile为空时返回0。
359
360
361### OH_ResourceManager_GetRawFileRemainingLength()
362
363```
364long OH_ResourceManager_GetRawFileRemainingLength (const RawFile * rawFile)
365```
366
367**描述**
368
369获取rawfile的剩余长度,单位为long。
370
371**起始版本:** 11
372
373**参数:**
374
375| 名称 | 描述 |
376| -------- | -------- |
377| rawFile | 表示指向[RawFile](#rawfile)的指针。 |
378
379**返回:**
380
381返回rawfile的剩余长度,如果rawfile为空时返回0。
382
383
384### OH_ResourceManager_GetRawFileRemainingLength64()
385
386```
387int64_t OH_ResourceManager_GetRawFileRemainingLength64 (const RawFile64 * rawFile)
388```
389
390**描述**
391
392获取较大rawfile的剩余长度,单位为int64_t。
393
394**起始版本:** 11
395
396**参数:**
397
398| 名称 | 描述 |
399| -------- | -------- |
400| rawFile | 表示指向[RawFile64](#rawfile64)的指针。 |
401
402**返回:**
403
404返回rawfile的剩余长度,如果rawfile为空时返回0。
405
406
407### OH_ResourceManager_GetRawFileSize()
408
409```
410long OH_ResourceManager_GetRawFileSize (RawFile * rawFile)
411```
412
413**描述**
414
415获取rawfile长度,单位为long。
416
417**起始版本:** 8
418
419**参数:**
420
421| 名称 | 描述 |
422| -------- | -------- |
423| rawFile | 表示指向[RawFile](#rawfile)的指针。 |
424
425**返回:**
426
427返回rawfile的整体长度,如果rawfile为空时返回0。
428
429
430### OH_ResourceManager_GetRawFileSize64()
431
432```
433int64_t OH_ResourceManager_GetRawFileSize64 (RawFile64 * rawFile)
434```
435
436**描述**
437
438获取较大rawfile文件的长度,单位为int64_t。
439
440**起始版本:** 11
441
442**参数:**
443
444| 名称 | 描述 |
445| -------- | -------- |
446| rawFile | 表示指向[RawFile64](#rawfile64)的指针。 |
447
448**返回:**
449
450返回rawfile的整体长度,如果rawfile为空时返回0。
451
452
453### OH_ResourceManager_InitNativeResourceManager()
454
455```
456NativeResourceManager* OH_ResourceManager_InitNativeResourceManager (napi_env env, napi_value jsResMgr )
457```
458
459**描述**
460
461基于JavaScipt侧的ResourceManager获取native侧的ResourceManager,用来完成rawfile相关功能。
462
463**起始版本:** 8
464
465**参数:**
466
467| 名称 | 描述 |
468| -------- | -------- |
469| env | 表示JavaScript Native Interface (napi)环境指针。 |
470| jsResMgr | 表示JavaScipt resource manager。 |
471
472**返回:**
473
474返回[NativeResourceManager](#nativeresourcemanager)指针,如果失败返回空指针。
475
476
477### OH_ResourceManager_IsRawDir()
478
479```
480bool OH_ResourceManager_IsRawDir (const NativeResourceManager * mgr, const char * path )
481```
482
483**描述**
484
485判断路径是否是rawfile下的目录。
486
487**起始版本:** 12
488
489**参数:**
490
491| 名称 | 描述 |
492| -------- | -------- |
493| mgr | 表示指向[NativeResourceManager](#nativeresourcemanager)的指针,此指针通过调用[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)方法获取。 |
494| path | rawfile路径 |
495
496**返回:**
497
498返回true表示是rawfile下的目录,返回false表示不是rawfile下的目录。
499
500
501### OH_ResourceManager_OpenRawDir()
502
503```
504RawDir* OH_ResourceManager_OpenRawDir (const NativeResourceManager * mgr, const char * dirName )
505```
506
507**描述**
508
509打开rawfile目录,打开后可以遍历对应目录下的rawfile文件。
510
511**起始版本:** 8
512
513**参数:**
514
515| 名称 | 描述 |
516| -------- | -------- |
517| mgr | 表示指向[NativeResourceManager](#nativeresourcemanager)的指针,此指针是通过调用 [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)方法获取的。 |
518| dirName | 表示要打开的rawfile目录名称,当传递一个空字符串时表示打开rawfile根目录。 |
519
520**返回:**
521
522返回[RawDir](#rawdir)指针。使用完此指针后,调用[OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir)释放。如果失败或者mgr为空时返回空指针。
523
524**参见:**
525
526[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)
527
528[OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir)
529
530
531### OH_ResourceManager_OpenRawFile()
532
533```
534RawFile* OH_ResourceManager_OpenRawFile (const NativeResourceManager * mgr, const char * fileName )
535```
536
537**描述**
538
539打开rawfile文件,打开后可以读取它的数据。
540
541**起始版本:** 8
542
543**参数:**
544
545| 名称 | 描述 |
546| -------- | -------- |
547| mgr | 表示指向[NativeResourceManager](#nativeresourcemanager)的指针,此指针通过调用[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)方法获取。 |
548| fileName | 表示基于rawfile根目录的相对路径下的文件名称。 |
549
550**返回:**
551
552返回[RawFile](#rawfile)指针。当使用完此指针,调用[OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile)释放。如果失败或者mgr和fileName为空时返回空指针。
553
554**参见:**
555
556[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)
557
558[OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile)
559
560
561### OH_ResourceManager_OpenRawFile64()
562
563```
564RawFile64* OH_ResourceManager_OpenRawFile64 (const NativeResourceManager * mgr, const char * fileName )
565```
566
567**描述**
568
569打开较大的rawfile文件,打开后可以读取它的数据。
570
571**起始版本:** 11
572
573**参数:**
574
575| 名称 | 描述 |
576| -------- | -------- |
577| mgr | 表示指向[NativeResourceManager](#nativeresourcemanager)的指针,此指针通过调用[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)方法获取。 |
578| fileName | 表示基于rawfile根目录的相对路径下的文件名称。 |
579
580**返回:**
581
582返回[RawFile64](#rawfile64)指针。当使用完此指针,调用[OH_ResourceManager_CloseRawFile64](#oh_resourcemanager_closerawfile64)释放。如果失败或者mgr和fileName为空时返回空指针。
583
584**参见:**
585
586[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager)
587
588[OH_ResourceManager_CloseRawFile64](#oh_resourcemanager_closerawfile64)
589
590
591### OH_ResourceManager_ReadRawFile()
592
593```
594int OH_ResourceManager_ReadRawFile (const RawFile * rawFile, void * buf, size_t length )
595```
596
597**描述**
598
599读取rawfile内容,从当前位置读取指定长度的数据。
600
601**起始版本:** 8
602
603**参数:**
604
605| 名称 | 描述 |
606| -------- | -------- |
607| rawFile | 表示指向[RawFile](#rawfile)的指针。 |
608| buf | 用于接收读取数据的缓冲区指针。 |
609| length | 读取数据的字节长度。 |
610
611**返回:**
612
613返回读取的字节数,如果读取长度超过文件末尾长度或者rawfile为空时,则返回0。
614
615
616### OH_ResourceManager_ReadRawFile64()
617
618```
619int64_t OH_ResourceManager_ReadRawFile64 (const RawFile64 * rawFile, void * buf, int64_t length )
620```
621
622**描述**
623
624读取较大的rawfile文件内容,从当前位置读取指定长度的数据。
625
626**起始版本:** 11
627
628**参数:**
629
630| 名称 | 描述 |
631| -------- | -------- |
632| rawFile | 表示指向[RawFile64](#rawfile64)的指针。 |
633| buf | 用于接收读取数据的缓冲区指针。 |
634| length | 读取数据的字节长度。 |
635
636**返回:**
637
638返回读取的字节数,如果读取长度超过文件末尾长度或者rawfile为空时,则返回0。
639
640
641### OH_ResourceManager_ReleaseNativeResourceManager()
642
643```
644void OH_ResourceManager_ReleaseNativeResourceManager (NativeResourceManager * resMgr)
645```
646
647**描述**
648
649释放native侧ResourceManager。
650
651**起始版本:** 8
652
653**参数:**
654
655| 名称 | 描述 |
656| -------- | -------- |
657| resMgr | 表示[NativeResourceManager](#nativeresourcemanager)指针。 |
658
659
660### OH_ResourceManager_ReleaseRawFileDescriptor()
661
662```
663bool OH_ResourceManager_ReleaseRawFileDescriptor (const RawFileDescriptor & descriptor)
664```
665
666**描述**
667
668关闭rawfile文件描述符。
669
670已打开的文件描述符在使用完以后必须释放,防止文件描述符泄露。
671
672**起始版本:** 8
673
674**参数:**
675
676| 名称 | 描述 |
677| -------- | -------- |
678| descriptor | 包含rawfile文件描述符,以及在HAP包中的起始位置和长度。 |
679
680**返回:**
681
682返回true表示关闭文件描述符成功,返回false表示关闭文件描述符失败。
683
684### OH_ResourceManager_ReleaseRawFileDescriptorData()
685
686```
687bool OH_ResourceManager_ReleaseRawFileDescriptorData (const RawFileDescriptor * descriptor )
688```
689
690**描述**
691
692关闭rawfile文件描述符。
693
694已打开的文件描述符在使用完以后必须释放,防止文件描述符泄露。
695
696**起始版本:** 12
697
698**参数:**
699
700| 名称 | 描述 |
701| -------- | -------- |
702| descriptor | 包含rawfile文件描述符,以及在HAP包中的起始位置和长度。 |
703
704**返回:**
705
706返回true表示关闭文件描述符成功,返回false表示关闭文件描述符失败。
707
708### OH_ResourceManager_ReleaseRawFileDescriptor64()
709
710```
711bool OH_ResourceManager_ReleaseRawFileDescriptor64 (const RawFileDescriptor64 * descriptor)
712```
713
714**描述**
715
716关闭rawfile文件描述符。
717
718已打开的文件描述符在使用完以后必须释放,防止文件描述符泄露。
719
720**起始版本:** 11
721
722**参数:**
723
724| 名称 | 描述 |
725| -------- | -------- |
726| descriptor | 包含rawfile文件描述符,以及在HAP包中的起始位置和长度。 |
727
728**返回:**
729
730返回true表示关闭文件描述符成功,返回false表示关闭文件描述符失败。
731
732
733### OH_ResourceManager_SeekRawFile()
734
735```
736int OH_ResourceManager_SeekRawFile (const RawFile * rawFile, long offset, int whence )
737```
738
739**描述**
740
741基于指定的偏移量,在rawfile文件内搜索读写数据的位置。
742
743**起始版本:** 8
744
745**参数:**
746
747| 名称 | 描述 |
748| -------- | -------- |
749| rawFile | 表示指向[RawFile](#rawfile)的指针。 |
750| offset | 表示指定的偏移量。 |
751| whence | 读写位置,有以下场景:<br/>0: 读写位置为文件起始位置加上offset。<br/>1: 读写位置为当前位置加上offset。<br/>2: 读写位置为文件末尾加上offset。 |
752
753**返回:**
754
755如果搜索成功返回0,如果发生错误返回-1。
756
757
758### OH_ResourceManager_SeekRawFile64()
759
760```
761int OH_ResourceManager_SeekRawFile64 (const RawFile64 * rawFile, int64_t offset, int whence )
762```
763
764**描述**
765
766基于指定的偏移量,在较大的rawfile文件内搜索读写数据的位置。
767
768**起始版本:** 11
769
770**参数:**
771
772| 名称 | 描述 |
773| -------- | -------- |
774| rawFile | 表示指向[RawFile64](#rawfile64)的指针。 |
775| offset | 表示指定的偏移量。 |
776| whence | 读写位置,有以下场景:<br/>0: 读写位置为文件起始位置加上offset。<br/>1: 读写位置为当前位置加上offset。<br/>2: 读写位置为文件末尾加上offset。 |
777
778**返回:**
779
780如果搜索成功返回0,如果发生错误返回-1。