File detection method and device, electronic equipment and storage medium
Through automated detection and processing mechanisms, the problem of program operation abnormalities caused by complex resource file reference relationships is solved, the efficiency of finding and updating referenced files is improved, manual intervention is reduced, and resource management is achieved efficient.
Patent Information
- Application Number
- CN202411183512.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-13
AI Technical Summary
During the game development process, the reference relationship of resource files is complex, which leads to the failure to update other files in time when the resource files are removed, resulting in abnormal program operation. The existing methods rely on manual search efficiency.
By obtaining the target file whose file type meets the preset file reference type, determine the target file object whose object type meets the preset object reference type, determine the detection results of the reference file with the reference relationship with the target file object, and then the file has been removed When performing exception processing, automatic detection and processing.
Improves the efficiency of finding other files that reference the removed resource files, reduces manual processing workload, reduces the risk of errors, and improves the accuracy and efficiency of resource management.
Smart Images

Figure CN119127805A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of file detection, and in particular to a file detection method, device, electronic device and storage medium. Background Art
[0002] Under the wave of the Internet, the continuous development and evolution of hardware and software technologies have promoted the emergence of smart devices and software. At the same time, a large number of games of different themes have emerged to meet the needs of users. With the vigorous development of various technologies in the game industry, more and more resource files are required when developing games.
[0003] Since there may be reference relationships between different resource files, if a resource file is removed and the resource file is missing, and the corresponding reference relationships of other files that reference the resource file are not removed, it will cause an exception when the program runs other files that reference the resource file. Currently, other files that reference the resource file are generally found manually, which results in low efficiency in finding other files that reference the removed resource file. Summary of the invention
[0004] The embodiments of the present application provide a file detection method, device, electronic device and storage medium, which can improve the efficiency of searching for other files that reference a removed resource file.
[0005] In a first aspect, an embodiment of the present application provides a file detection method, the method comprising:
[0006] Acquire a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file;
[0007] Determine, from the file objects of the target file, at least one target file object whose object type conforms to a preset object reference type, wherein the preset object reference type is used to indicate that a reference relationship exists between the target file object and at least one resource file;
[0008] Determine the file detection result of the reference file that has a reference relationship with the target file object;
[0009] If the file detection result is that the file has been removed, then file exception processing is performed on the target file.
[0010] In a second aspect, an embodiment of the present application provides a file detection device, the device comprising:
[0011] A file acquisition module, used to acquire a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file;
[0012] An object determination module, used to determine at least one target file object whose object type conforms to a preset object reference type from the file objects of the target file, wherein the preset object reference type is used to indicate that a reference relationship exists between the target file object and at least one resource file;
[0013] A result determination module, used to determine the file detection result of the reference file that has a reference relationship with the above-mentioned target file object;
[0014] The file processing module is used to perform file exception processing on the target file if the file detection result is that the file has been removed.
[0015] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory storing a plurality of instructions; a processor loads instructions from the memory to execute the steps of any one of the file detection methods provided in the embodiments of the present application.
[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a plurality of instructions suitable for loading by a processor to execute the steps of any one of the file detection methods provided in the embodiments of the present application.
[0017] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps of any file detection method provided in the embodiment of the present application.
[0018] By adopting the scheme of the embodiment of the present application, a target file whose file type conforms to a preset file reference type can be obtained, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file; from the file objects of the target file, at least one target file object whose object type conforms to the preset object reference type is determined, wherein the preset object reference type is used to indicate that the target file object has a reference relationship with at least one resource file; a file detection result of a reference file having a reference relationship with the target file object is determined; if the file detection result is that the file has been removed, file exception processing is performed on the target file, so as to quickly find the target file having a reference relationship with the resource file through the preset file reference type, and quickly find the target file object having a reference relationship with the resource file from the target file based on the preset object reference type, so as to detect the resource file referenced by the target file object, so as to process the corresponding target file when the resource file is removed, so as to improve the efficiency of finding other files that reference the removed resource file. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 This is a schematic diagram of an embodiment of the file detection method provided in the embodiments of the present application;
[0021] Figure 2 is a structural schematic diagram of a file detection device provided in an embodiment of the present application;
[0022] Figure 3 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] 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, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0024] Embodiments of the present application provide a file detection method, device, electronic device, and computer-readable storage medium.
[0025] Specifically, this embodiment will be described from the perspective of a file detection device, which can be integrated in an electronic device, that is, the file detection method of the embodiment of the present application can be executed by an electronic device, and optionally, the electronic device can include: a terminal device. The terminal device can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a game console, or a personal computer (PC) and other devices.
[0026] The file detection method provided in the embodiment of the present application can be applied to, for example, a file detection system. The file detection system may include a terminal device and a server, and the terminal may be a device including both receiving and transmitting hardware, that is, a device having receiving and transmitting hardware capable of performing two-way communication on a two-way communication link. The terminal device and the server may perform two-way communication via a network.
[0027] Optionally, the server may be an independent server, or a server network or server cluster composed of servers, including but not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud server composed of multiple servers. The cloud server is composed of a large number of computers or network servers based on cloud computing.
[0028] The following is a detailed description in conjunction with the accompanying drawings. In this embodiment, the execution subject is a terminal device as an example. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.
[0029] The file detection method of this embodiment can obtain a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file; from the file objects of the target file, determine at least one target file object whose object type conforms to the preset object reference type, wherein the preset object reference type is used to indicate that the target file object has a reference relationship with at least one resource file; determine a file detection result of a reference file that has a reference relationship with the target file object; if the file detection result is that the file has been removed, perform file exception processing on the target file.
[0030] Please refer to Figure 1 Taking a terminal device as an example, this embodiment provides a file detection method. The specific process of the file detection method can be as follows: Step 101 to Step 104, wherein:
[0031] Step 101: Obtain a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file.
[0032] Among them, at least some of the above-mentioned file objects can be one or more file objects, and the file object is an object that can be contained in the file. For example, the file object can be an object containing at least one kind of information such as text, picture, program, etc., and the file object can be a sub-file, etc. The specific setting can be based on the needs and is not limited here.
[0033] In this embodiment, the terminal obtains a target file whose file type meets the preset file reference type. The target file of the preset file reference type essentially contains a file that has a reference relationship with other resource files, so that the terminal only checks the target file and avoids checking files that have no reference relationship, thereby greatly improving the efficiency of file checking.
[0034] In some embodiments, the above-mentioned acquisition of the target file whose file type conforms to the preset file reference type includes: obtaining the target folder to be checked, and detecting the file type of each file in the above-mentioned target folder, and obtaining the target file whose file type conforms to the preset file reference type from the above-mentioned target folder.
[0035] The target folder is a folder to be checked. For example, it is possible to check whether the resource files referenced by the files in the folder are abnormal. The abnormality may include but is not limited to the resource files being removed, the resource files being faulty, etc.
[0036] It is understandable that due to the different file types of different files, files belonging to certain file types will reference at least one resource file, while files belonging to certain file types will not reference resource files. Therefore, in this embodiment, the terminal can determine whether it is necessary to check the file by traversing each file in the target folder one by one and detecting the file type of the file to clarify whether there is an abnormality in the resource file referenced by the file. That is, after obtaining the target folder, the terminal can detect the file type of each file in the target folder, so that the terminal can obtain the file type by detecting the file and clarify whether the corresponding file needs to be checked.
[0037] It should be noted that the above-mentioned target folder can be a folder in the game editor. For example, the game engine can be the Neox editor. Since there are a large number of resource files in the game editor, there may be a reference relationship between the resource files, such as a scene file references at least one texture file, a prefab file references a model file, and so on. If some of the resource files have been removed, such as deleted or moved to another storage location, and the file that references the removed resource file still references the removed resource file, it is easy to cause the program to have operations when running the file that references the removed resource file, such as displaying missing models or textures on the screen, and thus failing to render the expected game scene. Therefore, it is necessary to check the folders in the game editor to determine whether there are any abnormalities in the referenced resource files.
[0038] In some embodiments, since the file names of different files include a file extension and a file main name, and the file extension is used to identify the type of the file, the method for the terminal to detect the file type of each file in the above-mentioned target folder may be: detecting the file name of each file in the above-mentioned target folder.
[0039] In some embodiments, the above-mentioned target folder may be a folder containing necessary and more resource files. For example, changes in the resource files in the three folders "ui / prefabs", "ui / v_prefabs" and "effect" may have an important impact on the display and operation of the game. Therefore, the three folders "ui / prefabs", "ui / v_prefabs" and "effect" need to be set as target folders and traversed separately to detect the file type of each file in the above-mentioned target folders.
[0040] In some embodiments, since the above-mentioned detection of the file type of each file in the above-mentioned target folder may be the detection of the file name of each file in the above-mentioned target folder, the terminal may determine the corresponding target file based on the file name, that is, obtaining the target file whose file type conforms to the preset file reference type from the above-mentioned target folder may include: obtaining the target file whose file name contains the name indicated by the above-mentioned preset file reference type from the above-mentioned target file.
[0041] Exemplarily, in some scenarios, files with file extensions of ".uiprefab" and ".pse" can indicate a common resource file reference type in game development, that is, at least some file objects in files with file extensions of ".uiprefab" and ".pse" have a reference relationship with at least one resource file. Therefore, the target folder can be traversed by the traverse_folder function to detect whether there are files with file extensions of ".uiprefab" and ".pse", so as to further detect the detected files with file extensions of ".uiprefab" and ".pse", that is, to detect whether the reference to the resource file is abnormal. Among them, in a folder, there can be multiple files with the above file extensions of ".uiprefab" and ".pse", so that these files are used as target files; there can also be only one type of file with the above file extensions of ".uiprefab" and ".pse", so that the existing one type of file is used as the target file; there can also be no files with the above file extensions of ".uiprefab" and ".pse", that is, there is no target file in the folder. Among them, due to different project needs and different requirements for resource management, the common resource file reference types in game development are also different accordingly.
[0042] Step 102: Determine at least one target file object whose object type conforms to a preset object reference type from the file objects of the target file, wherein the preset object reference type is used to indicate that a reference relationship exists between the target file object and at least one resource file.
[0043] In this embodiment, the terminal determines a target file object whose object type meets a preset object reference type from among the file objects of the above-mentioned target file. The target file object of the preset object reference type is essentially a file that has a reference relationship with other resource files, so that the terminal only checks files that have a reference relationship with other resource files, avoiding checking files that do not have a reference relationship, thereby greatly improving the efficiency of file checking.
[0044] Specifically, the determining of at least one target file object whose object type conforms to the preset object reference type from the file objects of the target file may include: the terminal may perform file processing on the target file to obtain processed file data, and detect the processed file data, wherein the processed file data includes at least one set of data pairs. Then, the terminal may determine at least one target file object whose object type conforms to the preset object reference type based on the at least one set of data pairs.
[0045] It should be noted that when the terminal processes the above-mentioned target file to obtain processed file data, the terminal can pass the processed file data to a preset custom detection component, and the custom detection component is configured with a corresponding detection function to define the detection method for the processed file data. For example, a detection function "check_resource_reference" is defined to detect the relevance of resource references, that is, the function can analyze and process the processed data to check the reference relationship between resource files, clarify the corresponding referenced resource files, and thus clarify whether the reference relationship between the resource files is still valid, that is, determine whether the corresponding referenced resource files have been removed, and then ensure that the reference relationship between resource files is correct.
[0046] In some embodiments, due to the different file types of the above-mentioned target files and the different programming languages used to implement the above-mentioned file detection method, the above-mentioned file processing methods for the target files are different. For example, the above-mentioned file processing for the above-mentioned target files, obtaining the processed file data, and detecting the processed file data may include: the terminal reads the target file in json form, obtains json data, and passes the above-mentioned json data to a custom detection component for detection, and the above-mentioned json data contains at least one set of key-value pairs.
[0047] Specifically, the terminal reads the target file in json form to parse the file content of the target file into a data structure in json format, i.e., the above-mentioned json data. Specifically, the Python language can be used to process and operate the json data, that is, the built-in json module in Python can be used to read the json data in the target file, and the read json data containing at least one set of key-value pairs (key: value) is stored in the variable data for subsequent processing.
[0048] In some embodiments, the above-mentioned determination of at least one target file object whose object type conforms to a preset object reference type based on the above-mentioned at least one set of data pairs may include: the terminal may identify the type of the file object indicated by the key in the above-mentioned key-value pair through a custom detection component, and determine the file object corresponding to the above-mentioned key that conforms to the preset object reference type as the above-mentioned target file object.
[0049] It can be understood that since the file object is different depending on the file type of the target file, after the target file is processed, the processed file data obtained contains an object identifier for the file object, that is, the object identifier of the file object is used to indicate the object type, and the object identifier of the file object is set in the data pair, that is, the object identifier of the file object is the value of the key in the above-mentioned key-value pair.
[0050] Therefore, in this embodiment, the terminal uses a customized detection component to identify the type of the file object indicated by the key in the key-value pair to clearly determine whether the object type of the file object corresponding to the identified key meets the above-mentioned preset object reference type. If so, the file object corresponding to the above-mentioned key is determined as the target file object.
[0051] Among them, the terminal can use the file object whose object identifier matches the file object's name indicated by the preset object reference type as the target file object. It can be understood that by setting the preset object reference type, the file objects that may have problems can be detected separately to ensure the integrity and correctness of the resource reference.
[0052] Exemplarily, in some scenarios, a file object whose object identifier matches "asset_uri", "asset_path", "_texture" and "_value" may indicate a common resource reference attribute or resource type in game development, that is, a file object whose object identifier matches "asset_uri", "asset_path", "_texture" and "_value" has a reference relationship with at least one resource file. Therefore, it is possible to detect whether the object identifier matches "asset_uri", "asset_path", "_texture" and "_value". The match may be that the object identifier contains at least one of the identifiers listed above, or the object identifier is consistent with any of the identifiers listed above. Finally, the file object whose object identifier matches "asset_uri", "asset_path", "_texture" and "_value" may be further detected, that is, whether the reference to the file object is abnormal. For example, the usage of the referenced resource file in the game may be detected, that is, whether there is an erroneous reference or a missing reference. For another example, it is also possible to detect whether the referenced resource file has been removed.
[0053] Correspondingly, the reference file referenced by the target file object that conforms to the preset object reference type may include: taking the file indicated by the value in the key-value pair as the reference file, that is, determining the object type of the file object by the key, and determining the resource file referenced by the file object by the value corresponding to the key, that is, the reference file.
[0054] In some embodiments, since there may be multiple layers of reference relationships in the target file, that is, the target file includes multiple sub-files, one sub-file may reference another sub-file, and another sub-file may reference another sub-file, the files need to be processed and checked in layers to ensure the correct handling of the multiple layers of reference relationships. For example, ".uiprefab" and ".pse" files may have special functions or reference relationships in the project. Therefore, when it is detected that the target file includes multiple sub-files and there are multiple layers of references between the sub-files, multiple checks are required to ensure the correctness of the reference relationship.
[0055] Specifically, before determining at least one target file object whose object type conforms to the preset object reference type from the file object of the above-mentioned target file, it also includes: if the above-mentioned target file includes multiple sub-files, then obtaining a target sub-file whose file type conforms to the preset file reference type from the multiple sub-files, which is equivalent to obtaining a file whose file type conforms to the preset file reference type from each sub-file again, and then using the file objects of each of the above-mentioned target sub-files in the above-mentioned target file as the file objects of the above-mentioned target file.
[0056] It is understandable that if it is found that the target sub-file still contains multiple files when parsing the target sub-file, the files in the target sub-file that meet the preset file reference type will continue to be selected and the corresponding file objects will be determined.
[0057] Specifically, when the target file is read in json format to obtain json data containing at least one set of key-value pairs, and the target file object is determined based on the key in the key-value pair, if the value in the key-value pair is in the form of a dictionary or list, it indicates that there are multiple layers of references, and a second check is required for each element in the value recorded in the form of a dictionary or list, that is, to determine whether the file type of the file to which each element belongs meets the preset file reference type, and to determine the files that meet the preset file reference type, and then continue to determine the file objects in the files that meet the preset file reference type, and use the determined file objects as the file objects of the target file for subsequent judgment, that is, to determine whether the file object meets the preset object reference type. Among them, there may be multiple resource files of different types in the value recorded in the form of a dictionary, such as pictures and tables, and there may be multiple resource files of the same type in the value recorded in the form of a list.
[0058] The value recorded in the dictionary form stores the file path of the target file corresponding to the value and the resource file list associated with the target file.
[0059] Step 103: Determine the file detection result of the reference file that has a reference relationship with the target file object.
[0060] In this embodiment, the terminal needs to determine the resource file that has a reference relationship with the above-mentioned target file object, that is, the above-mentioned reference file, and then detect the reference file to clarify the file detection result of the reference file. The file detection result may include whether the reference file has been removed, that is, if the reference file has been removed, but the reference relationship between the target file object and the reference file has not been removed, it means that the reference has been removed.
[0061] In some embodiments, the file detection result of the reference file that has a reference relationship with the target file object may include: the terminal may use the file indicated by the value in the key-value pair as the reference file, and perform file detection on the reference file to obtain the file detection result of the reference file.
[0062] In some embodiments, the above-mentioned method of detecting the reference file to clarify the file detection result of the reference file includes but is not limited to a combination of at least one of the following methods: one is to determine whether the reference file is removed based on the files in the preset space where the deleted files are stored, that is, to determine whether there are removed or omitted references; another is to check whether the reference file is still under the file path based on the file path where the reference file is located, to determine whether the reference file is removed, that is, if the reference file is under the file path, it means that the reference file has not been removed, and if the reference file is not under the file path, it means that the reference file has been removed; another is to maintain a reference count variable to record the number of times each resource file is referenced by other files, so as to determine whether there are removed or omitted references by analyzing the reference count variable. When the reference count is 0, it means that the resource file has not been removed. If a resource file is referenced by other files, it can be marked as "removed"; another method is to maintain a cache variable indicating the reference relationship, which is used to record the reference relationship between resource files, so that each time the resource file is checked, the reference relationship recorded in the cache variable is compared to determine whether there are any removed or omitted references; another method is static analysis, that is, by statically analyzing the content or metadata of the resource file, checking the reference path, link or identifier information in the resource file to determine whether there are any removed or omitted references, which can be achieved through programming, using different parsing methods for different types of resource files to obtain reference relationships; another method is recursive checking, that is, for resource files with multi-layer reference relationships, recursive checking is required to ensure that references at all levels are considered, which can be achieved through a recursive algorithm, traversing all references of the resource file, and checking the validity of the references layer by layer.
[0063] Specifically, the file detection result of the reference file that has a reference relationship with the target file object may include: if the reference file is in a preset space, then the file detection result of the reference file is determined to be that the file has been removed, and the file in the preset space is a deleted file; if the reference file is not in the preset space, then the file detection result of the reference file is determined to be that the file has not been removed.
[0064] The location of the preset space can be determined based on the deleted path scanned, so that based on the deleted resource file, it can be determined that no other file continues to reference the deleted resource file, so as to avoid errors when the program is running. Therefore, the reference file is obtained through the reference relationship between the target file object and the reference file that has not been removed, and compared with the deleted resource file to determine whether the reference file has been removed.
[0065] Exemplarily, the terminal can construct SVN command line parameters for resource files that are modified or deleted under a specific version, so that in the game editor, by parsing the output of the SVN command line parameters, regular expressions or other parsing tools are used to extract the deleted or modified file paths, that is, to determine the above-mentioned preset space. The above-mentioned SVN command line parameters include the version number of the specific version of SVN to be scanned, and the operation type including operations such as modifying (modify) and / or deleting (delete) files.
[0066] Optionally, the terminal can convert the format of the deleted files retrieved in the preset space so as to analyze and compare the files in the preset space with the referenced files to improve processing efficiency. For example, since the PNG file is a picture file format that contains the pixel information of the picture, and the TXT file is a text file format that can directly contain text information. In some cases, saving the information of the resource file in text form can make data analysis, processing and management easier. Therefore, in order to facilitate subsequent data processing, such as checking, indexing, and comparing resource files, when the file format is PNG, the file format can be changed from PNG to TXT.
[0067] Step 104: If the file detection result is that the file has been removed, perform file exception processing on the target file.
[0068] In this embodiment, if the above file detection result is that the file has been removed, the terminal can perform file exception processing on the above target file so that the corresponding staff can view it. Therefore, through this embodiment, it can be achieved that when the resource file is removed, the file with missing resources is automatically detected, avoiding problems caused by the program being unable to correctly obtain these resources during operation, so as to improve the efficiency of game development. Moreover, through automated resource management, the workload of the corresponding staff in manually handling resource changes can be reduced, the efficiency of resource management can be improved, and the errors that may be caused by human operations can be further reduced, the risk of human errors can be reduced, the accuracy of resource management can be improved, and time and energy can be saved.
[0069] Specifically, the above-mentioned file exception processing for the above-mentioned target file may include: storing the above-mentioned target file in a preset type set, and the above-mentioned preset type set is used to store abnormal files; and / or, performing an abnormal identification operation on the above-mentioned target file, and recording the operation result of the above-mentioned abnormal identification operation, and the above-mentioned operation result is used to indicate that the above-mentioned target file is abnormal.
[0070] It can be understood that by storing the above target files in a preset type set, the corresponding staff can process the target files with reference anomalies by searching for corresponding files in the set. In addition, the above abnormal identification operation includes but is not limited to at least one of a deletion operation and a marking operation, that is, if the target file is marked by a marking operation, and an abnormal identification is assigned to the target file, that is, the abnormal identification is the operation result of the above abnormal identification operation, so that the corresponding staff can process the target file with reference anomalies with the abnormal identification by searching for the abnormal identification; or, the target file can be deleted by a deletion operation, and the deletion record is recorded as the operation result in an operation log, so that the corresponding staff can find the operation log to identify the target file with reference anomalies.
[0071] The above-mentioned collection can be a data structure for storing a unique set of objects or elements, that is, the above-mentioned target file, so as to subsequently process and analyze the objects or elements in the collection, such as further verifying the problem, generating reports, automatic processing, etc. The collection can be represented by data structures such as lists, sets, dictionaries, etc. The specific data structure to be selected depends on the characteristics of the stored data and the requirements of subsequent processing.
[0072] As can be seen from the above content, by obtaining the target folder to be checked and detecting the file type of each file in the above target folder; obtaining the target file whose file type conforms to the preset file reference type from the above target folder, wherein the above preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file; determining at least one target file object whose object type conforms to the preset object reference type from the file objects of the above target file, wherein the above preset object reference type is used to indicate that the target file object has a reference relationship with at least one resource file; determining the file detection result of the reference file having a reference relationship with the above target file object; if the above file detection result is that the file has been removed, performing file exception processing on the above target file, thereby quickly finding the target file having a reference relationship with the resource file through the preset file reference type, and quickly finding the target file object having a reference relationship with the resource file from the target file based on the preset object reference type, so as to detect the resource file referenced by the target file object, so as to process the corresponding target file when the resource file is removed, so as to improve the efficiency of finding other files that reference the removed resource file.
[0073] This embodiment also provides a file detection device, which can be integrated into a terminal device. Figure 2 As shown, the file detection device may include:
[0074] A file acquisition module 201 is used to acquire a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file;
[0075] The object determination module 202 is used to determine at least one target file object whose object type conforms to a preset object reference type from the file objects of the target file, wherein the preset object reference type is used to indicate that a reference relationship exists between the target file object and at least one resource file;
[0076] A result determination module 203 is used to determine the file detection result of the reference file that has a reference relationship with the target file object;
[0077] The file processing module 204 is used to perform file exception processing on the target file if the file detection result is that the file has been removed.
[0078] In some embodiments, the file acquisition module 201 is specifically used for:
[0079] Obtain a target folder to be checked, and detect the file type of each file in the target folder;
[0080] A target file whose file type conforms to a preset file reference type is obtained from the target folder.
[0081] In some embodiments, the file acquisition module 201 is specifically used for:
[0082] Check the file names of the files in the above target folder;
[0083] From the target file, obtain a target file whose file name contains a name indicated by the preset file reference type.
[0084] In some embodiments, the object determination module 202 is specifically used to:
[0085] Performing file processing on the target file to obtain processed file data, and detecting the processed file data, wherein the processed file data contains at least one set of data pairs;
[0086] Based on the at least one set of data pairs, at least one target file object whose object type conforms to a preset object reference type is determined.
[0087] In some embodiments, the object determination module 202 is specifically used to:
[0088] The target file is read in json form to obtain json data, and the json data is passed to the custom detection component for detection. The json data contains at least one set of key-value pairs.
[0089] In some embodiments, the object determination module 202 is specifically used to:
[0090] Using a custom detection component, identifying the type of the file object indicated by the key in the key-value pair;
[0091] The file object corresponding to the key that meets the preset object reference type is determined as the target file object.
[0092] In some embodiments, the above result determination module 203 is specifically used to:
[0093] The file indicated by the value in the key-value pair is used as the reference file, and file detection is performed on the reference file to obtain a file detection result of the reference file.
[0094] In some embodiments, the above result determination module 203 is specifically used to:
[0095] If the referenced file is in the preset space, determining that the file detection result of the referenced file is that the file has been removed, and the file in the preset space is a deleted file;
[0096] If the referenced file is not in the preset space, it is determined that the file detection result of the referenced file is that the file has not been removed.
[0097] In some embodiments, the object determination module 202 is further specifically configured to:
[0098] If the target file includes multiple sub-files, a target sub-file whose file type meets the preset file reference type is obtained from the multiple sub-files, and the file objects of each of the target sub-files in the target file are used as the file object of the target file.
[0099] In some embodiments, the file processing module 204 is specifically used to:
[0100] storing the target file into a preset type set, where the preset type set is used to store abnormal files; and / or
[0101] An abnormality identification operation is performed on the target file, and an operation result of the abnormality identification operation is recorded, where the operation result is used to indicate that the target file is abnormal.
[0102] From the above content, it can be seen that by obtaining a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file; from the file objects of the target file, determining at least one target file object whose object type conforms to the preset object reference type, wherein the preset object reference type is used to indicate that the target file object has a reference relationship with at least one resource file; determining a file detection result of a reference file having a reference relationship with the target file object; if the file detection result is that the file has been removed, performing file exception processing on the target file, thereby quickly finding the target file having a reference relationship with the resource file through the preset file reference type, and quickly finding the target file object having a reference relationship with the resource file from the target file based on the preset object reference type, so as to detect the resource file referenced by the target file object, so as to process the corresponding target file when the resource file is removed, so as to improve the efficiency of finding other files that reference the removed resource file.
[0103] Accordingly, an embodiment of the present application further provides an electronic device, which may be a terminal, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA) and other terminal devices. Alternatively, the electronic device may be a server.
[0104] like Figure 3 As shown, Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 300 includes a processor 301 having one or more processing cores, a memory 302 having one or more computer-readable storage media, and a computer program stored in the memory 302 and executable on the processor. The processor 301 is electrically connected to the memory 302. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange components differently.
[0105] The processor 301 is the control center of the electronic device 300. It uses various interfaces and lines to connect various parts of the entire electronic device 300, and executes various functions and processes data of the electronic device 300 by running or loading software programs and / or units stored in the memory 302, and calling data stored in the memory 302, so as to monitor the electronic device 300 as a whole. The processor 301 can be a central processing unit CPU, a graphics processing unit GPU, a network processor (Network Processor, NP), etc., and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application.
[0106] In the embodiment of the present application, the processor 301 in the electronic device 300 will load instructions corresponding to the processes of one or more application programs into the memory 302 according to the following steps, and the processor 301 will run the application programs stored in the memory 302 to implement various functions, such as:
[0107] Acquire a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file;
[0108] Determine, from the file objects of the target file, at least one target file object whose object type conforms to a preset object reference type, wherein the preset object reference type is used to indicate that a reference relationship exists between the target file object and at least one resource file;
[0109] Determine the file detection result of the reference file that has a reference relationship with the target file object;
[0110] If the file detection result is that the file has been removed, then file exception processing is performed on the target file.
[0111] Therefore, the electronic device 300 provided by this embodiment can bring the following technical effects: improving the efficiency of searching for other files that reference the removed resource file.
[0112] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0113] Optional, such as Figure 3 As shown, the electronic device 300 further includes: a touch screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306, and a power supply 307. The processor 301 is electrically connected to the touch screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307, respectively. Those skilled in the art can understand that Figure 3The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0114] The touch display screen 303 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 303 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel can be used to collect the user's touch operation on or near it (such as the user uses any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 301, and can receive the command sent by the processor 301 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 301 to determine the type of touch event, and then the processor 301 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 303 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 303 can also be used as a part of the input unit 306 to realize the input function.
[0115] The radio frequency circuit 304 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals with the network device or other electronic devices.
[0116] The audio circuit 305 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 305 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 305 and converted into audio data, and then the audio data is output to the processor 301 for processing, and then sent to another electronic device through the radio frequency circuit 304, or the audio data is output to the memory 302 for further processing. The audio circuit 305 may also include an earplug jack to provide communication between an external headset and the electronic device.
[0117] The input unit 306 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0118] The power supply 307 is used to supply power to various components of the electronic device 300. Optionally, the power supply 307 can be logically connected to the processor 301 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 307 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0119] although Figure 3 Not shown, the electronic device 300 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0120] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0121] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0122] To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute any file detection method provided in the embodiment of the present application. The computer program can execute the following steps of the file detection method:
[0123] Acquire a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file;
[0124] Determine, from the file objects of the target file, at least one target file object whose object type conforms to a preset object reference type, wherein the preset object reference type is used to indicate that a reference relationship exists between the target file object and at least one resource file;
[0125] Determine the file detection result of the reference file that has a reference relationship with the target file object;
[0126] If the file detection result is that the file has been removed, then file exception processing is performed on the target file.
[0127] It can be seen that the computer program can be loaded by the processor to execute any file detection method provided in the embodiments of the present application, thereby bringing the following technical effects: improving the efficiency of searching for other files that reference the removed resource file.
[0128] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0129] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0130] Since the computer program stored in the computer-readable storage medium can execute any one of the file detection methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the file detection methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0131] According to one aspect of the present application, a computer program product or a computer program is also provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the methods provided in various optional implementations of the above embodiments.
[0132] In the above-mentioned file detection device, computer-readable storage medium, electronic device, and computer program product embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, reference can be made to the relevant description of other embodiments. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process and beneficial effects of the above-described file detection device, computer-readable storage medium, computer program product, electronic device, and corresponding units can refer to the description of the file detection method in the above embodiment, and will not be repeated here.
[0133] The above is a detailed introduction to a file detection method, device, electronic device, computer-readable storage medium and computer program product provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A file detection method, characterized in that: The method comprises: Acquire a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least part of the file objects in the target file have a reference relationship with at least one resource file; Determine, from the file objects of the target file, at least one target file object whose object type conforms to a preset object reference type, wherein the preset object reference type is used to indicate that a reference relationship exists between the target file object and at least one resource file; Determine a file detection result of a reference file that has a reference relationship with the target file object; If the file detection result is that the file has been removed, file exception processing is performed on the target file.
2. The file detection method according to claim 1, characterized in that: The step of obtaining a target file whose file type conforms to a preset file reference type includes: Obtain a target folder to be checked, and detect the file type of each file in the target folder; A target file whose file type conforms to a preset file reference type is obtained from the target folder.
3. The file detection method according to claim 2, characterized in that: The detecting of the file type of each file in the target folder includes: Detect the file names of the files in the target folder; The step of obtaining a target file whose file type conforms to a preset file reference type from the target folder includes: From the target file, a target file whose file name contains a name indicated by the preset file reference type is obtained.
4. The file detection method according to claim 1, characterized in that: The step of determining at least one target file object whose object type conforms to a preset object reference type from the file objects of the target file comprises: Performing file processing on the target file to obtain processed file data, and detecting the processed file data, wherein the processed file data includes at least one set of data pairs; Based on the at least one set of data pairs, at least one target file object whose object type conforms to a preset object reference type is determined.
5. The file detection method according to claim 4, characterized in that: The processing of the target file to obtain processed file data and detecting the processed file data includes: The target file is read in json format to obtain json data, and the json data is passed to a custom detection component for detection, wherein the json data contains at least one set of key-value pairs.
6. The file detection method according to claim 5, characterized in that: The step of determining, based on the at least one set of data pairs, at least one target file object whose object type conforms to a preset object reference type comprises: Identify, by a custom detection component, the type of the file object indicated by the key in the key-value pair; The file object corresponding to the key that meets the preset object reference type is determined as the target file object.
7. The file detection method according to claim 6, characterized in that: The file detection result of determining the reference file having a reference relationship with the target file object includes: The file indicated by the value in the key-value pair is used as the reference file, and a file detection is performed on the reference file to obtain a file detection result of the reference file.
8. The file detection method according to claim 1, characterized in that: The file detection result of determining the reference file having a reference relationship with the target file object includes: If the referenced file is in the preset space, determining that the file detection result of the referenced file is that the file has been removed, and the file in the preset space is a deleted file; If the referenced file is not in the preset space, it is determined that the file detection result of the referenced file is that the file has not been removed.
9. The file detection method according to claim 1, characterized in that: Before determining at least one target file object whose object type conforms to a preset object reference type from the file objects of the target file, the method further includes: If the target file includes multiple sub-files, a target sub-file whose file type meets the preset file reference type is obtained from the multiple sub-files, and the file object of each target sub-file in the target file is used as the file object of the target file.
10. The file detection method according to any one of claims 1 to 9, characterized in that: The performing file exception processing on the target file includes: storing the target file into a preset type set, where the preset type set is used to store abnormal files; and / or An abnormality identification operation is performed on the target file, and an operation result of the abnormality identification operation is recorded, where the operation result is used to indicate that the target file is abnormal.
11. A file detection device, characterized in that: The device comprises: A file acquisition module, used to acquire a target file whose file type conforms to a preset file reference type, wherein the preset file reference type is used to indicate that at least some file objects in the target file have a reference relationship with at least one resource file; An object determination module, used to determine at least one target file object whose object type conforms to a preset object reference type from the file objects of the target file, wherein the preset object reference type is used to indicate that a reference relationship exists between the target file object and at least one resource file; A result determination module, used to determine the file detection result of the reference file that has a reference relationship with the target file object; The file processing module is used to perform file exception processing on the target file if the file detection result is that the file has been removed.
12. An electronic device, characterized in that: The system comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps of the file detection method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps of the file detection method according to any one of claims 1 to 10.
Citation Information
Patent Citations
A method for detecting invalid resource files of an installation package
CN108984207A
File exporting method and device, electronic equipment and readable storage medium
CN116775576A
Method and device for determining reference information of shader file and storage medium
CN116821061A
Method to process a source PDF file
US20160070517A1
