File packaging method and device and embedded file mapping method and device

By generating file description information and an index table, and combining this with an encryption algorithm to generate version identifiers, the compatibility and version management issues of embedded file systems are resolved. This enables efficient file packaging and access, and improves system reliability and management transparency.

CN120994216APending Publication Date: 2025-11-21SHENZHEN BOSHIJIE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510935542.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-08
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

Existing embedded file systems suffer from a wide variety of packaging tools with inconsistent versions and poor compatibility, resulting in files being unable to be read correctly on the device. Furthermore, traditional file systems consume a lot of resources, have slow access speeds, and lack a unified version management and upgrade mechanism, leading to high upgrade costs and low efficiency.

Method used

By obtaining a list of files to be processed, generating file description information and an index table, generating version identifiers based on encryption algorithms, constructing a packaging framework, generating structured packaged files, and parsing the version identifiers on the device side for file mapping.

Benefits of technology

It enables unified management and distribution of files, improves the repeatability and automation of the packaging process, reduces the risk of human intervention, ensures the integrity of file data and the reliability of the system, simplifies the file access process, and improves real-time performance and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994216A_ABST
    Figure CN120994216A_ABST
Patent Text Reader

Abstract

The invention discloses a file packaging method and device and an embedded file mapping method and device, and aims at solving the technical bottlenecks that in the preset file management and access process of embedded equipment, version management is disordered, the access efficiency is low, data integrity and safety are difficult to guarantee, and the updating and deploying process is complex. According to the method, file description information is uniformly generated, a file index table is constructed, a globally unique version identifier is generated based on context information and a preset encryption algorithm, and finally a binary packaging framework capable of being efficiently analyzed at an embedded end is formed; according to the method, the equipment end can quickly establish a name-offset-length metadata mapping table only by analyzing the file header during starting or updating, and real-time verification and high-speed access of the file are realized, so that the version traceability, the access performance, the data reliability and the updating flexibility of the preset file are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of embedded systems technology, and in particular to a file packaging and embedded file mapping method and apparatus. Background Technology

[0002] Currently, with the increasing intelligence of products, human-computer interaction is becoming increasingly important. In embedded products, voice and display are the main directions of human-computer interaction. Existing embedded file systems generally suffer from a wide variety of packaging tools with inconsistent versions and poor compatibility. Packaging with different tools or versions often results in files being unreadable on the device. At the same time, while traditional file systems are feature-rich, their large code size consumes too much Flash / ROM space, and file traversal and index maintenance also require a large amount of RAM, resulting in low access speed and poor real-time performance. Furthermore, the lack of a unified version management and upgrade mechanism means that each file update requires repackaging and re-adaptation on the terminal side, leading to high upgrade costs and low efficiency, making it difficult to meet the needs of frequent updates to pre-installed files and improved production efficiency. Summary of the Invention

[0003] This invention provides a file packaging and embedded file mapping method and apparatus to improve file mapping efficiency by simplifying the file mapping process.

[0004] To address the aforementioned technical problems, embodiments of the present invention provide a file packaging method, comprising:

[0005] Obtain a list of files to be processed, and generate file description information based on the list of files to be processed and the expected mapping address information;

[0006] Obtain the basic information of each file to be processed in the list of files to be processed, and construct a file index table based on the file description information and the basic information;

[0007] A version identifier is generated based on the context information of the current packaging operation and the preset encryption algorithm, and a packaging framework is generated based on the version identifier and the file index table.

[0008] A packaged file is generated based on the packaging framework, the list of files to be processed, and the expected mapping address information.

[0009] This invention, through a complete process of acquiring a list of files to be processed, generating file description information, constructing a file index table, generating a packaging framework, and generating a packaged file, can systematically integrate fragmented raw file systems into a single, structured packaged file. Its integrated packaging process not only facilitates unified file management and distribution but also records file data and version identifiers during the packaging stage, laying a solid foundation for subsequent rapid parsing and access by the device.

[0010] Furthermore, the step of obtaining the list of files to be processed and generating file description information based on the list of files to be processed and the expected mapping address information includes:

[0011] For all files in the list of files to be processed, sort them in ascending order based on the expected mapping address of each file to obtain the target file list;

[0012] Read the target file list sequentially, including the filename, source path, and expected mapping address of each file in the file;

[0013] File description information entries are generated based on preset field formats, filenames, source paths, and expected mapping addresses. The file description information entries corresponding to each file are then written into the file description list based on the sorting order, thus generating file description information.

[0014] This invention ensures a one-to-one correspondence between the description list and the memory mapping layout by sorting the files in the file list to be processed in ascending order according to the expected mapping address and generating formatted file description information for each file. This guarantees that the file items recorded in the subsequent index table and packaging framework strictly follow the memory address plan, avoiding access errors caused by inconsistent file order or manual entry mistakes. This greatly improves the repeatability and automation level of the entire packaging process, while reducing the risks associated with manual intervention.

[0015] Furthermore, the basic information includes filename, offset value, and file length; the step of obtaining basic information of each file to be processed in the list of files to be processed, and constructing a file index table based on the file description information and the basic information, includes:

[0016] Obtain the file length of each file in the list of files to be processed, and calculate the verification value of the file length based on a preset verification algorithm;

[0017] A file index table is constructed based on the expected mapping address, file length, checksum, file name, and offset value in the file description information.

[0018] This invention adds the reading of each file's length and the calculation of a checksum based on a preset verification algorithm during the index construction phase, thus retaining the information required for data integrity verification within the packaged file. This allows candidate devices to quickly detect the integrity of the data read from the file when mapping and accessing it, thereby promptly identifying potential data corruption during storage or transmission and ensuring the reliability and robustness of the system.

[0019] Furthermore, the step of generating a version identifier based on the context information of the current packaging operation and a preset encryption algorithm, and generating a packaging framework based on the version identifier and the file index table, includes:

[0020] Obtain the context information of the current packaging operation, and determine the timestamp and build sequence number based on the context information;

[0021] A version identifier is generated based on a preset hash algorithm, the timestamp, and the build sequence number;

[0022] A packaging framework is generated based on the preset binary header format, file index table, and version identifier.

[0023] This invention introduces contextual information (timestamp, build sequence number) and combines it with a hash algorithm when generating version identifiers, enabling the generation of a globally unique and tamper-proof version identifier for each packaging operation. This identifier, along with the file index table, is written into the binary header of the packaging framework, allowing the device to accurately determine the version of the loaded pre-installed files during startup or upgrade. If an inconsistency between the old and new versions is detected, an update mechanism is triggered. This mechanism effectively improves the transparency and controllability of pre-installed file management, providing excellent traceability and rollback capabilities for continuous iteration.

[0024] Secondly, this invention provides an embedded file mapping method, including:

[0025] Obtain the packaged file generated by the file packaging method described above;

[0026] The header of the packaged file is parsed to obtain the number of pre-defined files, version identifier, and basic information of each file.

[0027] A mapping table is constructed based on the number of preset files, version identifiers, and basic information of each file;

[0028] Obtain the name of the file to be mapped, match the file to be mapped in the mapping file based on the name of the file to be mapped, obtain the file data of the file to be mapped, and copy the file data to the working buffer to complete the file mapping.

[0029] This invention directly targets packaged files running on embedded terminals. By parsing the file header, it can obtain the pre-defined number of files, version identifiers, and data for each file in one go, and quickly build a mapping table in memory. After applying a name matching and offset mapping mechanism, the device can efficiently copy file content to the working buffer for use by upper-layer applications, even in situations where there is no file system support or the file system is limited. This simplifies the file access process on embedded terminals, significantly reduces implementation complexity in resource-constrained environments, and improves the real-time performance and reliability of file access.

[0030] Thirdly, the present invention provides a file packaging device, comprising: an information acquisition module, an index construction module, a packaging framework generation module, and a packaging module;

[0031] The information acquisition module is used to obtain a list of files to be processed and generate file description information based on the list of files to be processed and the expected mapping address information;

[0032] The index building module is used to obtain the basic information of each file to be processed in the list of files to be processed, and to build a file index table based on the file description information and the basic information;

[0033] The packaging framework generation module is used to generate a version identifier based on the context information of the current packaging operation and a preset encryption algorithm, and to generate a packaging framework based on the version identifier and the file index table.

[0034] The packaging module is used to generate a packaged file based on the packaging framework, the list of files to be processed, and the expected mapping address information.

[0035] Furthermore, the information acquisition module is used to obtain a list of files to be processed, and to generate file description information based on the list of files to be processed and the expected mapping address information, including:

[0036] For all files in the list of files to be processed, sort them in ascending order based on the expected mapping address of each file to obtain the target file list;

[0037] Read the target file list sequentially, including the filename, source path, and expected mapping address of each file in the file;

[0038] File description information entries are generated based on preset field formats, filenames, source paths, and expected mapping addresses. The file description information entries corresponding to each file are then written into the file description list based on the sorting order, thus generating file description information.

[0039] Furthermore, the index building module is used to obtain basic information including filename, offset value, and file length; the step of obtaining basic information of each file to be processed in the list of files to be processed, and building a file index table based on the file description information and the basic information, includes:

[0040] Obtain the file length of each file in the list of files to be processed, and calculate the verification value of the file length based on a preset verification algorithm;

[0041] A file index table is constructed based on the expected mapping address, file length, checksum, file name, and offset value in the file description information.

[0042] Furthermore, the packaging framework generation module is used to generate a version identifier based on the context information of the current packaging operation and a preset encryption algorithm, and to generate a packaging framework based on the version identifier and the file index table, including:

[0043] Obtain the context information of the current packaging operation, and determine the timestamp and build sequence number based on the context information;

[0044] A version identifier is generated based on a preset hash algorithm, the timestamp, and the build sequence number;

[0045] A packaging framework is generated based on the preset binary header format, file index table, and version identifier.

[0046] Fourthly, the present invention provides an embedded file mapping device, comprising: a file receiving module, a parsing module, a mapping table construction module, and a file mapping module;

[0047] The file receiving module is used to acquire the packaged file generated by the file packaging device described above;

[0048] The parsing module is used to parse the header of the packaged file to obtain the preset number of files, version identifier, and basic information of each file;

[0049] The mapping table construction module is used to construct a mapping table based on the preset number of files, version identifier, and basic information of each file.

[0050] The file mapping module is used to obtain the name of the file to be mapped, match the file name in the mapping file, obtain the file data of the file to be mapped, and copy the file data to the working buffer to complete the file mapping. Attached Figure Description

[0051] Figure 1 A schematic flowchart illustrating a file packaging method provided in an embodiment of the present invention;

[0052] Figure 2 This is a flowchart illustrating an embedded file mapping method provided by the present invention;

[0053] Figure 3 A schematic diagram of a file packaging device provided by the present invention;

[0054] Figure 4 This is a schematic diagram of an embedded file mapping device provided by the present invention. Detailed Implementation

[0055] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.

[0056] The terms "first" and "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such processes, methods, products, or apparatus.

[0057] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0058] Example 1

[0059] See Figure 1 , Figure 1 This is a flowchart illustrating a file packaging method according to an embodiment of the present invention. The embodiment of the present invention provides a file packaging method, including steps 101 to 104, as detailed below:

[0060] Step 101: Obtain a list of files to be processed, and generate file description information based on the list of files to be processed and the expected mapping address information;

[0061] In this embodiment, obtaining the list of files to be processed and generating file description information based on the list of files to be processed and the expected mapping address information includes:

[0062] For all files in the list of files to be processed, sort them in ascending order based on the expected mapping address of each file to obtain the target file list;

[0063] Read the target file list sequentially, including the filename, source path, and expected mapping address of each file in the file;

[0064] File description information entries are generated based on preset field formats, filenames, source paths, and expected mapping addresses. The file description information entries corresponding to each file are then written into the file description list based on the sorting order, thus generating file description information.

[0065] In this embodiment, it is assumed that the list of original files to be packaged contains three types of files: firmware image fw.bin (source path / input / fw.bin), configuration file config.json (source path / input / config.json), and resource file logo.bmp (source path / input / logo.bmp), with corresponding expected mapping base addresses of 0x10000, 0x08000, and 0x18000, respectively. First, the packaging tool sorts the three in ascending order according to the expected mapping base address of each file to obtain the target file list: [(config.json, / input / config.json, 0x08000), (fw.bin, / input / fw.bin, 0x10000), (logo.bmp, / input / logo.bmp, 0x18000)]. Then, the tool sequentially reads the filename, source path, and expected mapping base address from each record, and generates corresponding file description information entries according to a predefined field format (e.g., <filename length|filename|path length|path|address (4 bytes)>). Finally, all entries are written sequentially into the "file description list" binary stream or text list according to the above sorting order to form complete file description information for use in downstream index table generation and file header writing.

[0066] In this embodiment, by sorting the files in the file list to be processed in ascending order according to the expected mapping address and generating formatted file description information for each file, a one-to-one correspondence between the description list and the memory mapping layout is ensured. This ensures that the file items recorded in the subsequent index table and packaging framework strictly follow the memory address plan, avoiding access errors caused by inconsistent file order or manual entry mistakes. This greatly improves the repeatability and automation level of the entire packaging process, while reducing the risks associated with manual intervention.

[0067] Step 102: Obtain the basic information of each file to be processed in the list of files to be processed, and construct a file index table based on the file description information and the basic information;

[0068] In this embodiment, the basic information includes filename, offset value, and file length; obtaining the basic information of each file to be processed in the list of files to be processed, and constructing a file index table based on the file description information and the basic information, includes:

[0069] Obtain the file length of each file in the list of files to be processed, and calculate the verification value of the file length based on a preset verification algorithm;

[0070] A file index table is constructed based on the expected mapping address, file length, checksum, file name, and offset value in the file description information.

[0071] In this embodiment, it is assumed that the list of files to be packaged contains two preset files: firmware image fw.bin (source path / input / fw.bin) and configuration file config.json (source path / input / config.json), with expected mapping starting addresses of 0x10000 and 0x08000 respectively. The packaging tool first opens the two files sequentially, reads the file length of fw.bin (e.g., 524288 bytes) and the file length of config.json (e.g., 2048 bytes), and calculates their checksums (e.g., 0xA1 B2C3D4, 0x5E6F7A8B) based on a preset CRC32 checksum algorithm. Subsequently, the tool obtains the corresponding expected mapping address, filename, and offset value from the previously generated file description information, and organizes these parameters together with the file length and CRC32 checksum read just now into an index table entry. Finally, the fw.bin index entry records: filename "fw.bin", Offset = 0x10000, Length = 524288, Checksum = 0xA1 B2C3D4; the config.json index entry records: filename "config.json", Offset = 0x08000, Length = 2048, Checksum = 0x5E6F7A8B. All index entries are filled into the in-memory structure array in ascending order of Offset, completing the construction of the file index table.

[0072] In this embodiment, by adding the reading of the length of each file and the calculation of the checksum based on a preset verification algorithm during the index construction stage, the information required for data integrity verification is retained in the packaged file. This allows candidate devices to quickly detect whether the data read from the file is complete and error-free when mapping and accessing the file, thereby promptly detecting potential data corruption during storage or transmission and ensuring the reliability and robustness of the system operation.

[0073] Step 103: Generate a version identifier based on the context information of the current packaging operation and the preset encryption algorithm, and generate a packaging framework based on the version identifier and the file index table;

[0074] In this embodiment, the step of generating a version identifier based on the context information of the current packaging operation and a preset encryption algorithm, and generating a packaging framework based on the version identifier and the file index table, includes:

[0075] Obtain the context information of the current packaging operation, and determine the timestamp and build sequence number based on the context information;

[0076] A version identifier is generated based on a preset hash algorithm, the timestamp, and the build sequence number;

[0077] A packaging framework is generated based on the preset binary header format, file index table, and version identifier.

[0078] In this embodiment, at the start of a packaging operation, the packaging tool first reads the current timestamp (e.g., "2025-06-27T20:15:32Z") and the build sequence number (e.g., the 42nd packaging) from the build environment, and concatenates the two into the string "20250627_201532_042" in a fixed format; then, the tool uses a preset SHA-256 hash algorithm to calculate the hash value of the string, obtaining a 32-byte binary digest (e.g., 0x3F7A1). The tool writes the version identifier (C…E9BD) as hexadecimal text. Then, it constructs the packaging framework according to the predefined binary header format: first, it writes the 4-byte magic number 0x504B4746 (“PKGF”), then the 2-byte version identifier length (e.g., 0x0020), then the SHA-256 hash text (32 bytes) mentioned above, followed by the 4-byte total length of the file index table and its contents (each index entry contains the file name length, file name, offset, length, and checksum in sequence), finally forming a binary packaging framework header containing the version identifier and the complete file index table, which is then used by downstream users to write specific file data and deploy it to embedded devices.

[0079] In this embodiment, by introducing contextual information (timestamp, build sequence number) and combining it with a hash algorithm when generating the version identifier, a globally unique and tamper-proof version identifier can be generated for each packaging operation. This identifier, along with the file index table, is written into the binary header of the packaging framework, enabling the device to accurately determine the version of the loaded pre-built files during startup or upgrade. If an inconsistency between the old and new versions is detected, an update mechanism can be triggered. This mechanism effectively improves the transparency and controllability of pre-built file management, providing excellent traceability and rollback capabilities for continuous iteration.

[0080] Step 104: Generate a packaged file based on the packaging framework, the list of files to be processed, and the expected mapping address information.

[0081] In this embodiment, after constructing the packaging framework header, the packaging tool first writes the header into the beginning of the output file in binary format. Then, the tool iterates through each file entry in the file list to be processed, locates the corresponding write offset in the output file based on the expected mapping start address recorded in the file description information, and sequentially writes all binary data blocks of that file. For address gaps between adjacent files, the tool fills the blank areas according to a preset padding strategy (e.g., all-zero padding or repeated last byte padding) to ensure that the file data is accurately mapped to the specified memory layout. After all file data is written, the tool can optionally perform a full verification of the entire output file (e.g., recalculate CRC32 or SHA-256) and compare the verification result with the index table in the packaging framework to verify the integrity and correctness of the write operation. The final packaged file contains the version identifier and index table in the header, and the pre-set file data laid out according to the expected mapping address. It can be directly deployed to the Flash area of ​​the embedded device for on-demand, fast memory mapping and access by the device.

[0082] In this embodiment, by completing the entire process of obtaining a list of files to be processed, generating file description information, constructing a file index table, generating a packaging framework, and generating a packaged file, the scattered raw file system can be systematically integrated into a single, structured packaged file. This integrated packaging process not only facilitates unified file management and distribution but also records file data and version identifiers during the packaging stage, laying a solid foundation for subsequent rapid parsing and access by the device.

[0083] Please refer to Figure 2 , Figure 2 A flowchart illustrating an embedded file mapping method provided by the present invention includes steps 201 to 204, as detailed below:

[0084] Step 201: Obtain the packaged file generated by the file packaging method described above;

[0085] Step 202: Parse the header of the packaged file to obtain the number of preset files, version identifier, and basic information of each file;

[0086] Step 203: Construct a mapping table based on the number of preset files, version identifiers, and basic information of each file;

[0087] Step 204: Obtain the name of the file to be mapped, match the file to be mapped in the mapping file based on the name of the file to be mapped, obtain the file data of the file to be mapped, and copy the file data to the working buffer to complete the file mapping.

[0088] In this embodiment, it is assumed that the device burns the packaged file (containing 3 preset files) to the Flash starting address 0x0000_0000. Upon startup, the embedded program executes step 201, reads and parses the first 512 bytes of the file header from Flash, and obtains the number of preset files (e.g., 3), version identifier (e.g., "20250627_0423_ab12cd34") and basic information of each file (name, offset address, length, check value); step 202 constructs a mapping table in RAM in the form of a structure array (e.g., FileEntryentries[3]); step 203 establishes a hash or linear lookup index of name→entries[i] based on the mapping table; when the upper layer business needs to access "config.json", step 204 is executed, the file name "config.json" is passed in and matched in the mapping table, its offset address (e.g., 0x0001_0000) and length (e.g., 2048 bytes) are obtained, and then the data in the range is copied from the corresponding address window of Flash to the RAM working buffer; after completion, the CRC check module can be called to compare the copied data with the check value recorded in the mapping table to ensure file integrity, and finally return the buffer pointer for direct access by the business logic.

[0089] Please refer to Figure 3 , Figure 3 A schematic diagram of a file packaging device provided by the present invention includes: an information acquisition module 301, an index construction module 302, a packaging framework generation module 303, and a packaging module 304;

[0090] The information acquisition module 301 is used to acquire a list of files to be processed and generate file description information based on the list of files to be processed and the expected mapping address information.

[0091] The index building module 302 is used to obtain the basic information of each file to be processed in the file list to be processed, and to build a file index table based on the file description information and the basic information.

[0092] The packaging framework generation module 303 is used to generate a version identifier based on the context information of the current packaging operation and a preset encryption algorithm, and to generate a packaging framework based on the version identifier and the file index table.

[0093] The packaging module 304 is used to generate a packaged file based on the packaging framework, the list of files to be processed, and the expected mapping address information.

[0094] In this embodiment, the information acquisition module is used to obtain a list of files to be processed, and to generate file description information based on the list of files to be processed and the expected mapping address information, including:

[0095] For all files in the list of files to be processed, sort them in ascending order based on the expected mapping address of each file to obtain the target file list;

[0096] Read the target file list sequentially, including the filename, source path, and expected mapping address of each file in the file;

[0097] File description information entries are generated based on preset field formats, filenames, source paths, and expected mapping addresses. The file description information entries corresponding to each file are then written into the file description list based on the sorting order, thus generating file description information.

[0098] In this embodiment, the index building module is used to obtain basic information including filename, offset value, and file length; the step of obtaining basic information of each file to be processed in the file to be processed list and building a file index table based on the file description information and the basic information includes:

[0099] Obtain the file length of each file in the list of files to be processed, and calculate the verification value of the file length based on a preset verification algorithm;

[0100] A file index table is constructed based on the expected mapping address, file length, checksum, file name, and offset value in the file description information.

[0101] In this embodiment, the packaging framework generation module is used to generate a version identifier based on the context information of the current packaging operation and a preset encryption algorithm, and to generate a packaging framework based on the version identifier and the file index table, including:

[0102] Obtain the context information of the current packaging operation, and determine the timestamp and build sequence number based on the context information;

[0103] A version identifier is generated based on a preset hash algorithm, the timestamp, and the build sequence number;

[0104] A packaging framework is generated based on the preset binary header format, file index table, and version identifier.

[0105] Please refer to Figure 4 , Figure 4 A schematic diagram of an embedded file mapping device provided by the present invention includes: a file receiving module 401, a parsing module 402, a mapping table construction module 403, and a file mapping module 404;

[0106] The file receiving module 401 is used to obtain the packaged file generated by the file packaging device described above.

[0107] The parsing module 402 is used to parse the file header of the packaged file to obtain the preset number of files, version identifier and basic information of each file;

[0108] The mapping table construction module 403 is used to construct a mapping table based on the preset number of files, version identifier, and basic information of each file.

[0109] The file mapping module 404 is used to obtain the name of the file to be mapped, match the file to be mapped in the mapping file based on the name of the file to be mapped, obtain the file data of the file to be mapped, and copy the file data to the working buffer to complete the file mapping.

[0110] In this embodiment of the invention, a terminal device is also provided, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the above-described file packaging method.

[0111] In this embodiment of the invention, a computer-readable storage medium is also provided, which includes a stored computer program, wherein the computer program controls the device where the computer-readable storage medium is located to execute the above-described file packaging method when it is running.

[0112] For example, a computer program can be divided into one or more modules, one or more of which are stored in memory and executed by a processor to perform the present invention. The one or more modules can be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in a terminal device.

[0113] The terminal device may be a desktop computer, laptop, handheld computer, or cloud server, etc. The terminal device may include, but is not limited to, a processor, memory, and display. Those skilled in the art will understand that the above components are merely examples of terminal devices and do not constitute a limitation on the terminal device. It may include more or fewer components, or combinations of certain components, or different components. For example, the terminal device may also include input / output devices, network access devices, buses, etc.

[0114] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting all parts of the terminal device through various interfaces and lines.

[0115] Memory can be used to store computer programs and / or modules. The processor implements various functions of the terminal device by running or executing the computer programs and / or modules stored in the memory, and by accessing data stored in the memory. Memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system, application programs required for at least one function (such as sound playback, text conversion, etc.), etc.; the data storage area can store data created based on the use of the mobile phone (such as audio data, text message data, etc.). In addition, memory can include high-speed random access memory, and can also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart media cards (SMC), secure digital cards (SD cards), flash cards, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.

[0116] Wherein, if the module based on file packaging is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. Those skilled in the art can understand and implement this without any inventive effort.

[0117] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.

Claims

1. A method for packaging files, characterized in that, include: Obtain a list of files to be processed, and generate file description information based on the list of files to be processed and the expected mapping address information; Obtain the basic information of each file to be processed in the list of files to be processed, and construct a file index table based on the file description information and the basic information; A version identifier is generated based on the context information of the current packaging operation and the preset encryption algorithm, and a packaging framework is generated based on the version identifier and the file index table. A packaged file is generated based on the packaging framework, the list of files to be processed, and the expected mapping address information.

2. The file packaging method as described in claim 1, characterized in that, The step of obtaining the list of files to be processed and generating file description information based on the list of files to be processed and the expected mapping address information includes: For all files in the list of files to be processed, sort them in ascending order based on the expected mapping address of each file to obtain the target file list; Read the target file list sequentially, including the filename, source path, and expected mapping address of each file in the file; File description information entries are generated based on preset field formats, filenames, source paths, and expected mapping addresses. The file description information entries corresponding to each file are then written into the file description list based on the sorting order, thus generating file description information.

3. The file packaging method as described in claim 2, characterized in that, The basic information includes filename, offset value, and file length; obtaining the basic information of each file to be processed in the list of files to be processed, and constructing a file index table based on the file description information and the basic information, includes: Obtain the file length of each file in the list of files to be processed, and calculate the verification value of the file length based on a preset verification algorithm; A file index table is constructed based on the expected mapping address, file length, checksum, file name, and offset value in the file description information.

4. The file packaging method as described in claim 3, characterized in that, The process of generating a version identifier based on the context information of the current packaging operation and a preset encryption algorithm, and generating a packaging framework based on the version identifier and the file index table, includes: Obtain the context information of the current packaging operation, and determine the timestamp and build sequence number based on the context information; A version identifier is generated based on a preset hash algorithm, the timestamp, and the build sequence number; A packaging framework is generated based on the preset binary header format, file index table, and version identifier.

5. An embedded file mapping method, characterized in that, include: Obtain the packaged file generated by the file packaging method as described in any one of claims 1 to 4; The header of the packaged file is parsed to obtain the number of pre-defined files, version identifier, and basic information of each file. A mapping table is constructed based on the number of preset files, version identifiers, and basic information of each file; Obtain the name of the file to be mapped, match the file to be mapped in the mapping file based on the name of the file to be mapped, obtain the file data of the file to be mapped, and copy the file data to the working buffer to complete the file mapping.

6. A document packaging device, characterized in that, include: Information collection module, index building module, packaging framework generation module, and packaging module; The information acquisition module is used to obtain a list of files to be processed and generate file description information based on the list of files to be processed and the expected mapping address information; The index building module is used to obtain the basic information of each file to be processed in the list of files to be processed, and to build a file index table based on the file description information and the basic information; The packaging framework generation module is used to generate a version identifier based on the context information of the current packaging operation and a preset encryption algorithm, and to generate a packaging framework based on the version identifier and the file index table. The packaging module is used to generate a packaged file based on the packaging framework, the list of files to be processed, and the expected mapping address information.

7. A document packaging device as described in claim 6, characterized in that, The information acquisition module is used to obtain a list of files to be processed, and generate file description information based on the list of files to be processed and the expected mapping address information, including: For all files in the list of files to be processed, sort them in ascending order based on the expected mapping address of each file to obtain the target file list; Read the target file list sequentially, including the filename, source path, and expected mapping address of each file in the file; File description information entries are generated based on preset field formats, filenames, source paths, and expected mapping addresses. The file description information entries corresponding to each file are then written into the file description list based on the sorting order, thus generating file description information.

8. A document packaging device as described in claim 7, characterized in that, The index building module is used to obtain basic information, including filename, offset value, and file length; the step of obtaining basic information of each file to be processed in the list of files to be processed, and building a file index table based on the file description information and the basic information, includes: Obtain the file length of each file in the list of files to be processed, and calculate the verification value of the file length based on a preset verification algorithm; A file index table is constructed based on the expected mapping address, file length, checksum, file name, and offset value in the file description information.

9. A document packaging device as described in claim 8, characterized in that, The packaging framework generation module is used to generate a version identifier based on the context information of the current packaging operation and a preset encryption algorithm, and to generate a packaging framework based on the version identifier and the file index table, including: Obtain the context information of the current packaging operation, and determine the timestamp and build sequence number based on the context information; A version identifier is generated based on a preset hash algorithm, the timestamp, and the build sequence number; A packaging framework is generated based on the preset binary header format, file index table, and version identifier.

10. An embedded file mapping device, characterized in that, include: The module includes a file receiving module, a parsing module, a mapping table construction module, and a file mapping module. The file receiving module is used to acquire the packaged file generated by the file packaging device as described in any one of claims 6 to 9; The parsing module is used to parse the header of the packaged file to obtain the preset number of files, version identifier, and basic information of each file; The mapping table construction module is used to construct a mapping table based on the preset number of files, version identifier, and basic information of each file. The file mapping module is used to obtain the name of the file to be mapped, match the file name in the mapping file, obtain the file data of the file to be mapped, and copy the file data to the working buffer to complete the file mapping.