File processing method and apparatus, and electronic device and storage medium
By combining multiple pending files of the target program into one target file and generating resource query files for compression, the problem of low file compression rate in the prior art is solved, and higher compression rate and program stability are achieved.
Patent Information
- Application Number
- PCT/CN2024/127141
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-05
- Filing Date
- 2024-10-24
- Publication Date
- 2025-06-12
AI Technical Summary
When compressing multiple files in the prior art, there is redundancy in compressed data, resulting in the problem of low compression rate.
By obtaining at least two pending files of the target program, combining them into one target file, and generating a resource query file based on the file association information of each pending file, compressing the target file and resource query file to obtain the target resource file corresponding to the target program.
Improve file compression rate, while ensuring the stability of program operation and ensuring the normal operation of target programs.
Smart Images

Figure CN2024127141_12062025_PF_FP_ABST
Abstract
Description
File processing method, device, electronic device and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed on December 5, 2023, with application number 202311659342.X and invention name “File processing method, device, electronic device and storage medium”. The entire contents of that application are incorporated by reference into this application. Technical Field
[0003] The embodiments of the present disclosure relate to the field of data processing technology, and in particular to a file processing method, device, electronic device, and storage medium. Background Art
[0004] In the prior art, when compressing multiple files, they are usually compressed based on the ZIP compression method. This method uses a single file as the compression object and compresses each file separately. There is redundancy in the compressed data, which leads to a low compression rate.
[0005] Summary of the Invention
[0006] The present disclosure provides a file processing method, device, electronic device and storage medium to improve the file compression rate while achieving the effect of improving the stability of program operation.
[0007] In a first aspect, an embodiment of the present disclosure provides a file processing method, the method comprising:
[0008] Obtain at least two files to be processed of the target program;
[0009] Merging the at least two to-be-processed files into one target file, and generating a resource query file based on file association information of each to-be-processed file;
[0010] The target resource file corresponding to the target program is obtained by compressing the target file and the resource query file.
[0011] In a second aspect, an embodiment of the present disclosure further provides a file processing device, the device comprising:
[0012] A file acquisition module, used to acquire at least two to-be-processed files of a target program;
[0013] A file processing module, configured to merge the at least two files to be processed into one target file, and generate a resource query file based on the file association information of each file to be processed;
[0014] The target resource file generating module is used to obtain a target resource file corresponding to the target program by compressing the target file and the resource query file.
[0015] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0016] one or more processors;
[0017] a storage device for storing one or more programs,
[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement the file processing method as described in any one of the embodiments of the present disclosure.
[0019] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to execute the file processing method as described in any one of the embodiments of the present disclosure.
[0020] The technical solution of the embodiment of the present disclosure obtains at least two to-be-processed files of the target program, merges the at least two to-be-processed files into one target file, generates a resource query file based on the file association information of each to-be-processed file, compresses the target file and the resource query file, and obtains a target resource file corresponding to the target program. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0022] FIG1 is a flow chart of a file processing method provided by an embodiment of the present disclosure;
[0023] FIG2 is a flow chart of another file processing method provided by an embodiment of the present disclosure;
[0024] FIG3 is a flow chart of another file processing method provided by an embodiment of the present disclosure;
[0025] FIG4 is a schematic diagram illustrating a storage method for file association information provided by an embodiment of the present disclosure;
[0026] FIG5 is a flow chart of another file processing method provided by an embodiment of the present disclosure;
[0027] FIG6 is a schematic structural diagram of a file processing device provided by an embodiment of the present disclosure;
[0028] FIG7 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0029] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0030] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0031] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0032] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0033] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0034] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0035] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) must comply with the requirements of relevant laws, regulations and relevant provisions.
[0036] Before introducing this technical solution, we will first provide an example application scenario. This technical solution can be applied to any scenario where multiple files need to be merged. For example, when running an application, the application must first be compiled and then the compiled project files must be packaged into a file that can be recognized by the system before the application can be run on the system. Merging multiple files can be achieved based on the technical solution of the embodiments of this disclosure.
[0037] Figure 1 is a flow chart of a file processing method provided by an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to any scenario where multiple files need to be merged. The method can be executed by a file processing device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, a PC or a server, etc.
[0038] As shown in FIG1 , the method of this embodiment may specifically include:
[0039] S110: Obtain at least two to-be-processed files of the target program.
[0040] The target program can be an application developed under any system. For example, the target program can be an application of a certain software (e.g., video software, music software, etc.). The to-be-processed file is a file related to running the target program. For example, the to-be-processed file can be a configuration file used to store and manage configuration information of the target program, such as database connection information, log configuration, system parameters, and other configuration information; or the to-be-processed file can also be a file used to define the structure and model of data, such as various fields and attributes of a defined data model.
[0041] In this embodiment, the target program may be compiled using a compiler or editing code. During the compilation of the target program, at least two to-be-processed files required for running the target program may be obtained through an interface.
[0042] In this embodiment, obtaining at least two to-be-processed files of the target program includes: obtaining at least two to-be-processed files in a target directory related to the target program.
[0043] The file to be processed is a binary file.
[0044] In actual applications, when compiling a target program, multiple files to be processed are generated. These files are compiled binary files and stored in a target directory associated with the target program. Therefore, all the files to be processed can be retrieved from this target directory. The file format of these files to be processed corresponds to the target program. To ensure the accuracy of file retrieval, a corresponding preset format can be predefined based on the target program. For example, if the target program is an Android application, the preset format can be XML (Extensible Markup Language) format. Accordingly, the files to be processed are XML-formatted files, which can be composed of multiple parts. For example, the files to be processed can contain information such as attributes, entities, comments, references, character data segments, start tags, end tags, and document type declarations. If the target program is an iOS application, the preset format can be IPA (iPhone Application) format. In this way, the files to be processed in the preset format corresponding to the target program can be retrieved from the target directory associated with the target program.
[0045] For example, taking an APK program as an example, there are multiple XML format files in the layout directory of the APK program. The layout directory can be used as the target directory to obtain all XML format files from the layout directory, that is, all the files to be processed are obtained.
[0046] S120: Merge at least two to-be-processed files into one target file, and generate a resource query file based on file association information of each to-be-processed file.
[0047] The file association information may be corresponding to the file to be processed. For example, the file association information of a file to be processed may include but is not limited to the file name, file type, file length, file size, file storage path, compression method, etc.
[0048] In this embodiment, a file can be created, and the file contents of all pending files can be copied to this created file to obtain a target file. This allows subsequent compression to be performed on each pending file separately for each target file, thereby achieving an improved compression ratio. At the same time, to ensure that the contents of a pending file can be found within the compressed file when the target program is running, another file can be created to save the file association information of each pending file to this created file, generating a resource query file so that the file contents can be subsequently found within the compressed file using the contents of the resource query file.
[0049] For example, after finding all the files to be used, a new file merge_layout is created, and all the binary files in the layout directory are merged into merge_layout, and the merged file is used as the target file.
[0050] S130 , obtaining a target resource file corresponding to the target program by compressing the target file and the resource query file.
[0051] In this embodiment, compression technology (such as ZIP compression technology) can be used to compress the target file and resource query file to generate a compressed file. This file is the target resource file corresponding to the target program. When the target program is subsequently run, the text content in the target resource file can be decompressed and read to enable the target program to run normally, thereby ensuring the stability of the program operation.
[0052] In this embodiment, in order to reduce memory consumption, at least two files to be processed can be deleted before the target file and the resource query file are compressed. In this way, when the target program is running, there are no individual files to be processed, but only one target file placed in the target directory. For example, after the Merged Resources task (i.e., the resource merging task), all the original large number of small layout files can be deleted. In order to ensure that the merged file can be accurately obtained when the target program is running, the target file needs to be placed in the target directory. It is also necessary to add the target resource file to the resource directory corresponding to the target program after obtaining the target resource file to ensure that the merged file content can be accurately obtained from the target resource file.
[0053] The technical solution of the embodiment of the present disclosure obtains at least two to-be-processed files of the target program, and then merges the at least two to-be-processed files into one target file. Based on the file association information of each to-be-processed file, a resource query file is generated, and the target file and the resource query file are compressed to obtain a target resource file corresponding to the target program. This solves the problem of compressing each file separately in the related art, resulting in a low file compression rate. During the compilation of the target program, at least two to-be-processed files of the target program are merged into one target file, thereby reducing the file size. At the same time, a resource query file is generated based on the file association information of each to-be-processed file, and then the target file and the resource query file are compressed to improve the file compression rate by compressing one target file. At the same time, it can also ensure that when the target file content in the target resource file is subsequently read, the file content can be accurately obtained by parsing the resource query file in the target resource file, thereby ensuring the stability of the program operation and ensuring that the target program can operate normally.
[0054] FIG2 is a flow chart of another file processing method provided by an embodiment of the present disclosure. The technical solution of this embodiment further refines S120 based on the above embodiment. The technical features that are the same or similar to those of the above embodiment are not repeated here.
[0055] As shown in FIG2 , the method of this embodiment may specifically include:
[0056] S210: Obtain at least two to-be-processed files of the target program.
[0057] S220: Create a target file in the target directory, and merge the file contents of at least two to-be-processed files into the target file based on the resource merging task.
[0058] In this embodiment, to ensure that the merged file is available when the program is running, a new file can be created in the target directory and used as the target file. Furthermore, a pre-set resource merge task can be used to merge all pending files into this target file, placing the target file in the target directory. This allows compression to be performed using only the target file in the target directory, avoiding the need to compress all pending files separately, thereby improving the compression ratio.
[0059] S230: Determine file association information of the file to be processed according to the file attributes of the file to be processed and the file attributes of the merged files in the target file.
[0060] The merged file is a file in at least two files to be processed.
[0061] In order to ensure that the merged file content can be accurately obtained when the target program is run, the file association information of each to-be-processed file needs to be determined. In this embodiment, the implementation method of determining the file association information of each to-be-processed file is the same, and the file association information of any to-be-processed file can be used as an example for introduction.
[0062] Specifically, during the process of merging the to-be-processed file into the target file, the file attributes of the to-be-processed file (e.g., file attributes including but not limited to file size, file type, file name, the order in which the file was merged into the target file, file path, etc.) can be determined, and the file attributes can be used as the file association information of the to-be-processed file. Furthermore, the position of the incoming to-be-processed file in the target file can be determined in combination with the file attributes of the merged files in the incoming target file, and the position can also be used as the file association information of the to-be-processed file, so that the specific file content can be subsequently read from the compressed file through the file association information.
[0063] It should be noted that the above S220 to S30 can be executed sequentially or in parallel, and the specific execution order is not limited. The above order is only the order for explaining the technical solutions in each step, not the execution order of each step.
[0064] S240: Generate a resource query file based on the file association information.
[0065] The resource query file is a file created in the target directory.
[0066] Specifically, a new file may be created in the target directory, and the file association information may be stored in the file according to a preset structure to obtain a resource query file. When parsing the resource query file, the file format may be used for parsing.
[0067] S250: Obtain a target resource file corresponding to the target program by compressing the target file and the resource query file.
[0068] The technical solution of the disclosed embodiment creates a target file in a target directory and uses a resource merging task to merge the file contents of at least two to-be-processed files into a single target file. This removes duplicate character strings between the to-be-processed files, reduces file size, and thus improves the file compression ratio. Furthermore, based on the file attributes of the to-be-processed files and the attributes of the merged files within the target file, the file association information of the to-be-processed files is determined. A resource query file is then generated based on this file association information, ensuring that the contents of the compressed files can subsequently be accurately and effectively read from the contents of the resource query file, thereby improving program performance.
[0069] FIG3 is a flow chart of another file processing method provided by an embodiment of the present disclosure. The technical solution of this embodiment is based on the above-mentioned embodiment. File attributes include file length and file name. Furthermore, file association information for the file to be processed can be determined based on the file length and file name of the file to be processed and the file length and file name of the merged files in the target file. Technical features identical or similar to those of the above-mentioned embodiments are not further described here.
[0070] As shown in FIG3 , the method of this embodiment may specifically include:
[0071] S310: Obtain at least two to-be-processed files of the target program.
[0072] S320: Create a target file in the target directory, and merge the file contents of at least two to-be-processed files into the target file based on the resource merging task.
[0073] S330: Determine the offset value of the file to be processed based on the file length of the merged file.
[0074] In this embodiment, in order to be able to find the contents of individual files within the target file when the target program is running, the location where the files to be processed are placed within the target file can be recorded during the file merging process. Specifically, the file lengths of all merged files within the target file can be used as offset values for placing the files to be processed within the target file, with the offset values used to indicate the location where the files to be processed are placed within the target file. Optionally, file length can be expressed in two ways: in characters or in bytes.
[0075] For example, when a file to be processed is placed in a target file, the file length of the file to be processed can be recorded. If the file to be processed is the first file to be placed in the target file, the file length of the merged file in the target file is 0, and the offset value of the file to be processed is 0. If the file to be processed is the second file to be placed in the target file, the offset value of the file to be processed can be the string length of all merged files in the target file, and the offset value and file length of the file to be processed in the merged file are recorded, so that the specific content of the compressed file can be obtained through the offset value and file length when the target resource file is subsequently read.
[0076] S340: Determine a file identifier and at least one file path value corresponding to the file to be processed according to the file name.
[0077] In this embodiment, the file name of the file to be processed can also be recorded. For example, the name of the file to be processed 1 is activity_lib1; the name of the file to be processed 2 is activity_main. Furthermore, when the file name of the file to be processed is identified, a file identifier for identifying the file to be processed can be determined, so that the corresponding file can be found through the file identifier. For example, the file name can be used as the file identifier of the file, or the file identifier of each file to be processed can be determined by a preset identifier generation method (such as a random, sequential, etc. generation method).
[0078] Considering that there may be multiple versions of a file to be processed, each version corresponds to a different file path. For example, for a layout file with multiple versions, multiple files are subdivided under it (such as layout-v21, layout-v24, etc.) corresponding to different versions. In the case of multiple versions, different files to be processed share file identifiers. At this time, they can be distinguished by the file path name to ensure the uniqueness of each file and the accuracy of file search. The file path of the file to be processed can be recorded as the file path value. If a file to be processed has one version, then the file to be processed corresponds to one file path value. If a file to be processed has multiple versions, then the file paths of different version files under the file to be processed can be recorded as file path values, that is, the file to be processed corresponds to multiple file path values.
[0079] S350: Use the file name, file identifier, file length, at least one file path value, and offset value as file association information of the file to be processed.
[0080] Specifically, taking a certain file to be processed as an example, the file name, file identifier, file length, at least one file path value and offset value of the file to be processed can all be used as file association information of the file to be processed, so that when reading the target file, the corresponding file can be found from it through the file association information of the file.
[0081] S360: Generate a resource query file based on the file association information.
[0082] In order to minimize the size of the merged file, the entire storage logic can be flattened to reduce structured information. For example, the offset value and file length are used to mark the start and end of the content of the file to be processed, and the offset value and file length are stored in the header of the file. At the same time, the file identifier and file path value corresponding to the file to be processed are also stored to generate a resource query file.
[0083] In this embodiment, a resource query file is generated based on file association information, including: if at least one file path value is a first preset number, then based on the file identifier, file length and offset value in the file association information, the file content in the resource query file is determined; if at least one file path value is a second preset number, then based on the file identifier, file path value, file length and offset value in the file association information, the file content in the resource query file is determined.
[0084] In practical applications, based on the number of file path values corresponding to each file to be processed, it can be determined in which format to store the file association information of the file to be processed. Specifically, if the number of file path values corresponding to the file to be processed is the first preset number (such as 1), then the file identifier, file length, and offset value in the file association information of the file to be processed can be stored in the resource query file. If the number of file path values corresponding to the file to be processed reaches the second preset number (such as 2), then the file path value, file length, and offset value in the file association information of the file to be processed can be stored in the resource query file.
[0085] Exemplarily, referring to FIG. 4, for a file with only one file path value, the storage format of the file association information of the file to be processed can be: <file identifier, <offset value, file length>>, such as: <layout_id_1, <offset value, file length>>, <layout_id_2, <offset value, file length>>. For a file with multiple file path values, the storage format of the file association information of the file to be processed can be: <file path value, <offset value, file length>>, such as: <file path value_n1, <offset value, file length>>, <file path value_n2, <offset value, file length>>. The advantage of this setting is that by selecting the corresponding storage format according to the number of file path values of the file to be processed to mark the file information to be processed, not only can the running speed and stability be improved when reading and parsing the target file, but also multiple versions of the file to be processed can be merged into the target file.
[0086] S370. By performing compression processing on the target file and the resource query file, a target resource file corresponding to the target program is obtained.
[0087] The technical solution of the embodiment of the present disclosure determines the offset value of the file to be processed based on the file length of the merged file, and uses the offset value to reflect the position of the file to be processed in the target file, ensuring the correctness and accuracy of file content reading. At the same time, according to the file name, the file identifier and at least one file path value corresponding to the file to be processed are determined, so that the file to be processed can be identified by the file identifier or the file path value, ensuring the accuracy of file search. Further, the file name, file identifier, file length, at least one file path value, and offset value are used as the file association information of the file to be processed to generate a resource query file, ensuring that the content of the compressed file can be read through the content in the resource query file later, and ensuring that the program can run normally.
[0088] FIG5 is a flow chart illustrating another file processing method provided by an embodiment of the present disclosure. The technical solution of this embodiment, based on the above-described embodiment, further includes reading a target resource file when running a target program and decompressing the target resource file to obtain the compressed target file content within the target resource file. Technical features identical or similar to those of the above-described embodiments are not further described herein.
[0089] As shown in FIG5 , the method of this embodiment may specifically include:
[0090] S410 : When running the target program, read the target resource file based on the target function.
[0091] It should be noted that when running the target program, the merged files need to be read. All files are parsed through the system API LayoutInflater.from(this).inflate(R.layout.layout_xxx, null). The system API inflate() method needs to be called. The system API can be analyzed first to determine the availability of the API. Under the condition that the API is available, the target resource file can be read.
[0092] In this embodiment, when the target program is running, the target resource file can be read from the resource directory by calling the target function. Optionally, the target function can be getResource. Exemplarily, the getResources() call point can be hooked, the getResources() method can be reimplemented to return a customized resources class, and the getlayout() method can be overridden to return a new XmlResourceParser, completing the customized parsing of the target resource file. Alternatively, the original mResources can be replaced with a customized resources class through reflection, and the getLayout() method can be overridden to return an XmlResourceParser.
[0093] In order to ensure the integrity and correctness of the data, the current check value of the target resource file can be determined before reading the target resource file based on the target function when running the target program; when the current check value is the same as the standard check value of the target resource file generated after the merger, the target resource file is read based on the target function.
[0094] Specifically, when generating the target resource file, a checksum algorithm can be used to generate a standard checksum corresponding to the target resource file, and the standard checksum is added to the file header. Optionally, the checksum algorithm can be CRC32 (Cyclic Redundancy Check) and MD5 (Message Digest Algorithm). Before reading the target resource file based on the target function, the checksum algorithm can be used to calculate the checksum corresponding to the target resource file as the current checksum. Furthermore, the current checksum and the standard checksum can be checked. There are many ways to check. For example, one method can be: comparing the current checksum with the standard checksum. If the current checksum is the same as the standard checksum, it means that the checksum has passed. Another method can be: processing the current checksum and the standard checksum based on preset logic. If the processing result is within a preset range, it can be considered that the checksum has passed. Furthermore, under the condition that the checksum passes, the target function can be called to read the target resource file to ensure the correctness and integrity of the data, thereby improving the stability of the program during runtime.
[0095] It should be noted that the resource query file includes file association information for each file to be processed, and the file association information includes a file identifier and / or a file path value, an offset value, and a file length. When reading the target resource file based on the target function, corresponding parameters, such as a file identifier and / or a file path value, can be passed into the target function, so that the file association information of the corresponding file can be found from the resource query file in the target resource file through the parameter information in the target function, and the specific content can be read from the target resource file through the file association information.
[0096] In this embodiment, reading the target resource file based on the target function includes: reading the resource query file in the target resource file based on the file identifier or file path value in the target function.
[0097] Specifically, the resource query file in the target resource file can be read by parsing the file identifier or file path value in the target function, so that the corresponding offset value and file length can be found in the resource query file through the file identifier or file path value, ensuring that the specific content can be accurately read from the target resource file, thereby ensuring the stability of program operation.
[0098] S420: Obtain the compressed target file content in the target resource file based on the resource query file in the target resource file.
[0099] In this embodiment, in the process of querying a file based on the resources in the target resource file to obtain the compressed target file content in the target resource file, the offset value and the file length can be determined based on the file identifier or the file path value; and the target file content can be read based on the offset value and the file length.
[0100] Specifically, the associated offset value and file length can be found through the file identifier or the file path value. For example, through file identifier 1, <file identifier 1, <offset value A, file length B>> can be found; through file path value a / b, <a / b, <offset value C, file length D>> can be found. Further, the target file content can be read according to <offset value, file length>. For example, the position in the target file in the target resource file can be located through the offset value, and taking this position as the starting read position, the file content corresponding to the file length is read, that is, the target file content is read. After the target file content is read, subsequent page rendering operations can be performed.
[0101] Exemplarily, the target resource file in the resource directory can be read, decompressed, and then according to the file identifier, or the file path value is obtained through the file identifier, the corresponding <offset value, file length> can be found at the head of the resource query file. Then, the target file content is read according to the offset value. The advantage of this setting is that it can accurately and effectively find the required content in the compressed target file through the file identifier or the file path value, improving the program running speed and operation stability at the same time.
[0102] The technical solution of the embodiment of the present disclosure reads the target resource file using the target function when running the target program, and then obtains the compressed target file content from the target resource file based on the resource query file in the target resource file, improving the efficiency and accuracy of file content acquisition.
[0103] FIG. 6 is a schematic structural diagram of a file processing device provided by an embodiment of the present disclosure. As shown in FIG. 6, the device includes: a file acquisition module 510, a file processing module 520, and a target resource file generation module 530.
[0104] Among them, the file acquisition module 510 is used to acquire at least two files to be processed of the target program; the file processing module 520 is used to merge the at least two files to be processed into a target file, and generate a resource query file based on the file association information of each file to be processed; the target resource file generation module 530 is used to obtain a target resource file corresponding to the target program through compression processing of the target file and the resource query file.
[0105] On the basis of the above-mentioned optional technical solutions, optionally, the file acquisition module 510 is specifically configured to acquire at least two to-be-processed files in a target directory related to the target program; wherein the to-be-processed files are binary files.
[0106] Based on the above optional technical solutions, optionally, the file processing module 520 includes a file processing unit and a resource query file generating unit.
[0107] A file processing unit is configured to create a target file in a target directory and merge the file contents of the at least two files to be processed into the target file based on a resource merging task; and to determine file association information of the file to be processed based on file attributes of the file to be processed and file attributes of a merged file in the target file; wherein the merged file is a file in the at least two files to be processed; and a resource query file generating unit is configured to generate the resource query file based on the file association information; wherein the resource query file is a file created in the target directory.
[0108] Based on the above optional technical solutions, optionally, the file attributes include file length and file name, and the file processing unit includes: an offset value determination unit, a file path value determination unit and a file association information determination unit.
[0109] An offset value determination unit is used to determine the offset value of the file to be processed based on the file length of the merged file; a file path value determination unit is used to determine a file identifier and at least one file path value corresponding to the file to be processed according to the file name; and a file association information determination unit is used to use the file name, file identifier, file length, at least one file path value and offset value as the file association information of the file to be processed.
[0110] Based on the above-mentioned optional technical solutions, optionally, the resource query file generation unit is specifically used to determine the file content in the resource query file based on the file identifier, file length and offset value in the file association information if the at least one file path value is a first preset number; and determine the file content in the resource query file based on the file identifier, file path value, file length and offset value in the file association information if the at least one file path value is a second preset number.
[0111] Based on the above optional technical solutions, optionally, the device further includes a file deletion module and a file addition module.
[0112] The file deletion module is used to delete the at least two files to be processed; the file addition module is used to add the target resource file to the resource directory corresponding to the target program.
[0113] Based on the above optional technical solutions, optionally, the device further includes a content acquisition module, and the content acquisition module includes a target resource file reading unit and a content acquisition unit.
[0114] The target resource file reading unit is used to read the target resource file based on the target function when running the target program; the content acquisition unit is used to acquire the compressed target file content in the target resource file based on the resource query file in the target resource file.
[0115] On the basis of the above-mentioned optional technical solutions, optionally, the device further includes a verification module, and the verification module includes a verification value determination unit and a verification unit.
[0116] A check value determination unit is used to determine the current check value of the target resource file; a check unit is used to read the target resource file based on the target function when the current check value is the same as the standard check value of the target resource file generated after merging.
[0117] Based on the above optional technical solutions, optionally, the resource query file includes file association information of each to-be-processed file, the file association information including a file identifier and / or a file path value, an offset value, and a file length, and the target resource file reading unit includes: a resource query file reading unit, the resource query file reading unit being configured to read the resource query file in the target resource file based on the file identifier or the file path value in the target function;
[0118] Based on the above optional technical solutions, optionally, the content acquisition unit includes a search unit and a content reading unit.
[0119] The search unit is used to determine the offset value and the file length based on the file identifier or the file path value; the content reading unit is used to read the target file content based on the offset value and the file length.
[0120] The technical solution of the embodiment of the present disclosure obtains at least two to-be-processed files of the target program, and then merges the at least two to-be-processed files into one target file. Based on the file association information of each to-be-processed file, a resource query file is generated, and the target file and the resource query file are compressed to obtain a target resource file corresponding to the target program. This solves the problem of compressing each file separately in the related art, resulting in a low file compression rate. During the compilation of the target program, at least two to-be-processed files of the target program are merged into one target file, thereby reducing the file size. At the same time, a resource query file is generated based on the file association information of each to-be-processed file, and then the target file and the resource query file are compressed to improve the file compression rate by compressing one target file. At the same time, it can also ensure that when the target file content in the target resource file is subsequently read, the file content can be accurately obtained by parsing the resource query file in the target resource file, thereby ensuring the stability of the program operation and ensuring that the target program can operate normally.
[0121] The file processing device provided by the embodiments of the present disclosure can execute the file processing method provided by any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0122] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0123] FIG7 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Referring to FIG7 , a schematic diagram of the structure of an electronic device (such as a terminal device or server in FIG7 ) 600 suitable for implementing an embodiment of the present disclosure is shown below. The terminal device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. The electronic device shown in FIG6 is merely an example and should not impose any limitations on the functions and scope of use of the embodiments of the present disclosure.
[0124] As shown in FIG7 , the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An edit / output (I / O) interface 605 is also connected to the bus 604.
[0125] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although FIG. 6 shows the electronic device 600 with various devices, it should be understood that not all of the devices shown are required to be implemented or present. More or fewer devices may alternatively be implemented or present.
[0126] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0127] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0128] The electronic device provided by the embodiment of the present disclosure and the file processing method provided by the above embodiment belong to the same inventive concept. For technical details not fully described in the embodiment of the present disclosure, please refer to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0129] An embodiment of the present disclosure provides a computer storage medium on which a computer program is stored. When the program is executed by a processor, the file processing method provided by the above embodiment is implemented.
[0130] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0131] In some embodiments, the client and server can communicate using any currently known or later developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or later developed network.
[0132] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0133] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains at least two to-be-processed files of the target program; merges the at least two to-be-processed files into one target file, and generates a resource query file based on the file association information of each to-be-processed file; and obtains a target resource file corresponding to the target program by compressing the target file and the resource query file.
[0134] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0135] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0136] The units involved in the embodiments described in this disclosure may be implemented in software or hardware. In some cases, the name of a unit does not limit the unit itself. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses."
[0137] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0138] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0139] According to one or more embodiments of the present disclosure, [Example 1] provides a file processing method, the method comprising:
[0140] Obtain at least two files to be processed of the target program;
[0141] Merging the at least two to-be-processed files into one target file, and generating a resource query file based on file association information of each to-be-processed file;
[0142] The target resource file corresponding to the target program is obtained by compressing the target file and the resource query file.
[0143] According to one or more embodiments of the present disclosure, [Example 2] provides a file processing method, further comprising:
[0144] Obtain at least two to-be-processed files in a target directory related to the target program;
[0145] Wherein, the file to be processed is a binary file.
[0146] According to one or more embodiments of the present disclosure, [Example 3] provides a file processing method, further comprising:
[0147] Creating a target file in a target directory, and merging the file contents of the at least two to-be-processed files into the target file based on the resource merging task; and,
[0148] Determining file association information of the file to be processed based on file attributes of the file to be processed and file attributes of the merged file in the target file; wherein the merged file is a file in the at least two files to be processed;
[0149] generating the resource query file based on the file association information;
[0150] The resource query file is a file created in the target directory.
[0151] According to one or more embodiments of the present disclosure, [Example 4] provides a file processing method, further comprising: Optionally, the file attributes include file length and file name;
[0152] Determining the offset value of the to-be-processed file based on the file length of the merged file;
[0153] Determining, according to the file name, a file identifier and at least one file path value corresponding to the file to be processed;
[0154] The file name, file identifier, file length, at least one file path value, and offset value are used as file association information of the file to be processed.
[0155] According to one or more embodiments of the present disclosure, [Example 5] provides a file processing method, further comprising:
[0156] If the at least one file path value is a first preset number, determining the file content in the resource query file based on the file identifier, file length, and offset value in the file association information;
[0157] If the at least one file path value is a second preset number, the file content in the resource query file is determined based on the file identifier, file path value, file length, and offset value in the file association information.
[0158] According to one or more embodiments of the present disclosure, [Example 6] provides a file processing method, further comprising:
[0159] Deleting the at least two files to be processed;
[0160] After obtaining the target resource file, the method further includes:
[0161] Add the target resource file to the resource directory corresponding to the target program.
[0162] According to one or more embodiments of the present disclosure, [Example 7] provides a file processing method, further comprising:
[0163] When running the target program, reading the target resource file based on the target function;
[0164] Based on the resource query file in the target resource file, the compressed target file content in the target resource file is obtained.
[0165] According to one or more embodiments of the present disclosure, [Example 8] provides a file processing method, further comprising:
[0166] Determining a current checksum value of the target resource file;
[0167] When the current check value is the same as the standard check value of the target resource file generated after merging, the target resource file is read based on the target function.
[0168] According to one or more embodiments of the present disclosure, [Example 9] provides a file processing method, further comprising: optionally, the resource query file includes file association information of each file to be processed, the file association information including a file identifier and / or a file path value, an offset value, and a file length;
[0169] Reading a resource query file in the target resource file based on the file identifier or file path value in the target function;
[0170] According to one or more embodiments of the present disclosure, [Example 10] provides a file processing method, further comprising:
[0171] Determine an offset value and a file length based on the file identifier or the file path value;
[0172] Based on the offset value and the file length, the target file content is read.
[0173] According to one or more embodiments of the present disclosure, [Example 11] provides a file processing device, including:
[0174] A file acquisition module, used to acquire at least two to-be-processed files of a target program;
[0175] A file processing module, configured to merge the at least two files to be processed into one target file, and generate a resource query file based on the file association information of each file to be processed;
[0176] The target resource file generating module is used to obtain a target resource file corresponding to the target program by compressing the target file and the resource query file.
[0177] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0178] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0179] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A file processing method, comprising: Obtain at least two files to be processed of the target program; Merging the at least two to-be-processed files into one target file, and generating a resource query file based on the file association information of each to-be-processed file; as well as The target resource file corresponding to the target program is obtained by compressing the target file and the resource query file.
2. The method according to claim 1, wherein obtaining at least two to-be-processed files of the target program comprises: Obtain at least two to-be-processed files in a target directory related to the target program; Wherein, the file to be processed is a binary file.
3. The method according to claim 1, wherein merging the at least two to-be-processed files into one target file and generating a resource query file based on the file association information of each to-be-processed file comprises: Creating a target file in a target directory, and merging the file contents of the at least two to-be-processed files into the target file based on the resource merging task; Determining file association information of the file to be processed according to file attributes of the file to be processed and file attributes of the merged file in the target file, wherein the merged file is a file of the at least two files to be processed; as well as Based on the file association information, generating the resource query file; The resource query file is a file created in the target directory.
4. The method according to claim 3, wherein the file attributes include file length and file name, and determining the file association information of the file to be processed according to the file attributes of the file to be processed and the file attributes of the merged files in the target file comprises: Determining the offset value of the to-be-processed file based on the file length of the merged file; Determine, according to the file name, a file identifier and at least one file path value corresponding to the file to be processed; and The file name, file identifier, file length, at least one file path value and offset value are used as file association information of the file to be processed.
5. The method according to claim 4, wherein generating the resource query file based on the file association information comprises: If the at least one file path value is a first preset number, determining the file content in the resource query file based on the file identifier, file length, and offset value in the file association information; as well as If the at least one file path value is a second preset number, then based on the file in the file association information The identifier, file path value, file length and offset value are used to determine the file content in the resource query file.
6. The method according to claim 1, further comprising, before compressing the target file and the resource query file: Deleting the at least two files to be processed; After obtaining the target resource file, the method further includes: Add the target resource file to the resource directory corresponding to the target program.
7. The method according to claim 1, further comprising: When running the target program, reading the target resource file based on the target function; as well as Based on the resource query file in the target resource file, the compressed target file content in the target resource file is obtained.
8. The method according to claim 7, further comprising, before reading the target resource file based on the target function when running the target program: Determining a current checksum of the target resource file; and When the current check value is the same as the standard check value of the target resource file generated after merging, the target resource file is read based on the target function.
9. The method according to claim 8, wherein the resource query file includes file association information of each file to be processed, the file association information includes a file identifier and / or a file path value, an offset value, and a file length, and the reading of the target resource file based on the target function comprises: Based on the file identifier or file path value in the target function, read the resource query file in the target resource file; The step of obtaining the compressed target file content in the target resource file based on the resource query file in the target resource file includes: Determine an offset value and a file length based on the file identifier or the file path value; as well as Based on the offset value and the file length, the target file content is read.
10. A file processing device, comprising: A file acquisition module, used for acquiring at least two to-be-processed files of a target program; A file processing module, used for merging the at least two files to be processed into one target file, and generating a resource query file based on the file association information of each file to be processed; as well as The target resource file generation module is used to obtain a target resource file corresponding to the target program by compressing the target file and the resource query file.
11. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors The device implements the file processing method according to any one of claims 1-9.
12. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to perform the file processing method according to any one of claims 1 to 9 when executed by a computer processor.
Citation Information
Patent Citations
File processing method and device, terminal and storage medium
CN110908958A
File loading method and device and readable storage medium
CN111008048A
File processing method and device, file searching method and device, computer equipment and storage medium
CN114780494A
Packaging and bulk transfer of files and metadata for synchronization
US20100088297A1