Compressed file retrieval method, electronic equipment and device
By generating a virtual directory and searching sub-files in the compressed file according to it, the problem of inefficient retrieval efficiency caused by decompressing compressed files in the prior art is solved, efficient retrieval of compressed files is achieved and storage space is saved.
Patent Information
- Application Number
- CN202411944883.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, when searching sub-files in compressed files, it is necessary to decompress the compressed files, resulting in low retrieval efficiency and occupies a large amount of storage space.
By generating a virtual directory, the hierarchy is expressed in sequence according to the file name of the subfile contained in the file header of the compressed file: the folders that need to be opened or subcompressed files that need to be decompressed in sequence are obtained in the compressed file, or the target subfile to be retrieved. Then search the target subfile by virtual directory, and only unzip and read its contents after the target subfile is retrieved.
It realizes efficient retrieval of its sub-files without decompressing a large number of compressed files, improving retrieval efficiency and saving storage space.
Smart Images

Figure CN119719057A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a compressed file retrieval method, electronic equipment and device. Background Art
[0002] A compressed file may contain a large number of sub-files, folders or sub-compressed files, that is, the sub-files contained in the compressed file are relatively complicated. In the related art, when searching for sub-files contained in a compressed file, it is necessary to decompress the compressed file to a hard disk, and then search from the decompressed sub-files. However, when searching in a large number of compressed files, it takes a long time to decompress a large number of compressed files, and it takes a lot of storage space, resulting in low efficiency in searching for sub-files in the compressed file.
[0003] For example, in modern industrial production, the test log of equipment is an important source of data to ensure product quality and performance. With the expansion of production scale and the increase of equipment types, the number of test logs has also increased exponentially. In order to effectively manage and utilize these log data, companies usually compress the test logs and store them. In this case, if the compressed test logs need to be analyzed, it is necessary to first retrieve the required content from a large number of compressed test logs. In this case, if the relevant technology is used to retrieve the test logs, there will be a problem of low retrieval efficiency, which will affect the overall efficiency of the test log analysis. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a compressed file retrieval method, electronic device and apparatus to solve the problem of low retrieval efficiency of sub-files in compressed files. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a compressed file retrieval method, the method comprising:
[0006] Obtaining search conditions for content retrieval in a compressed file;
[0007] Generate a virtual directory for each sub-file according to the file name of the sub-file contained in the file header of the compressed file, wherein the levels in the virtual directory sequentially represent: a folder to be opened or a sub-compressed file to be decompressed in order to obtain the sub-file in the compressed file, or a target sub-file to be retrieved;
[0008] According to the virtual directory, searching for a target sub-file matching the search condition;
[0009] Decompressing the compressed file, and reading the decompressed target sub-file;
[0010] The target file content matching the content search sub-condition in the search condition is retrieved and acquired from the file content contained in the target sub-file.
[0011] In one embodiment of the present application, searching for a target sub-file matching the search condition according to the virtual directory includes:
[0012] Determine whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file, wherein the search condition includes search sub-conditions corresponding to different levels, each search sub-condition represents a folder or sub-compressed file that meets the matching condition at the corresponding level, the target search sub-condition is the sub-search condition corresponding to the target level, and the initial target level is the highest level in the target virtual directory;
[0013] If not, then in the case where the target level is not the highest level, the target level is updated to the level above the current target level, and the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file is returned to search for a folder or sub-compressed file matching the target search sub-condition that has not been determined;
[0014] If it exists, then enter the folder corresponding to the target level or open the sub-compressed file corresponding to the target level, and determine whether the current folder or sub-compressed file contains the target sub-file;
[0015] If the target sub-file is not included, the target level is updated to the level below the current target level in the target virtual directory, and the process returns to the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file.
[0016] In one embodiment of the present application, the sub-compressed file corresponding to the target level is opened in the following manner:
[0017] Determine the compressed file type of the sub-compressed file corresponding to the target level;
[0018] The sub-compressed file is opened using a tool corresponding to the compressed file type.
[0019] In one embodiment of the present application, the method further includes:
[0020] When there is a need to save the target sub-file, the target sub-file is stored in a preset path.
[0021] In a second aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:
[0022] processor;
[0023] Transceiver;
[0024] A machine-readable storage medium storing machine-executable instructions that can be executed by the processor, the machine-executable instructions causing the processor to perform the following steps:
[0025] Obtaining search conditions for content retrieval in a compressed file;
[0026] Generate a virtual directory for each sub-file according to the file name of the sub-file contained in the file header of the compressed file, wherein the levels in the virtual directory sequentially represent: a folder to be opened or a sub-compressed file to be decompressed in order to obtain the sub-file in the compressed file, or a target sub-file to be retrieved;
[0027] According to the virtual directory, searching for a target sub-file matching the search condition;
[0028] Decompressing the compressed file, and reading the decompressed target sub-file;
[0029] The target file content matching the content search sub-condition in the search condition is retrieved and acquired from the file content contained in the target sub-file.
[0030] In one embodiment of the present application, searching the target sub-file matching the search condition according to the virtual directory specifically includes:
[0031] Determine whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file, wherein the search condition includes search sub-conditions corresponding to different levels, each search sub-condition represents a folder or sub-compressed file that meets the matching condition at the corresponding level, the target search sub-condition is the sub-search condition corresponding to the target level, and the initial target level is the highest level in the target virtual directory;
[0032] If not, then in the case where the target level is not the highest level, the target level is updated to the level above the current target level, and the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file is returned to search for a folder or sub-compressed file matching the target search sub-condition that has not been determined;
[0033] If it exists, then enter the folder corresponding to the target level or open the sub-compressed file corresponding to the target level, and determine whether the current folder or sub-compressed file contains the target sub-file;
[0034] If the target sub-file is not included, the target level is updated to the level below the current target level in the target virtual directory, and the process returns to the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file.
[0035] In one embodiment of the present application, opening the sub-compressed file specifically includes:
[0036] Determine the compressed file type of the sub-compressed file corresponding to the target level;
[0037] The sub-compressed file is opened using a tool corresponding to the compressed file type.
[0038] In one embodiment of the present application, the machine executable instructions further cause the processor to perform the following steps:
[0039] When there is a need to save the target sub-file, the target sub-file is stored in a preset path.
[0040] In a third aspect, an embodiment of the present application provides a compressed file retrieval device, the device comprising:
[0041] A range acquisition module, used to acquire search conditions for content retrieval in a compressed file;
[0042] A directory generation module, for generating a virtual directory for each sub-file according to the file name of the sub-file contained in the file header of the compressed file, wherein the levels in the virtual directory sequentially represent: a folder to be opened or a sub-compressed file to be decompressed in order to obtain the sub-file in the compressed file, or a target sub-file to be retrieved;
[0043] A sub-file retrieval module, used to retrieve a target sub-file matching the retrieval condition according to the virtual directory;
[0044] A sub-file reading module, used for decompressing the compressed file and reading the decompressed target sub-file;
[0045] The content acquisition module is used to retrieve and acquire the target file content matching the content search sub-condition in the search condition from the file content contained in the target sub-file.
[0046] In one embodiment of the present application, the sub-file retrieval module includes:
[0047] A matching submodule, used to determine whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file, wherein the search condition includes search sub-conditions corresponding to different levels, each search sub-condition represents a folder or sub-compressed file that meets the matching condition at the corresponding level, the target search sub-condition is the sub-search condition corresponding to the target level, and the initial target level is the highest level in the target virtual directory;
[0048] The first level updating submodule is used for, if the matching submodule determines that there is no folder or sub-compressed file matching the target search subcondition, then, if the target level is not the highest level, updating the target level to the level above the current target level, returning to trigger the execution of the matching submodule, and searching for folders or sub-compressed files matching the target search subcondition that have not been determined;
[0049] A sub-file determination sub-module, for entering a folder corresponding to a target level or opening a sub-compressed file corresponding to a target level if the matching sub-module determines that there is a folder or sub-compressed file matching the target search sub-condition, and determining whether the current folder or sub-compressed file contains the target sub-file;
[0050] The second level update submodule is used to update the target level to the next level of the current target level in the target virtual directory if the subfile determination submodule determines that the current folder or sub-compressed file does not contain the target subfile, and return to trigger the execution of the matching submodule.
[0051] In one embodiment of the present application, the sub-compressed file corresponding to the target level is opened by the following sub-modules:
[0052] A file type determination submodule, used to determine the compressed file type of the sub-compressed file corresponding to the target level;
[0053] The compressed file opening submodule is used to open the sub-compressed file using a tool corresponding to the compressed file type.
[0054] In one embodiment of the present application, the device further includes:
[0055] The sub-file storage module is used to store the target sub-file in a preset path when there is a need to save the target sub-file.
[0056] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any method step described in the first aspect is implemented.
[0057] In a fifth aspect, an embodiment of the present application further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the method steps described in the first aspect above.
[0058] Beneficial effects of the embodiments of the present application:
[0059] In the embodiment of the present application, a virtual directory is generated for the subfile according to the file name of the subfile contained in the file header of the compressed file, so that the compressed file can be searched according to the virtual directory, and after the target subfile is retrieved, the compressed file is opened to read the decompressed target subfile. That is, in the present application, the subfile contained in the compressed file can be searched without decompressing the compressed file, and the compressed file where the target subfile is located can be opened only when the target subfile is retrieved, so that the decompressed target subfile can be read, thereby obtaining the target file content contained in the target subfile. Therefore, the solution provided by the embodiment of the present application does not need to decompress a large number of compressed files before searching, so that the efficiency of searching the compressed files can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0061] Figure 1 A schematic diagram of a flow chart of a first compressed file retrieval method provided in an embodiment of the present application;
[0062] Figure 2 A schematic diagram of a flow chart of a second compressed file retrieval method provided in an embodiment of the present application;
[0063] Figure 3 A schematic diagram of a target sub-file retrieval process provided by an embodiment of the present application;
[0064] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0065] Figure 5 A structural schematic diagram of a compressed file retrieval device is provided for an embodiment of the present application. DETAILED DESCRIPTION
[0066] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0067] In the process of retrieving sub-files in a large number of compressed files in the related art (for example, retrieving test logs), a large number of compressed files need to be decompressed, which takes a long time and occupies a large amount of storage space, resulting in low efficiency in retrieving sub-files in compressed files in the related art. In order to solve the above problems, the embodiments of the present application provide a compressed file retrieval method, electronic device and apparatus.
[0068] See also Figure 1 , which is a flow chart of the first compressed file retrieval method provided in an embodiment of the present application, including the following steps S101-S105.
[0069] S101: Acquire search conditions for content search in a compressed file.
[0070] The compressed files may be compressed files within the acquired search range, and the search range may be the storage path of the compressed files, for example, the storage path of the folder where the compressed files are located, and the compressed files contained in the folder are all compressed files to be searched.
[0071] Alternatively, the search range may also be a generation time range of the compressed files. For example, if the search range is from x-month-x-day to y-month-y-day, the compressed files generated within the generation time range are the compressed files to be searched.
[0072] Alternatively, the retrieval range may also be the source range of the compressed file. For example, when the compressed file is a compressed test log, the source range may be the test log generated by device z. The compressed file to be retrieved is the test log generated by device z among all the stored compressed files.
[0073] After the search range is obtained, it is determined whether the files included in the search range are compressed files according to their suffixes, and then the target sub-files can be searched for in each compressed file included in the search range.
[0074] In addition, the above retrieval condition can be expressed in the form of a regular statement. Specifically, there can be multiple regular statements. Except for the last regular statement, each regular statement represents a retrieval sub-condition for searching in a layer of folders or a layer of sub-compressed files in the compressed file. The last regular statement is used to retrieve the required target file content in the target sub-file finally found. For example, the compressed file contains 4 folders in the first layer, each folder contains 2 sub-compressed files in the second layer, each sub-compressed file contains 3 sub-compressed files in the third layer, and the sub-compressed file in the third layer contains the sub-file in the fourth layer. Then the first regular statement indicates the search sub-condition for searching the folder containing the target sub-file in the first layer (such as the search sub-condition is the folder name, generation time, source, etc. of the folder), the second regular statement indicates the search sub-condition for searching the sub-compressed file containing the target sub-file in the second layer (such as the search sub-condition is the file name, generation time, source, etc. of the sub-compressed file), the third regular statement indicates the search sub-condition for searching the self-compressed file containing the target sub-file in the third layer (such as the search sub-condition is the file name, generation time, source, etc. of the sub-compressed file), and the fourth regular statement indicates the search sub-condition for searching the target sub-file in the fourth layer (such as the search sub-condition is the file name, generation time, source, etc. of the target sub-file). The target sub-file can be in various forms such as tables, documents, images, audio files, etc., and this application does not limit this.
[0075] In one embodiment of the present application, the above search scope and / or search condition may be input by the user or may be preset, which is not limited here. The user can flexibly and simply generate the search condition by inputting a regular statement.
[0076] S102: Generate a virtual directory for each sub-file according to the file name of the sub-file contained in the file header of the compressed file.
[0077] The levels in the virtual directory represent in order: the folders that need to be opened or the sub-compressed files that need to be decompressed in order to obtain the sub-file in the compressed file, or the target sub-file to be retrieved.
[0078] Specifically, the file header of the compressed file includes the file name of the sub-file contained in the compressed file. For example, dir1 / dir11 / file1 means that the sub-file file1 is located in the dir11 folder in the dir1 folder obtained after the compressed file is decompressed; dir2 / com22 / file2 means that the sub-file file2 is located in the com22 sub-compressed package in the dir2 folder obtained after the compressed file is decompressed; dir2 / dir23 / file3 means that the sub-file file3 is located in the dir23 folder in the dir2 folder obtained after the compressed file is decompressed.
[0079] Therefore, although the sub-files are essentially at the same level in the compressed file, there is no real hierarchical structure and directory. However, based on the file name in the file header of the compressed file, this embodiment can generate a virtual directory for the compressed file.
[0080] As shown in the previous example, the virtual directory corresponding to file1 contains three layers, in the order of dir1-dir11-file1.
[0081] The virtual directory corresponding to file2 contains three layers, in order: dir2-com22-file2.
[0082] The virtual directory corresponding to file3 contains three layers, in order: dir2-dir23-file3.
[0083] S103: According to the virtual directory, a target sub-file matching the search condition is searched.
[0084] Specifically, the order of the search sub-conditions included in the search condition can be matched with each level in the virtual directory from front to back in sequence, and the sub-files that match each level of the corresponding virtual directory with each search sub-condition in the search condition are determined as the target sub-files.
[0085] For example, taking the virtual directories of file1, file2, and file3 shown in the previous text as an example, if the search condition consists of three regular statements, the first search sub-condition represented by the first regular statement is that the file name is dir2, then the virtual directories matched are the directories of file2 and file3; the search sub-condition represented by the second regular statement is that the file name is dir23, then the virtual directory matched is the directory of file3; the search sub-condition represented by the third regular statement is that the file name is file3, then the virtual directory matched is the directory of file3. Based on the above search conditions, the target sub-file finally retrieved is file3.
[0086] It should be noted that since the number of compressed files to be retrieved may be large and each compressed file may contain multiple sub-files, the number of files to be retrieved is large. In this case, multiple processes can be used to retrieve different compressed files respectively to improve the retrieval efficiency of compressed files.
[0087] In another embodiment of the present application, the following Figure 2 Steps S103A to S103D shown implement the above-mentioned step S103, which will not be described in detail here.
[0088] S104: decompress the compressed file, and read the decompressed target sub-file.
[0089] S105: Retrieve and obtain target file contents that match the content search sub-condition in the search condition from the file contents contained in the target sub-file.
[0090] Specifically, the content search sub-condition may be to search for a sentence containing a preset keyword, or, when the file content is a number, the content search sub-condition may be to search for numbers within a target range, etc. The content search condition may be set according to actual needs and is not limited here.
[0091] In one embodiment, after the target file content matching the above content retrieval sub-condition is obtained, the target file content may be stored in a preset table.
[0092] Furthermore, the acquired target file content may be displayed on a display for the user to view and process.
[0093] In another embodiment of the present application, the following step A may also be performed.
[0094] Step A: When there is a need to save a target sub-file, the target sub-file is stored in a preset path.
[0095] Specifically, when the user inputs a file saving instruction, the target sub-file may be stored in a preset path.
[0096] Alternatively, when the target sub-file saving function is turned on, the target sub-file is stored in a preset path.
[0097] Alternatively, there is a requirement to save the target sub-file by default, and the target sub-file is stored in a preset path.
[0098] As can be seen from the above, in the embodiment of the present application, a virtual directory is generated for the sub-file according to the file name of the sub-file contained in the file header of the compressed file, so that the compressed file can be searched according to the virtual directory, and after the target sub-file is retrieved, the compressed file is opened to read the decompressed target sub-file. That is, in the present application, the sub-file contained in the compressed file can be searched without decompressing the compressed file, and the compressed file where the target sub-file is located can be opened only when the target sub-file is retrieved, so that the decompressed target sub-file can be read, thereby obtaining the target file content contained in the target sub-file. Therefore, the solution provided by the embodiment of the present application does not need to decompress a large number of compressed files before searching, so that the efficiency of searching the compressed files can be improved.
[0099] In addition, there is another retrieval method in the related art. It is to enter all the files in the compressed package into the database, and then search in the database. The above method based on the data retrieval method provided by the database can indeed speed up the retrieval speed, but entering a large number of files into the database will make the structure of the entire retrieval system more complicated, and the workload of entering the files into the database in the early stage is also very large. A lot of labor costs are required for system development and construction, and each time the file is entered into the database, it is necessary to decompress the compressed file and read the file structure, which increases the cost of maintaining the database. In addition, storing a large number of files in the database will take up a lot of storage space.
[0100] However, the scheme provided in the embodiment of the present application still stores compressed files, which takes up less storage space. In addition, there is no need to use a database for data retrieval, which also reduces the cost of maintaining the database, reduces the system complexity, and saves the labor cost of system development and construction.
[0101] See also Figure 2 , is a flow chart of a second compressed file retrieval method provided in an embodiment of the present application, which is similar to the aforementioned Figure 1 Compared with the embodiment shown in the figure, the above step S103 is implemented by the following steps S103A to S103D.
[0102] S103A: Determine whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file.
[0103] Among them, the above-mentioned search conditions include search sub-conditions corresponding to different levels, each search sub-condition represents a folder or sub-compressed file that meets the matching conditions at the corresponding level, the above-mentioned target search sub-condition is the sub-search condition corresponding to the above-mentioned target level, and the initial target level is the highest level in the above-mentioned target virtual directory.
[0104] If such folder or sub-compressed file does not exist, step S103B is executed; if such folder or sub-compressed file exists, step S103C is executed.
[0105] For example, if the target search sub-condition is the name of a folder or sub-compressed file, then the folder or sub-compressed file with the name in the current target level is searched. If the target search sub-condition is the generation time range of a folder or sub-compressed file, then the folder or sub-compressed file in the current target level whose generation time is within the generation time range is searched. If the target search sub-condition is the source of a folder or sub-compressed file, then the folder or sub-compressed file from the source in the current target level is searched.
[0106] In addition, the folders, sub-compressed files or sub-files that can be obtained directly after decompressing the compressed file correspond to the highest level, the folders, sub-compressed files or sub-files that can be obtained by opening the folder of the highest level or decompressing the sub-compressed file of the highest level correspond to the second level, and the folders, sub-compressed files or sub-files that can be obtained by further opening the folder of the second level or decompressing the sub-compressed file of the second level correspond to the third level, and so on.
[0107] S103B: When the target level is not the highest level, update the target level to the level above the current target level.
[0108] Return to execute the above step S103A, and search for folders or sub-compressed files that have not been determined and match the target search sub-condition. If there are no folders or sub-compressed files that have not been determined and match the target search sub-condition, it means that the target sub-file does not exist in the current compressed file, and the process ends and continues to search for the next compressed file.
[0109] If the target level is the highest level, it means that there is no matching target sub-file in the compressed file. In this case, the process can be terminated and the next compressed file can be searched.
[0110] S103C: Enter a folder corresponding to the target level or open a sub-compressed file corresponding to the target level, and determine whether the current folder or sub-compressed file contains the target sub-file.
[0111] In one embodiment of the present application, the sub-compressed file can be decompressed to open the sub-compressed file.
[0112] However, if the above method is adopted, the file obtained after decompression will consume time and occupy hard disk space. Since the sub-compressed file may not actually contain the target sub-file, decompressing the sub-compressed file in the search target sub-file will reduce the search efficiency. Therefore, in another embodiment of the present application, the sub-compressed file corresponding to the target level can be opened through the following steps B-C.
[0113] Step B: Determine the compressed file type of the sub-compressed file corresponding to the target level.
[0114] Specifically, the compressed file type can be determined according to the file suffix of the sub-compressed file, or the compressed file type can also be manually specified by the user.
[0115] Step C: Use the tool corresponding to the above compressed file type to open the sub-compressed file.
[0116] Different compressed file types correspond to different tools, such as zipfile library, tarfile library, etc. The tools can be used to open the sub-compressed file without decompressing it.
[0117] A compressed file containing a sub-compressed file can be called a nested compressed file. If the relevant technology is used to search for the nested compressed file, multiple rounds of decompression are required to complete the search process. As shown above, the efficiency of using the relevant technology to search for ordinary compressed files is already low. For nested compressed files that require multiple rounds of decompression to unlock, the efficiency will be even lower. However, the embodiment of the present application can retrieve the target sub-file without decompressing any compressed package, so the search efficiency of the nested compressed file can be greatly improved.
[0118] If the target sub-file is included, the target sub-file is retrieved and step S104 is executed; otherwise, the search needs to be continued and step S103D is executed.
[0119] S103D: Update the target level to the next level of the current target level in the target virtual directory.
[0120] Return to the above step S103A and continue to perform the next round of retrieval.
[0121] As can be seen from the above, in the embodiment of the present application, the compressed files are retrieved layer by layer in a hierarchical order, thereby improving the level of detail of the compressed file retrieval and increasing the coverage of the retrieved locations, thereby increasing the probability of retrieving the target sub-files and the number of retrieved target sub-files.
[0122] See also Figure 3 , is a schematic diagram of a target sub-file retrieval process provided in an embodiment of the present application, including the following steps S301-S309.
[0123] S301: Read a compressed file.
[0124] S302: Match the directory name.
[0125] Specifically, the search condition is matched with the virtual directory of the sub-file in the compressed file. The specific matching method can refer to the above description.
[0126] S303: Determine whether the matched target is a directory or a sub-compressed file.
[0127] Here, directory refers to the folder contained in the compressed file.
[0128] If it is a sub-compressed file, execute step S304; if it is a directory, execute step S305.
[0129] S304: Open the sub-compressed file.
[0130] S305: Enter the directory.
[0131] S306: Determine whether a target sub-file is matched.
[0132] If no match is found, the process returns to step S302 for further searching. If a match is found, the process proceeds to step S307.
[0133] S307: Read the target file.
[0134] S308: Determine whether all directories have been traversed.
[0135] Since other locations in the compressed file may also contain target sub-files that meet the search criteria, it is necessary to determine whether all directories have been traversed. If so, execute step S309; otherwise, return to execute step S302 for further search.
[0136] S309: End the process.
[0137] Corresponding to the aforementioned compressed file retrieval method, an embodiment of the present application provides an electronic device.
[0138] See also Figure 4 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, the electronic device comprising:
[0139] Processor 401;
[0140] transceiver 404;
[0141] A machine-readable storage medium 402, wherein the machine-readable storage medium 402 stores machine-executable instructions that can be executed by the processor 401, and the machine-executable instructions prompt the processor 401 to perform the following steps:
[0142] Obtaining search conditions for content retrieval in a compressed file;
[0143] Generate a virtual directory for each sub-file according to the file name of the sub-file contained in the file header of the compressed file, wherein the levels in the virtual directory sequentially represent: a folder to be opened or a sub-compressed file to be decompressed in the compressed file, or a target sub-file to be retrieved;
[0144] According to the virtual directory, searching for a target sub-file matching the search condition;
[0145] Decompressing the compressed file, and reading the decompressed target sub-file;
[0146] The target file content matching the content search sub-condition in the search condition is retrieved and acquired from the file content contained in the target sub-file.
[0147] like Figure 4 As shown, the network device may further include a communication bus 403. The processor 401, the machine-readable storage medium 402, and the transceiver 404 communicate with each other through the communication bus 403. The communication bus 403 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 403 may be divided into an address bus, a data bus, a control bus, and the like.
[0148] The transceiver 404 may be a wireless communication module. Under the control of the processor 401 , the transceiver 404 exchanges data with other devices.
[0149] The machine-readable storage medium 402 may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk storage. In addition, the machine-readable storage medium 402 may also be at least one storage device located away from the aforementioned processor.
[0150] The processor 401 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0151] As can be seen from the above, in the embodiment of the present application, a virtual directory is generated for the sub-file according to the file name of the sub-file contained in the file header of the compressed file, so that the compressed file can be searched according to the virtual directory, and after the target sub-file is retrieved, the compressed file is opened to read the decompressed target sub-file. That is, in the present application, the sub-file contained in the compressed file can be searched without decompressing the compressed file, and the compressed file where the target sub-file is located can be opened only when the target sub-file is retrieved, so that the decompressed target sub-file can be read, thereby obtaining the target file content contained in the target sub-file. Therefore, the solution provided by the embodiment of the present application does not need to decompress a large number of compressed files before searching, so that the efficiency of searching the compressed files can be improved.
[0152] In one embodiment of the present application, searching the target sub-file matching the search condition according to the virtual directory specifically includes:
[0153] Determine whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file, wherein the search condition includes search sub-conditions corresponding to different levels, each search sub-condition represents a folder or sub-compressed file that meets the matching condition at the corresponding level, the target search sub-condition is the sub-search condition corresponding to the target level, and the initial target level is the highest level in the target virtual directory;
[0154] If not, then in the case where the target level is not the highest level, the target level is updated to the level above the current target level, and the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file is returned to search for a folder or sub-compressed file matching the target search sub-condition that has not been determined;
[0155] If it exists, then enter the folder corresponding to the target level or open the sub-compressed file corresponding to the target level, and determine whether the current folder or sub-compressed file contains the target sub-file;
[0156] If the target sub-file is not included, the target level is updated to the level below the current target level in the target virtual directory, and the process returns to the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file.
[0157] As can be seen from the above, in the embodiment of the present application, the compressed files are retrieved layer by layer in a hierarchical order, thereby improving the level of detail of the compressed file retrieval and increasing the coverage of the retrieved locations, thereby increasing the probability of retrieving the target sub-files and the number of retrieved target sub-files.
[0158] In one embodiment of the present application, the sub-compressed file corresponding to the target level is opened in the following manner:
[0159] Determine the compressed file type of the sub-compressed file corresponding to the target level;
[0160] The sub-compressed file is opened using a tool corresponding to the compressed file type.
[0161] As can be seen from the above, a compressed file containing a sub-compressed file can be called a nested compressed file. If the relevant technology is used to search for a nested compressed file, multiple rounds of decompression are required to complete the search process. As shown above, the efficiency of using the relevant technology to search for ordinary compressed files is already low, and for nested compressed files that require multiple rounds of decompression to unlock, the efficiency will be even lower. However, the embodiment of the present application can retrieve the target sub-file without decompressing any compressed package, so the search efficiency of the nested compressed file can be greatly improved.
[0162] In one embodiment of the present application, the machine executable instructions further cause the processor 404 to perform the following steps:
[0163] When there is a need to save the target sub-file, the target sub-file is stored in a preset path.
[0164] Corresponding to the aforementioned compressed file retrieval method, an embodiment of the present application provides a compressed file retrieval device.
[0165] See also Figure 5 , is a schematic diagram of the structure of a compressed file retrieval device provided in an embodiment of the present application, the device comprising:
[0166] Range acquisition module 501, used to acquire search conditions for content search in compressed files;
[0167] The directory generation module 502 is used to generate a virtual directory for each sub-file according to the file name of the sub-file contained in the file header of the compressed file, wherein the levels in the virtual directory sequentially represent: the folder to be opened or the sub-compressed file to be decompressed in order to obtain the sub-file in the compressed file, or the target sub-file to be retrieved;
[0168] The sub-file retrieval module 503 is used to retrieve a target sub-file matching the retrieval condition according to the virtual directory;
[0169] The sub-file reading module 504 is used to decompress the compressed file and read the decompressed target sub-file;
[0170] The content acquisition module 505 is used to retrieve and acquire the target file content matching the content search sub-condition in the search condition from the file content contained in the target sub-file.
[0171] As can be seen from the above, in the embodiment of the present application, a virtual directory is generated for the sub-file according to the file name of the sub-file contained in the file header of the compressed file, so that the compressed file can be searched according to the virtual directory, and after the target sub-file is retrieved, the compressed file is opened to read the decompressed target sub-file. That is, in the present application, the sub-file contained in the compressed file can be searched without decompressing the compressed file, and the compressed file where the target sub-file is located can be opened only when the target sub-file is retrieved, so that the decompressed target sub-file can be read, thereby obtaining the target file content contained in the target sub-file. Therefore, the solution provided by the embodiment of the present application does not need to decompress a large number of compressed files before searching, so that the efficiency of searching the compressed files can be improved.
[0172] In one embodiment of the present application, the sub-file retrieval module 503 includes:
[0173] A matching submodule, used to determine whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file, wherein the search condition includes search sub-conditions corresponding to different levels, each search sub-condition represents a folder or sub-compressed file that meets the matching condition at the corresponding level, the target search sub-condition is the sub-search condition corresponding to the target level, and the initial target level is the highest level in the target virtual directory;
[0174] The first level updating submodule is used for, if the matching submodule determines that there is no folder or sub-compressed file matching the target search subcondition, then, if the target level is not the highest level, updating the target level to the level above the current target level, returning to trigger the execution of the matching submodule, and searching for folders or sub-compressed files matching the target search subcondition that have not been determined;
[0175] A sub-file determination sub-module, for entering a folder corresponding to a target level or opening a sub-compressed file corresponding to a target level if the matching sub-module determines that there is a folder or sub-compressed file matching the target search sub-condition, and determining whether the current folder or sub-compressed file contains the target sub-file;
[0176] The second level update submodule is used to update the target level to the next level of the current target level in the target virtual directory if the subfile determination submodule determines that the current folder or sub-compressed file does not contain the target subfile, and return to trigger the execution of the matching submodule.
[0177] As can be seen from the above, in the embodiment of the present application, the compressed files are retrieved layer by layer in a hierarchical order, thereby improving the level of detail of the compressed file retrieval and increasing the coverage of the retrieved locations, thereby increasing the probability of retrieving the target sub-files and the number of retrieved target sub-files.
[0178] In one embodiment of the present application, the sub-compressed file corresponding to the target level is opened by the following sub-modules:
[0179] A file type determination submodule, used to determine the compressed file type of the sub-compressed file corresponding to the target level;
[0180] The compressed file opening submodule is used to open the sub-compressed file using a tool corresponding to the compressed file type.
[0181] As can be seen from the above, a compressed file containing a sub-compressed file can be called a nested compressed file. If the relevant technology is used to search for a nested compressed file, multiple rounds of decompression are required to complete the search process. As shown above, the efficiency of using the relevant technology to search for ordinary compressed files is already low, and for nested compressed files that require multiple rounds of decompression to unlock, the efficiency will be even lower. However, the embodiment of the present application can retrieve the target sub-file without decompressing any compressed package, so the search efficiency of the nested compressed file can be greatly improved.
[0182] In one embodiment of the present application, the device further includes:
[0183] The sub-file storage module is used to store the target sub-file in a preset path when there is a need to save the target sub-file.
[0184] In another embodiment provided by the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned compressed file retrieval methods are implemented.
[0185] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any compressed file retrieval method in the above embodiments.
[0186] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0187] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0188] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the electronic device, device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0189] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A compressed file retrieval method, characterized in that: The method comprises: Obtaining search conditions for content retrieval in a compressed file; Generate a virtual directory for each sub-file according to the file name of the sub-file contained in the file header of the compressed file, wherein the levels in the virtual directory sequentially represent: a folder to be opened or a sub-compressed file to be decompressed in order to obtain the sub-file in the compressed file, or a target sub-file to be retrieved; According to the virtual directory, searching for a target sub-file matching the search condition; Decompressing the compressed file, and reading the decompressed target sub-file; The target file content matching the content search sub-condition in the search condition is retrieved and acquired from the file content contained in the target sub-file.
2. The method according to claim 1, characterized in that The step of retrieving a target sub-file matching the search condition according to the virtual directory includes: Determine whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file, wherein the search condition includes search sub-conditions corresponding to different levels, each search sub-condition represents a folder or sub-compressed file that meets the matching condition at the corresponding level, the target search sub-condition is the sub-search condition corresponding to the target level, and the initial target level is the highest level in the target virtual directory; If not, then in the case where the target level is not the highest level, the target level is updated to the level above the current target level, and the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file is returned to search for a folder or sub-compressed file matching the target search sub-condition that has not been determined; If it exists, then enter the folder corresponding to the target level or open the sub-compressed file corresponding to the target level, and determine whether the current folder or sub-compressed file contains the target sub-file; If the target sub-file is not included, the target level is updated to the level below the current target level in the target virtual directory, and the process returns to the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file.
3. The method according to claim 2, characterized in that Open the sub-compressed file corresponding to the target level by: Determine the compressed file type of the sub-compressed file corresponding to the target level; The sub-compressed file is opened using a tool corresponding to the compressed file type.
4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: When there is a need to save the target sub-file, the target sub-file is stored in a preset path.
5. An electronic device, characterized in that: The electronic device comprises: processor; Transceiver; A machine-readable storage medium storing machine-executable instructions that can be executed by the processor, the machine-executable instructions causing the processor to perform the following steps: Obtaining search conditions for content retrieval in a compressed file; Generate a virtual directory for each sub-file according to the file name of the sub-file contained in the file header of the compressed file, wherein the levels in the virtual directory sequentially represent: a folder to be opened or a sub-compressed file to be decompressed in order to obtain the sub-file in the compressed file, or a target sub-file to be retrieved; According to the virtual directory, searching for a target sub-file matching the search condition; Decompressing the compressed file, and reading the decompressed target sub-file; The target file content matching the content search sub-condition in the search condition is retrieved and acquired from the file content contained in the target sub-file.
6. The electronic device according to claim 5, characterized in that: The step of retrieving the target sub-file matching the search condition according to the virtual directory specifically includes: Determine whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file, wherein the search condition includes search sub-conditions corresponding to different levels, each search sub-condition represents a folder or sub-compressed file that meets the matching condition at the corresponding level, the target search sub-condition is the sub-search condition corresponding to the target level, and the initial target level is the highest level in the target virtual directory; If not, then in the case where the target level is not the highest level, the target level is updated to the level above the current target level, and the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file is returned to search for a folder or sub-compressed file matching the target search sub-condition that has not been determined; If it exists, then enter the folder corresponding to the target level or open the sub-compressed file corresponding to the target level, and determine whether the current folder or sub-compressed file contains the target sub-file; If the target sub-file is not included, the target level is updated to the level below the current target level in the target virtual directory, and the process returns to the step of determining whether there is a folder or sub-compressed file matching the target search sub-condition in the current target level of the compressed file.
7. The electronic device according to claim 6, characterized in that: Open the sub-compressed file corresponding to the target level by: Determine the compressed file type of the sub-compressed file corresponding to the target level; The sub-compressed file is opened using a tool corresponding to the compressed file type.
8. The electronic device according to any one of claims 5 to 7, characterized in that: The machine executable instructions further cause the processor to perform the following steps: When there is a need to save the target sub-file, the target sub-file is stored in a preset path.
9. A compressed file retrieval device, characterized in that: The device comprises: A range acquisition module, used to acquire search conditions for content retrieval in a compressed file; A directory generation module, for generating a virtual directory for each sub-file according to the file name of the sub-file contained in the file header of the compressed file, wherein the levels in the virtual directory sequentially represent: a folder to be opened or a sub-compressed file to be decompressed in order to obtain the sub-file in the compressed file, or a target sub-file to be retrieved; A sub-file retrieval module, used to retrieve a target sub-file matching the retrieval condition according to the virtual directory; A sub-file reading module, used for decompressing the compressed file and reading the decompressed target sub-file; The content acquisition module is used to retrieve and acquire the target file content matching the content search sub-condition in the search condition from the file content contained in the target sub-file.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 4 are implemented.