1# Rawfile 2 3 4## Overview 5 6Provides the function of operating rawfile directories and rawfiles. You can use the APIs to traverse, open, search for, read, and close raw files. The **rawfile** APIs are non-thread-safe, and the **close** and **open** APIs are thread-safe. 7 8**Since**: 8 9 10 11## Summary 12 13 14### Files 15 16| Name| Description| 17| -------- | -------- | 18| [raw_dir.h](raw__dir_8h.md) | Provides functions related to the **rawfile** directory.| 19| [raw_file.h](raw__file_8h.md) | Provides functions related to rawfiles, including searching for, reading, and closing rawfiles.| 20| [raw_file_manager.h](raw__file__manager_8h.md) | Provides file management functions for the **rawfile** directory. You can use the **ResourceManager** to open a rawfile and perform operations such as data search and reading.| 21 22 23### Structs 24 25| Name| Description| 26| -------- | -------- | 27| struct [RawFileDescriptor](_raw_file_descriptor.md) | Defines the file descriptor information of a file in the **rawfile** directory.| 28| struct [RawFileDescriptor64](_raw_file_descriptor64.md) | Defines the file descriptor of a large rawfile.| 29 30 31### Types 32 33| Name| Description| 34| -------- | -------- | 35| typedef struct [RawDir](#rawdir) [RawDir](#rawdir) | Provides access to the **rawfile** directory.| 36| typedef struct [RawFile](#rawfile) [RawFile](#rawfile) | Provides access to rawfiles.| 37| typedef struct [RawFile64](#rawfile64) [RawFile64](#rawfile64) | Provides access to large rawfiles.| 38| typedef struct [NativeResourceManager](#nativeresourcemanager) [NativeResourceManager](#nativeresourcemanager) | Represents the native **ResourceManager**.| 39 40 41### Functions 42 43| Name| Description| 44| -------- | -------- | 45| const char \* [OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename) ([RawDir](#rawdir) \*rawDir, int index) | Obtains the name of a file in **rawfile** based on the index.| 46| int [OH_ResourceManager_GetRawFileCount](#oh_resourcemanager_getrawfilecount) ([RawDir](#rawdir) \*rawDir) | Obtains the number of files in a [RawDir](#rawdir).| 47| void [OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir) ([RawDir](#rawdir) \*rawDir) | Closes a [RawDir](#rawdir) and releases all associated resources.| 48| int [OH_ResourceManager_ReadRawFile](#oh_resourcemanager_readrawfile) (const [RawFile](#rawfile) \*rawFile, void \*buf, size_t length) | Reads data of the specified length from the current position in a rawfile.| 49| int [OH_ResourceManager_SeekRawFile](#oh_resourcemanager_seekrawfile) (const [RawFile](#rawfile) \*rawFile, long offset, int whence) | Searches for the data read/write position in a rawfile based on the specified offset.| 50| long [OH_ResourceManager_GetRawFileSize](#oh_resourcemanager_getrawfilesize) ([RawFile](#rawfile) \*rawFile) | Obtains the length of the rawfile, in long.| 51| long [OH_ResourceManager_GetRawFileRemainingLength](#oh_resourcemanager_getrawfileremaininglength) (const [RawFile](#rawfile) \*rawFile) | Obtains the remaining length of the rawfile, in long.| 52| void [OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile) ([RawFile](#rawfile) \*rawFile) | Closes a [RawFile](#rawfile) and releases all associated resources.| 53| long [OH_ResourceManager_GetRawFileOffset](#oh_resourcemanager_getrawfileoffset) (const [RawFile](#rawfile) \*rawFile) | Obtains the current offset of a rawfile, in long.| 54| bool [OH_ResourceManager_GetRawFileDescriptor](#oh_resourcemanager_getrawfiledescriptor) (const [RawFile](#rawfile) \*rawFile, [RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | Opens a rawfile based on the specified offset (in long) and file length (in long) and obtains the file descriptor.| 55| bool [OH_ResourceManager_ReleaseRawFileDescriptor](#oh_resourcemanager_releaserawfiledescriptor) (const [RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | Releases a file descriptor.| 56| int64_t [OH_ResourceManager_ReadRawFile64](#oh_resourcemanager_readrawfile64) (const [RawFile64](#rawfile64) \*rawFile, void \*buf, int64_t length) | Reads data of the specified length from the current position in a large rawfile.| 57| int [OH_ResourceManager_SeekRawFile64](#oh_resourcemanager_seekrawfile64) (const [RawFile64](#rawfile64) \*rawFile, int64_t offset, int whence) | Searches for the data read/write position in a large rawfile based on the specified offset.| 58| int64_t [OH_ResourceManager_GetRawFileSize64](#oh_resourcemanager_getrawfilesize64) ([RawFile64](#rawfile64) \*rawFile) | Obtains the length of a large rawfile, in int64_t.| 59| int64_t [OH_ResourceManager_GetRawFileRemainingLength64](#oh_resourcemanager_getrawfileremaininglength64) (const [RawFile64](#rawfile64) \*rawFile) | Obtains the remaining length of a large rawfile, in int64_t.| 60| void [OH_ResourceManager_CloseRawFile64](#oh_resourcemanager_closerawfile64) ([RawFile64](#rawfile64) \*rawFile) | Closes a [RawFile64](#rawfile64) and releases all associated resources.| 61| int64_t [OH_ResourceManager_GetRawFileOffset64](#oh_resourcemanager_getrawfileoffset64) (const [RawFile64](#rawfile64) \*rawFile) | Obtains the offset of a large rawfile, in int64_t.| 62| bool [OH_ResourceManager_GetRawFileDescriptor64](#oh_resourcemanager_getrawfiledescriptor64) (const [RawFile64](#rawfile64) \*rawFile, [RawFileDescriptor64](_raw_file_descriptor64.md) \*descriptor) | Opens a large rawfile based on the specified offset (in int64_t) and file length (in int64_t) and obtains the file descriptor.| 63| bool [OH_ResourceManager_ReleaseRawFileDescriptor64](#oh_resourcemanager_releaserawfiledescriptor64) (const [RawFileDescriptor64](_raw_file_descriptor64.md) \*descriptor) | Releases a file descriptor.| 64| [NativeResourceManager](#nativeresourcemanager) \* [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager) (napi_env env, napi_value jsResMgr) | Obtains the native **ResourceManager** based on the JS **ResourceManager** to implement rawfile-specific functions.| 65| void [OH_ResourceManager_ReleaseNativeResourceManager](#oh_resourcemanager_releasenativeresourcemanager) ([NativeResourceManager](#nativeresourcemanager) \*resMgr) | Releases the native **ResourceManager**.| 66| [RawDir](#rawdir) \* [OH_ResourceManager_OpenRawDir](#oh_resourcemanager_openrawdir) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*dirName) | Traverses all files in the **rawfile** directory.| 67| [RawFile](#rawfile) \* [OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*fileName) | Opens a rawfile and reads the data in it.| 68| [RawFile64](#rawfile64) \* [OH_ResourceManager_OpenRawFile64](#oh_resourcemanager_openrawfile64) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*fileName) | Opens a large rawfile and reads the data in it.| 69| bool [OH_ResourceManager_IsRawDir](#oh_resourcemanager_israwdir) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*path) | Checks whether a path is a subdirectory in the **rawfile** directory.| 70 71 72## Type Description 73 74 75### NativeResourceManager 76 77``` 78typedef struct NativeResourceManager NativeResourceManager 79``` 80 81**Description** 82 83Represents the native **ResourceManager**. 84 85This class encapsulates the native implementation of the JavaScript resource manager. The **ResourceManager** pointer can be obtained by using [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager). 86 87**Since**: 8 88 89 90### RawDir 91 92``` 93typedef struct RawDir RawDir 94``` 95 96**Description** 97 98Provides access to the **rawfile** directory. 99 100**Since**: 8 101 102 103### RawFile 104 105``` 106typedef struct RawFile RawFile 107``` 108 109**Description** 110 111Provides access to rawfiles. 112 113**Since**: 8 114 115 116### RawFile64 117 118``` 119typedef struct RawFile64 RawFile64 120``` 121 122**Description** 123 124Provides access to large rawfiles. 125 126**Since**: 11 127 128 129## Function Description 130 131 132### OH_ResourceManager_CloseRawDir() 133 134``` 135void OH_ResourceManager_CloseRawDir (RawDir * rawDir) 136``` 137 138**Description** 139 140Closes a [RawDir](#rawdir) opened and releases all associated resources. 141 142**Since**: 8 143 144**Parameters** 145 146| Name| Description| 147| -------- | -------- | 148| rawDir | Pointer to the [RawDir](#rawdir).| 149 150**See** 151 152[OH_ResourceManager_OpenRawDir](#oh_resourcemanager_openrawdir) 153 154 155### OH_ResourceManager_CloseRawFile() 156 157``` 158void OH_ResourceManager_CloseRawFile (RawFile * rawFile) 159``` 160 161**Description** 162 163Closes a [RawFile](#rawfile) and releases all associated resources. 164 165**Since**: 8 166 167**Parameters** 168 169| Name| Description| 170| -------- | -------- | 171| rawFile | Pointer to the [RawFile](#rawfile) to read.| 172 173**See** 174 175[OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile) 176 177 178### OH_ResourceManager_CloseRawFile64() 179 180``` 181void OH_ResourceManager_CloseRawFile64 (RawFile64 * rawFile) 182``` 183 184**Description** 185 186Closes a [RawFile64](#rawfile64) and releases all associated resources. 187 188**Since**: 11 189 190**Parameters** 191 192| Name| Description| 193| -------- | -------- | 194| rawFile | Pointer to [RawFile64](#rawfile64).| 195 196**See** 197 198[OH_ResourceManager_OpenRawFile64](#oh_resourcemanager_openrawfile64) 199 200 201### OH_ResourceManager_GetRawFileCount() 202 203``` 204int OH_ResourceManager_GetRawFileCount (RawDir * rawDir) 205``` 206 207**Description** 208 209Obtains the number of files in a [RawDir](#rawdir). 210 211You can use this function to obtain available indexes in [OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename). 212 213**Since**: 8 214 215**Parameters** 216 217| Name| Description| 218| -------- | -------- | 219| rawDir | Pointer to the [RawDir](#rawdir).| 220 221**See** 222 223[OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename) 224 225**Returns** 226 227Number of files in **rawDir**. If **rawDir** is empty, **0** is returned. 228 229 230### OH_ResourceManager_GetRawFileDescriptor() 231 232``` 233bool OH_ResourceManager_GetRawFileDescriptor (const RawFile * rawFile, RawFileDescriptor & descriptor ) 234``` 235 236**Description** 237 238Opens a rawfile based on the specified offset (in long) and file length (in long) and obtains the file descriptor. 239 240The file descriptor obtained can be used to read the file. 241 242**Since**: 8 243 244**Parameters** 245 246| Name| Description| 247| -------- | -------- | 248| rawFile | Pointer to the [RawFile](#rawfile) to read.| 249| descriptor | File descriptor of the rawfile, start position of the rawfile in the HAP, and length of the rawfile.| 250 251**Returns** 252 253<b>true</b> if the file is opened; returns <b>false</b> if the access to the file is rejected. 254 255 256### OH_ResourceManager_GetRawFileDescriptor64() 257 258``` 259bool OH_ResourceManager_GetRawFileDescriptor64 (const RawFile64 * rawFile, RawFileDescriptor64 * descriptor ) 260``` 261 262**Description** 263 264Opens a large rawfile based on the specified offset (in int64_t) and file length (in int64_t) and obtains the file descriptor. 265 266The file descriptor obtained can be used to read the file. 267 268**Since**: 11 269 270**Parameters** 271 272| Name| Description| 273| -------- | -------- | 274| rawFile | Pointer to [RawFile64](#rawfile64).| 275| descriptor | File descriptor of the rawfile, start position of the rawfile in the HAP, and length of the rawfile.| 276 277**Returns** 278 279<b>true</b> if the file is opened; <b>false</b> if the access to the file is rejected. 280 281 282### OH_ResourceManager_GetRawFileName() 283 284``` 285const char* OH_ResourceManager_GetRawFileName (RawDir * rawDir, int index ) 286``` 287 288**Description** 289 290Obtains the name of a file in **rawfile** based on the index. 291 292You can use this function to traverse the **rawfile** directory. 293 294**Since**: 8 295 296**Parameters** 297 298| Name| Description| 299| -------- | -------- | 300| rawDir | Pointer to the [RawDir](#rawdir).| 301| index | Index of the file in the [RawDir](#rawdir).| 302 303**Returns** 304 305File name obtained if the rawfile exists in the directory; returns **null** otherwise. The file name returned can be used as the input parameter of [OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile). 306 307**See** 308 309[OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile) 310 311 312### OH_ResourceManager_GetRawFileOffset() 313 314``` 315long OH_ResourceManager_GetRawFileOffset (const RawFile * rawFile) 316``` 317 318**Description** 319 320Obtains the current offset of a rawfile, in long. 321 322Current offset of the rawfile. 323 324**Since**: 8 325 326**Parameters** 327 328| Name| Description| 329| -------- | -------- | 330| rawFile | Pointer to the [RawFile](#rawfile) to read.| 331 332**Returns** 333 334Current offset of the rawfile. If the rawfile is empty, **0** is returned. 335 336 337### OH_ResourceManager_GetRawFileOffset64() 338 339``` 340int64_t OH_ResourceManager_GetRawFileOffset64 (const RawFile64 * rawFile) 341``` 342 343**Description** 344 345Obtains the offset of a large rawfile, in int64_t. 346 347**Since**: 11 348 349**Parameters** 350 351| Name| Description| 352| -------- | -------- | 353| rawFile | Pointer to [RawFile64](#rawfile64).| 354 355**Returns** 356 357Returns the current offset of the rawfile. If the rawfile is empty, 0 is returned. 358 359 360### OH_ResourceManager_GetRawFileRemainingLength() 361 362``` 363long OH_ResourceManager_GetRawFileRemainingLength (const RawFile * rawFile) 364``` 365 366**Description** 367 368Obtains the remaining length of the rawfile, in long. 369 370**Since**: 11 371 372**Parameters** 373 374| Name| Description| 375| -------- | -------- | 376| rawFile | Pointer to the [RawFile](#rawfile) to read.| 377 378**Returns** 379 380Remaining length of the rawfile. If the rawfile is empty, **0** is returned. 381 382 383### OH_ResourceManager_GetRawFileRemainingLength64() 384 385``` 386int64_t OH_ResourceManager_GetRawFileRemainingLength64 (const RawFile64 * rawFile) 387``` 388 389**Description** 390 391Obtains the remaining length of a large rawfile, in int64_t. 392 393**Since**: 11 394 395**Parameters** 396 397| Name| Description| 398| -------- | -------- | 399| rawFile | Pointer to [RawFile64](#rawfile64).| 400 401**Returns** 402 403Remaining length of the rawfile. If the rawfile is empty, **0** is returned. 404 405 406### OH_ResourceManager_GetRawFileSize() 407 408``` 409long OH_ResourceManager_GetRawFileSize (RawFile * rawFile) 410``` 411 412**Description** 413 414Obtains the length of the rawfile, in long. 415 416**Since**: 8 417 418**Parameters** 419 420| Name| Description| 421| -------- | -------- | 422| rawFile | Pointer to the [RawFile](#rawfile) to read.| 423 424**Returns** 425 426Overall length of the rawfile. If the rawfile is empty, **0** is returned. 427 428 429### OH_ResourceManager_GetRawFileSize64() 430 431``` 432int64_t OH_ResourceManager_GetRawFileSize64 (RawFile64 * rawFile) 433``` 434 435**Description** 436 437Obtains the length of a large rawfile, in int64_t. 438 439**Since**: 11 440 441**Parameters** 442 443| Name| Description| 444| -------- | -------- | 445| rawFile | Pointer to [RawFile64](#rawfile64).| 446 447**Returns** 448 449Overall length of the rawfile. If the rawfile is empty, **0** is returned. 450 451 452### OH_ResourceManager_InitNativeResourceManager() 453 454``` 455NativeResourceManager* OH_ResourceManager_InitNativeResourceManager (napi_env env, napi_value jsResMgr ) 456``` 457 458**Description** 459 460Obtains the native **ResourceManager** based on the JS **ResourceManager** to implement rawfile-specific functions. 461 462**Since**: 8 463 464**Parameters** 465 466| Name| Description| 467| -------- | -------- | 468| env | Pointer to the JavaScript Native API (napi) environment.| 469| jsResMgr | JS **ResourceManager**.| 470 471**Returns** 472 473Pointer to [NativeResourceManager](#nativeresourcemanager). If the operation fails, a null pointer is returned. 474 475 476### OH_ResourceManager_IsRawDir() 477 478``` 479bool OH_ResourceManager_IsRawDir (const NativeResourceManager * mgr, const char * path ) 480``` 481 482**Description** 483 484Checks whether a path is a subdirectory in the **rawfile** directory. 485 486**Since**: 12 487 488**Parameters** 489 490| Name| Description| 491| -------- | -------- | 492| mgr | Pointer to the [NativeResourceManager](#nativeresourcemanager), which is obtained by using [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager).| 493| path | Path of a rawfile.| 494 495**Returns** 496 497**true** if the path is a subdirectory in the **rawfile** directory; **false** otherwise. 498 499 500### OH_ResourceManager_OpenRawDir() 501 502``` 503RawDir* OH_ResourceManager_OpenRawDir (const NativeResourceManager * mgr, const char * dirName ) 504``` 505 506**Description** 507 508Traverses all files in the **rawfile** directory. 509 510**Since**: 8 511 512**Parameters** 513 514| Name| Description| 515| -------- | -------- | 516| mgr | Pointer to the [NativeResourceManager](#nativeresourcemanager), which is obtained by using [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager).| 517| dirName | Pointer to the name of the directory to open. If this field is left empty, the root directory will be opened.| 518 519**Returns** 520 521Pointer to the [RawDir](#rawdir). You can use [OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir) to close the directory and release resources. If the operation fails or **mgr** is empty, a null pointer is returned. 522 523**See** 524 525[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager) 526 527[OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir) 528 529 530### OH_ResourceManager_OpenRawFile() 531 532``` 533RawFile* OH_ResourceManager_OpenRawFile (const NativeResourceManager * mgr, const char * fileName ) 534``` 535 536**Description** 537 538Opens a rawfile and reads the data in it. 539 540**Since**: 8 541 542**Parameters** 543 544| Name| Description| 545| -------- | -------- | 546| mgr | Pointer to the [NativeResourceManager](#nativeresourcemanager), which is obtained by using [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager).| 547| fileName | Pointer to the name of the file in the relative path of the **rawfile** root directory.| 548 549**Returns** 550 551Pointer to the [RawFile](#rawfile) opened. You can use [OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile) to close the rawfile and release resources. If the operation fails or **mgr** or **fileName** is empty, a null pointer is returned. 552 553**See** 554 555[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager) 556 557[OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile) 558 559 560### OH_ResourceManager_OpenRawFile64() 561 562``` 563RawFile64* OH_ResourceManager_OpenRawFile64 (const NativeResourceManager * mgr, const char * fileName ) 564``` 565 566**Description** 567 568Opens a large rawfile and reads the data in it. 569 570**Since**: 11 571 572**Parameters** 573 574| Name| Description| 575| -------- | -------- | 576| mgr | Pointer to the [NativeResourceManager](#nativeresourcemanager), which is obtained by using [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager).| 577| fileName | Pointer to the name of the file in the relative path of the **rawfile** root directory.| 578 579**Returns** 580 581Pointer to [RawFile64](#rawfile64). After this pointer is used, call [OH_ResourceManager_CloseRawFile64](#oh_resourcemanager_closerawfile64) to release it. If the operation fails or **mgr** or **fileName** is empty, a null pointer is returned. 582 583**See** 584 585[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager) 586 587[OH_ResourceManager_CloseRawFile64](#oh_resourcemanager_closerawfile64) 588 589 590### OH_ResourceManager_ReadRawFile() 591 592``` 593int OH_ResourceManager_ReadRawFile (const RawFile * rawFile, void * buf, size_t length ) 594``` 595 596**Description** 597 598Reads data of the specified length from the current position in a rawfile. 599 600**Since**: 8 601 602**Parameters** 603 604| Name| Description| 605| -------- | -------- | 606| rawFile | Pointer to the [RawFile](#rawfile) to read.| 607| buf | Pointer to the buffer for receiving the read data.| 608| length | Length of the data to read.| 609 610**Returns** 611 612Number of read bytes. If the read length exceeds the length of the file end or rawfile is empty, **0** is returned. 613 614 615### OH_ResourceManager_ReadRawFile64() 616 617``` 618int64_t OH_ResourceManager_ReadRawFile64 (const RawFile64 * rawFile, void * buf, int64_t length ) 619``` 620 621**Description** 622 623Reads data of the specified length from the current position in a large rawfile. 624 625**Since**: 11 626 627**Parameters** 628 629| Name| Description| 630| -------- | -------- | 631| rawFile | Pointer to [RawFile64](#rawfile64).| 632| buf | Pointer to the buffer for receiving the read data.| 633| length | Length of the data to read.| 634 635**Returns** 636 637Number of read bytes. If the read length exceeds the length of the file end or rawfile is empty, **0** is returned. 638 639 640### OH_ResourceManager_ReleaseNativeResourceManager() 641 642``` 643void OH_ResourceManager_ReleaseNativeResourceManager (NativeResourceManager * resMgr) 644``` 645 646**Description** 647 648Releases the native **ResourceManager**. 649 650**Since**: 8 651 652**Parameters** 653 654| Name| Description| 655| -------- | -------- | 656| resMgr | Pointer to the [NativeResourceManager](#nativeresourcemanager) instance to release.| 657 658 659### OH_ResourceManager_ReleaseRawFileDescriptor() 660 661``` 662bool OH_ResourceManager_ReleaseRawFileDescriptor (const RawFileDescriptor & descriptor) 663``` 664 665**Description** 666 667Releases the file descriptor of a file in **rawfile**. 668 669To prevent file descriptor leakage, you are advised to release a rawfile descriptor immediately after use. 670 671**Since**: 8 672 673**Parameters** 674 675| Name| Description| 676| -------- | -------- | 677| descriptor | File descriptor of the rawfile. It contains the file descriptor, start position in the HAP, and file length.| 678 679**Returns** 680 681Returns <b>true</b> if the file descriptor is released; returns <b>false</b> otherwise. 682 683 684### OH_ResourceManager_ReleaseRawFileDescriptor64() 685 686``` 687bool OH_ResourceManager_ReleaseRawFileDescriptor64 (const RawFileDescriptor64 * descriptor) 688``` 689 690**Description** 691 692Releases the file descriptor of a file in **rawfile**. 693 694To prevent file descriptor leakage, you are advised to release a rawfile descriptor immediately after use. 695 696**Since**: 11 697 698**Parameters** 699 700| Name| Description| 701| -------- | -------- | 702| descriptor | File descriptor of the rawfile. It contains the file descriptor, start position in the HAP, and file length.| 703 704**Returns** 705 706<b>true</b> if the file descriptor is released; <b>false</b> otherwise. 707 708 709### OH_ResourceManager_SeekRawFile() 710 711``` 712int OH_ResourceManager_SeekRawFile (const RawFile * rawFile, long offset, int whence ) 713``` 714 715**Description** 716 717Searches for the data read/write position in a rawfile based on the specified offset. 718 719**Since**: 8 720 721**Parameters** 722 723| Name| Description| 724| -------- | -------- | 725| rawFile | Pointer to the [RawFile](#rawfile) to read.| 726| offset | Specified offset.| 727| whence | Read/Write position. The options are as follows:<br>**0**: The read/write position is the start position of the file plus the offset.<br>**1**: The read/write position is the current position plus the offset.<br>**2**: The read/write position is the end position of the file plus the offset.| 728 729**Returns** 730 731**0** if the search is successful; **-1** otherwise. 732 733 734### OH_ResourceManager_SeekRawFile64() 735 736``` 737int OH_ResourceManager_SeekRawFile64 (const RawFile64 * rawFile, int64_t offset, int whence ) 738``` 739 740**Description** 741 742Searches for the data read/write position in a large rawfile based on the specified offset. 743 744**Since**: 11 745 746**Parameters** 747 748| Name| Description| 749| -------- | -------- | 750| rawFile | Pointer to [RawFile64](#rawfile64).| 751| offset | Specified offset.| 752| whence | Read/Write position. The options are as follows:<br>**0**: The read/write position is the start position of the file plus the offset.<br>**1**: The read/write position is the current position plus the offset.<br>**2**: The read/write position is the end position of the file plus the offset.| 753 754**Returns** 755 756**0** if the search is successful; **-1** otherwise. 757