CN112988278B - Meta file modification method and device of resource file, electronic equipment and storage medium - Google Patents
Meta file modification method and device of resource file, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN112988278B CN112988278B CN202110389732.4A CN202110389732A CN112988278B CN 112988278 B CN112988278 B CN 112988278B CN 202110389732 A CN202110389732 A CN 202110389732A CN 112988278 B CN112988278 B CN 112988278B
- Authority
- CN
- China
- Prior art keywords
- file
- configuration
- configuration management
- resource
- rule
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
- G06F16/258—Data format conversion from or to a database
Abstract
The embodiment of the invention discloses a meta file modification method and device of a resource file, electronic equipment and a storage medium, wherein the method comprises the following steps: when an import event of the resource file is monitored, taking the imported resource file as a file to be configured; searching a configuration management file with the shortest path distance to a file to be configured according to a preset searching algorithm; judging whether the configuration management file contains a configuration rule matched with the file to be configured; and if so, modifying the meta file of the file to be configured according to the configuration rule. By setting the configuration management file and setting the configuration rules in the configuration management file, the configuration management file can be automatically searched when a newly imported resource file is imported, and the meta file of the resource file is modified by using the configuration rules matched with the configuration management file, so that the code maintenance cost and the communication cost are saved.
Description
Technical Field
The embodiment of the invention relates to computer technology, in particular to a meta file modification method and device of a resource file, electronic equipment and a storage medium.
Background
Currently, in the process of developing a game project by using a unity3d game engine, the game engine can automatically generate a meta file corresponding to an art resource file (e.g., a resource file such as a sticker, a scene, an animation, or a model) required by the project. The meta file records the related format configuration information of the resource file, and the unity3d generates the conversion files of the resource file corresponding to different platforms according to the related configuration information in the meta file, and stores the conversion files in the Library folder.
However, in order to meet the business requirements of game items, the meta file generated by the game engine by default needs to be modified, and the existing meta file modification method of resource files includes managing at least one resource folder or special file name by using script codes. Specifically, the script code may determine a managed resource folder through a path of the folder, modify different configuration information for different types of resource files in the resource folder, and modify the meta file according to the configuration information, so as to automatically modify the meta file for a newly imported resource file in the managed resource folder.
However, the deficiencies of the prior methods include at least: 1. when the folder path changing operation such as moving a resource folder, modifying a folder name and the like is performed, in order to modify a meta file of a resource file newly introduced or newly introduced into the resource folder, a statement of a folder path to be updated needs to be found out from a large number of codes and updated, and the codes are cumbersome to maintain, so that the maintenance cost is high; 2. the resource files are usually operated by the designer, and the management script codes need to be maintained by professional programmers, and when the designer performs conventional operations such as new creation and moving of resource folders, communication with the programmers is needed every time, so that the communication cost is increased.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for modifying a meta file of a resource file, an electronic device, and a storage medium, which can automatically modify a corresponding meta file when the resource file is imported, so as to save code maintenance cost and communication cost.
In a first aspect, an embodiment of the present invention provides a method for modifying a meta file of a resource file, including:
when an import event of the resource file is monitored, taking the imported resource file as a file to be configured;
searching the configuration management file with the shortest path distance to the file to be configured according to a preset searching algorithm;
judging whether the configuration management file contains a configuration rule matched with the file to be configured;
and if so, modifying the meta file of the file to be configured according to the configuration rule.
Optionally, when an import event of the resource file is monitored, taking the imported resource file as a file to be configured includes:
when a path change event of the folder is monitored, taking at least one resource file in the folder with the changed path as an imported resource file;
and sequentially selecting the current files to be configured from at least one imported resource file.
Optionally, the searching for the configuration management file with the shortest path distance to the file to be configured according to a preset search algorithm includes:
taking the path node of the file to be configured as a starting point, and gradually and upwards searching whether a folder of each father path node contains a configuration management file;
and taking the first searched configuration management file as the configuration management file with the shortest path distance with the file to be configured.
Optionally, the determining whether the configuration management file includes a configuration rule matched with the file to be configured includes:
judging whether the configuration management file contains a configuration rule corresponding to the file type of the file to be configured;
if so, judging whether the file to be configured contains a rule application directory corresponding to the configuration rule;
and if so, judging whether the relative path of the file to be configured and the configuration management file meets a preset regular expression screening rule or not.
Optionally, the determining whether the relative path between the file to be configured and the configuration management file meets a preset regular expression screening rule includes:
determining a relative path between the file to be configured and the configuration management file according to the path node of the file to be configured and the path node of the configuration management file;
judging whether the relative path meets a preset inclusion rule represented by a regular expression or not; and/or the presence of a gas in the gas,
and judging whether the relative path meets a preset exclusion rule father path node represented by a regular expression.
Optionally, the method for modifying a meta file of a resource file further includes:
if the configuration management file does not contain the configuration rule matched with the file to be configured, circularly searching the configuration management file with the shortest path distance to the file to be configured except the searched configuration management file according to the preset searching algorithm;
and stopping searching the configuration management file until the configuration management file contains the configuration rule matched with the file to be configured or the path root node is searched.
Optionally, the method for modifying a meta file of a resource file further includes:
receiving a modification instruction acting on a modification interface, and modifying the corresponding configuration management file according to the modification instruction;
the modification instruction is an instruction for adding configuration rules and/or an instruction for modifying configuration rules.
In a second aspect, an embodiment of the present invention further provides a meta file modification apparatus for a resource file, including:
the device comprises a to-be-configured file determining module, a to-be-configured file determining module and a to-be-configured file determining module, wherein the to-be-configured file determining module is used for taking an imported resource file as a to-be-configured file when an import event of the resource file is monitored;
the configuration management file searching module is used for searching the configuration management file with the shortest path distance to the file to be configured according to a preset searching algorithm;
the configuration rule judging module is used for judging whether the configuration management file contains a configuration rule matched with the file to be configured;
and the meta file modification module is used for modifying the meta file of the file to be configured according to the configuration rule if the configuration management file contains the configuration rule matched with the file to be configured.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the meta file modification method for a resource file provided in any embodiment of the present application.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the meta file modification method for a resource file as provided in any embodiment of the present application.
The embodiment of the invention provides a meta file modification method and device of a resource file, electronic equipment and a storage medium, wherein the meta file modification method comprises the following steps: when an import event of the resource file is monitored, taking the imported resource file as a file to be configured; searching a configuration management file with the shortest path distance to a file to be configured according to a preset searching algorithm; judging whether the configuration management file contains a configuration rule matched with the file to be configured; and if so, modifying the meta file of the file to be configured according to the configuration rule. By setting the configuration management file and setting the configuration rules in the configuration management file, the configuration management file can be automatically searched when a newly imported resource file is imported, and the meta file of the resource file is modified by using the configuration rules matched with the configuration management file, so that the code maintenance cost and the communication cost are saved.
Drawings
Fig. 1 is a schematic flowchart illustrating a meta file modification method for a resource file according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a meta file modification method for a resource file according to a second embodiment of the present invention;
FIG. 3 is a schematic diagram of a file structure in a meta file modification method for a resource file according to a second embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a meta file modification apparatus for a resource file according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described through embodiments with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention. In the following embodiments, optional features and examples are provided in each embodiment, and various features described in the embodiments may be combined to form a plurality of alternatives, and each numbered embodiment should not be regarded as only one technical solution.
Example one
Fig. 1 is a flowchart illustrating a method for modifying meta files of resource files according to an embodiment of the present invention, which is applicable to a situation where meta files of resource files are modified in a unity/unity3d application. The method can be executed by a meta file modification apparatus of a resource file provided by an embodiment of the present invention, which is implemented in software and/or hardware, and is preferably configured in an electronic device, such as a computer.
Referring to fig. 1, a meta file modification method for a resource file includes the following steps:
s110, when the import event of the resource file is monitored, the imported resource file is used as a file to be configured.
The meta file modification apparatus for a resource file, which executes the meta file modification method for a resource file according to the embodiment of the present invention, may be considered as a virtual apparatus implemented by a code program, and may be referred to as an Asset Import Manager (Asset Import Manager). The resource import manager can be loaded into the project file of the game project under development, and can be used for realizing parameter configuration on the resource file of the import project so as to realize modification on the default generated meta file.
In the embodiment of the present invention, the import event of the resource file includes, but is not limited to: adding a new resource file event in the existing resource folder; keeping the path of the existing resource folder unchanged, and only re-importing the existing resource files in the resource folder; moving the existing resource folder to other paths, and re-importing all resource files in the moved resource folder; and creating a new resource folder, and moving in the event of the resource file in the new resource folder. In addition, the import events of the resource files caused by other resource file changes or resource file folder changes are also included in the import events of the resource files according to the embodiments of the present invention, and are not exhaustive here.
In this embodiment, the resource import manager may monitor an import event of the resource file by calling an interface (e.g., a Post Process API) provided by the underlying code of the project. In addition, the resource import manager can take the imported resource file as the file to be configured when capturing the import event of the resource file.
Optionally, when an import event of the resource file is monitored, taking the imported resource file as a file to be configured includes: when a path change event of the folder is monitored, taking at least one resource file in the folder with the changed path as an imported resource file; and sequentially selecting the current files to be configured from at least one imported resource file.
In a specific embodiment, when the resource folder moves to another path to cause an import event of the resource file, the resource import manager may use all resource files in the resource folder with the changed path as the imported resource files. And the resource import manager can select one resource configuration file from the resource files in sequence as the current file to be configured, and perform parameter configuration on the current file to be configured to generate a meta file of the current file to be configured.
Or, in a case that processing resources (e.g., computing and storage resources) are abundant, the resource import manager may also take all imported resource files as files to be configured at the same time, and perform parameter configuration on at least one file to be configured synchronously, so as to improve the efficiency of modifying the meta file.
And S120, searching the configuration management file with the shortest path distance to the file to be configured according to a preset searching algorithm.
In the embodiment of the present invention, after the resource import manager is loaded into the project file, all predefined configuration management file (manager) objects in the project may be obtained through initialization, and the name, path node, included configuration rule, and information such as configuration parameters included in each configuration rule of the configuration management file object may be queried through different query statements. In addition, when receiving operations such as adding, deleting or updating the configuration management file object, the resource import manager can also realize automatic maintenance of the configuration management file object set.
After determining the file to be configured, the resource import manager can acquire a path node of the file to be configured; further, according to a preset search algorithm, a path node with the shortest path distance from the path node of each configuration management file to the path node of the file to be configured is determined, and the configuration management file corresponding to the path node with the shortest path distance is used as the searched configuration management file. The preset search algorithm may include a query range, the corresponding resource import manager may query the configuration management file having the shortest path distance to the file to be configured according to the query range, and the query range may be at least one range among a flat directory, a parent directory, and a child directory, for example.
Optionally, searching the configuration management file with the shortest path distance to the file to be configured according to a preset search algorithm includes: with the path node of the file to be configured as a starting point, searching upwards step by step whether the folder of each father path node contains the configuration management file; and taking the first searched configuration management file as the configuration management file with the shortest path distance to the file to be configured.
In this embodiment, the process of the resource import manager searching the configuration management file according to the preset search algorithm may specifically be: firstly, searching whether a folder of a parent path node at the upper stage contains a configuration management file or not by taking a path node of a file to be configured as a starting point; if so, taking the configuration management file as the configuration management file with the shortest path distance to the file to be configured; if not, searching whether the files of the upper two stages of father path nodes contain the configuration management files or not, and circularly searching the step to realize that whether the folders of all father path nodes contain the configuration management files or not is searched upwards step by step; and taking the first searched configuration management file as the configuration management file with the shortest path distance with the file to be configured. In addition, if the root node of the searched project file does not search the configuration management file, the search of the configuration management file is stopped, and the modification of the meta file of the file to be configured is ignored.
The configuration management file can exist at any path node position under the engineering file, and a plurality of configuration management files can form tree-shaped structure distribution. In general, the configuration management files closer to the root node of the tree structure may be defined as general configuration management files, and the configuration management files closer to the leaf nodes of the tree structure may be defined as specific configuration management files. This is advantageous for implementation, when specific configuration of the resource file is desired, the resource file may be placed at a position where the path distance corresponding to the specific configuration management file is short, and when general configuration of the resource file is desired, the resource file may be placed at a path node position covered by any general configuration management file that is long in distance from the path of the specific configuration management file, which may be considered that the general configuration management file may implement a wider configuration application range. In addition, the configuration management files are distributed in a tree structure, and the structure of the configuration management files can be optimized, so that the configuration management files are clear in structure and convenient to manage.
S130, judging whether the configuration management file contains a configuration rule matched with the file to be configured.
In the embodiment of the present invention, each configuration management file may include from zero to multiple configuration rules.
The configuration management file containing the zero configuration rules may be used as an explanatory document, and may explain information such as an explanation of a folder in which the configuration management file is located, a folder maintenance staff list, a configuration management file designer list, or profiles of the configuration management files. In addition, the configuration management file of the zero configuration rule can also reserve a configuration position for the subsequent newly added configuration rule.
In a configuration management file containing at least one configuration rule, each configuration rule is modified aiming at a meta file of a file to be configured of a specified file type, and each type only supports one format setting at the same time, wherein the file type of the file to be configured comprises but is not limited to types such as maps, sound effects, animations or models. Correspondingly, whether the configuration management file contains the configuration rule matched with the file to be configured or not can be judged, whether the configuration management file contains the configuration rule corresponding to the file type of the file to be configured or not can be judged. If the configuration management file contains the configuration rule corresponding to the file type of the file to be configured, the configuration management file is considered to contain the configuration rule matched with the file to be configured; and if the configuration management file does not contain the configuration rule corresponding to the file type of the file to be configured, the configuration management file is considered to not contain the configuration rule matched with the file to be configured.
Optionally, the determining whether the configuration management file includes a configuration rule matching the file to be configured includes: judging whether the configuration management file contains a configuration rule corresponding to the file type of the file to be configured; if so, judging whether the file to be configured contains a rule application directory corresponding to the configuration rule or not; if so, judging whether the relative path of the file to be configured and the configuration management file meets a preset regular expression screening rule or not.
In the configuration management file containing at least one configuration rule, each configuration rule may further be preset with a rule application directory, where the rule application directory may be considered as a management scope of the configuration rule, and the management scope may be a resource file in a flat directory, a resource file in all sub-directories, or a resource file in a flat directory and a resource file in all sub-directories. Specifically, the resource import manager may determine the rule application directory of the configuration rule according to the Search Mode parameter of the query Mode of the configuration rule, and preset different query modes, which may correspond to the different management ranges. The resource import manager may modify, by using the configuration rule, a meta file of the resource file in the rule application directory corresponding to the configuration rule.
In the configuration management file containing at least one configuration rule, each configuration rule may also be preset with a regular expression screening rule, where the regular expression screening rule may be regarded as a screening rule of a relative path represented in a regular expression form. The regular expression is a logic formula for operating character strings, namely a 'regular character string' is formed by using a plurality of specific characters defined in advance and a combination of the specific characters, and the 'regular character string' is used for expressing a filtering logic for the character strings. Illustratively, if the regular expression is [ a-z ], then any lower case alphabetic character in the range of "a" to "z" matches the regular expression.
After judging that the configuration management file contains the configuration rule corresponding to the file type of the file to be configured, the resource import manager can further judge whether the file to be configured contains the rule application directory corresponding to the configuration rule or not, and can further judge whether the relative path between the file to be configured and the configuration management file meets the preset regular expression screening rule or not. If the configuration rule is met, the configuration management file is considered to contain a configuration rule matched with the file to be configured; if any item does not meet the requirement, the configuration management file is considered to not contain the configuration rule matched with the file to be configured.
In addition, according to a specific application scenario, other filtering rules of the file to be configured, except for the file type, the rule application directory and/or the regular expression screening rule, can be preset for each configuration rule. Correspondingly, when the file to be configured meets all the preset filtering rules of the configuration rules, the file to be configured is considered to be matched with the configuration rules, so that the meta file of the file to be configured is modified by using the most matched configuration rules.
It should be noted that different configuration management files may include configuration rules for the same file type, and the configuration parameters of the configuration rules are different, so that when the file to be configured is placed in different path nodes, the file to be configured can be modified according to meta files of different configuration rules in the configuration management file with a short path distance. In addition, two configuration rules for a file type can be included in the same configuration management file, but the rule application directories of the two configuration rules cannot intersect to avoid configuration errors.
Further, determining whether the relative path between the file to be configured and the configuration management file meets a preset regular expression screening rule includes: determining a relative path between the file to be configured and the configuration management file according to the path node of the file to be configured and the path node of the configuration management file; judging whether the relative path meets a preset inclusion rule represented by a regular expression; and/or judging whether the relative path meets a preset exclusion rule represented by a regular expression.
In this embodiment, the step of determining the relative path by the resource import manager may be: determining a first intersected father path node of the configuration management file and the file to be configured; taking the next-level path node closest to the file to be configured of the first intersected father path node as a path starting point; sequentially determining the path node closest to the file to be configured at the next stage as a path intermediate node until the path node of the file to be configured; and separating the path nodes by using preset symbols (for example, separating by using a "/" symbol) to obtain the relative paths of the file to be configured and the configuration management file.
For example, suppose that the parent path node of the configuration management file (named manager1) is folder a (named xxA), and the next-level path node of folder a includes folder B (named xxB) and folder C (named xxC), and folder C contains the file to be configured (named xxx. The step of the resource import manager determining the relative path of xxx.jpg to manager1 may be: determining xxA as the first intersecting parent path node of manager1 and xxx.jpg; xxA if the next-level path node closest to the file to be configured is xxC, xxC is the starting point of the path; xxC the next closest path node to xxx.jpg equals xxx.jpg; determine the relative path of xxx. jpg relative to manager1 as: xxC/xxx.
The preset regular expression screening rule may be a preset inclusion rule expressed by a regular expression, or may be an exclusion rule expressed by a regular expression, or may include both the inclusion rule expressed by a regular expression and the exclusion rule expressed by a regular expression. If the characters specified by the inclusion rule exist in the relative path, the relative path is considered to meet the preset inclusion rule represented by the regular expression; if the relative path does not have characters specified by the exclusion rule, the relative path is considered to meet the preset exclusion rule represented by the regular expression; if the relative path includes both the characters specified by the inclusion rule and the characters specified by the exclusion rule, the relative path is considered to satisfy both the preset inclusion rule represented by the regular expression and the preset exclusion rule represented by the regular expression.
Specifically, the resource import manager may determine the inclusion rule expressed by the regular expression according to an Include regex parameter of the configuration rule, and determine the exclusion rule expressed by the regular expression according to an Include regex parameter of the configuration rule. If the Include regex parameter is null and the Exclose regex parameter is not null, judging whether the relative path of the file to be configured and the configuration management file meets a preset regular expression screening rule or not by judging whether the relative path meets the preset exclusion rule represented by the regular expression or not; if the Include regex parameter is not null and the Exclude regex parameter is null, judging whether the relative path of the file to be configured and the configuration management file meets a preset regular expression screening rule or not by judging whether the relative path meets a preset inclusion rule represented by a regular expression or not; if the Include Regex parameters and the Exclude Regex parameters are both empty, the regular expression screening rules are considered to be ineffective, namely whether the relative paths of the file to be configured and the configuration management file meet the preset regular expression screening rules or not does not need to be judged.
For example, assuming that the inclusion regex parameter is "ui _" and the exception regex parameter is "setting", when there are both the included character "ui _" and the character "setting" specified by the exclusion rule in the relative path, the relative path between the file to be configured and the configuration management file may be considered to satisfy the preset regular expression screening rule.
And S140, if so, modifying the meta file of the file to be configured according to the configuration rule.
In this embodiment, if the configuration management file includes a configuration rule matching the file to be configured, the resource import manager may modify the meta file of the file to be configured according to a predefined configuration parameter in the matching configuration rule, and specifically, modify a corresponding parameter in the original meta file by using the configuration parameter based on a YAML serialized custom-specific language (DSL).
Each configuration rule may include configuration parameters of a file format from zero to multiple configuration resource files, and the process of defining the configuration parameters of each configuration rule may be: each configuration rule contains configuration parameters of all file formats of a certain type of resource file, and the configuration parameters contained in the configuration rule can be defined by performing attribute setting on each configuration parameter.
The attributes of the configuration parameters may include, but are not limited to: invalid Do Nothing (N), Default (D) and Lock (L). Wherein, the configuration parameter set to N may be considered as a configuration parameter not belonging to the configuration rule; the configuration parameter set to D may be considered as a default setting when the file to be configured is modified, and the configuration parameter may be subsequently modified after the file to be configured is successfully modified; the configuration parameter set to L may be considered as a default setting when the to-be-configured file is modified, and the to-be-configured file cannot be subsequently modified after being modified successfully, that is, if the to-be-configured file is modified successfully, and the user modifies the configuration parameter again, the configuration parameter is forcibly modified back.
By using the meta file modification method disclosed by the embodiment, under the condition of importing multiple resource files, the meta file of the imported resource files can be automatically modified through the configuration management file without manual complicated processing, and compared with the traditional method, the meta file modification method greatly saves the code maintenance cost and the communication cost and improves the development efficiency of game projects.
It should be noted that when the import event of the resource file is: when an existing resource folder is moved to other paths and events of all resource files in the moved resource folder are re-imported, it is required to ensure that corresponding configuration management files are synchronously moved or copied to the folder in which the resource folder is moved, so as to ensure normal configuration of the resource files. And when the configuration management file moves to a position, the path node in the configuration management file maintained by the resource import manager can be automatically changed without manual maintenance, so that the maintenance cost is reduced.
According to the meta file modification method of the resource file, provided by the embodiment of the invention, when an import event of the resource file is monitored, the imported resource file is used as a file to be configured; searching a configuration management file with the shortest path distance to a file to be configured according to a preset searching algorithm; judging whether the configuration management file contains a configuration rule matched with the file to be configured; and if so, modifying the meta file of the file to be configured according to the configuration rule. By setting the configuration management file and setting the configuration rules in the configuration management file, the configuration management file can be automatically searched when a newly imported resource file is imported, and the meta file of the resource file is modified by using the configuration rules matched with the configuration management file, so that the code maintenance cost and the communication cost are saved.
Example two
Fig. 2 is a flowchart illustrating a method for modifying a meta file of a resource file according to a second embodiment of the present invention. The present embodiment and various alternatives in the flow docking method provided in the above embodiments may be combined. The embodiment optimizes the condition that the configuration management file does not contain the configuration rule matched with the file to be configured, and can realize the recursive upward search of the configuration management file so as to improve the probability of generating the meta file of the file to be configured. The embodiments of the present invention have the same inventive concept as the above embodiments, and the technical details not described in the embodiments can be seen from the above embodiments.
Referring to fig. 2, the method for modifying a meta file of a resource file specifically includes the following steps:
s210, when the import event of the resource file is monitored, the imported resource file is used as a file to be configured.
S220, searching the configuration management file with the shortest path distance to the file to be configured according to a preset searching algorithm.
And S230, judging whether the configuration management file contains a configuration rule matched with the file to be configured.
And S240, if yes, modifying the meta file of the file to be configured according to the configuration rule.
S250, if not, judging whether a path root node is searched;
and S260, if not, circularly searching the configuration management file with the shortest path distance to the file to be configured except the searched configuration management file according to a preset searching algorithm, and jumping to the step S230.
If the resource import manager does not find the path root node of the engineering file, the resource import manager can continue to search the configuration management file in the recursion direction, so as to perform parameter configuration on the file to be configured, and improve the probability of generating the meta file of the file to be configured.
And S270, if so, stopping searching the configuration management file.
If the resource import manager has searched the path root node of the project file and has not found the configuration management file yet, the search of the configuration management file is stopped, and the meta file is stopped to be modified, that is, the meta file is failed to be modified.
Fig. 3 is a schematic diagram of a file architecture in a meta file modification method for a resource file according to a second embodiment of the present invention. Taking the file architecture shown in fig. 3 as an example, assuming that the file 3 is a newly imported or newly imported project), the step of the resource import manager modifying the meta file of the file 3 may include:
when an import event of the file 3 is monitored, taking the file 3 as a file to be configured; taking the path node of the file 3 as a starting point, taking a configuration management file manager2 contained in the folder C of the parent path node at the upper level as a configuration management file with the shortest path distance; judging whether the manager2 contains a configuration rule matched with the file to be configured; if yes, modifying the meta file of the file 3 according to the configuration rule; if not, taking the configuration management file manager1 contained in the folder A of the upper two levels of father path nodes as the configuration management file with the shortest path distance; judging whether the manager1 contains a configuration rule matched with the file to be configured; if yes, modifying the meta file of the file 3 according to the configuration rule; if not, stopping searching the configuration management file. Therefore, when the file 3 is imported into the project file, the meta file is automatically modified for the file 3, and the code maintenance cost and the communication cost are saved.
Optionally, the method for modifying a meta file of a resource file further includes: receiving a modification instruction acted on a modification interface, and modifying the corresponding configuration management file according to the modification instruction; the modification instruction is an instruction for adding the configuration rule and/or an instruction for modifying the configuration rule.
In this embodiment, after the meta file of the file to be configured is generated, log information may also be output. Wherein the log information may include, but is not limited to: and configuring information such as management file identification, configuration rule identification, resource file identification and the like. The configuration management file identifier, the configuration rule identifier, and the resource file identifier correspond to a unique configuration management file, a unique configuration rule, and a unique resource file, and may be, for example, names of the configuration management file, the configuration rule, and the resource file, respectively. When the meta file of the modified resource file does not meet the expectation, the user can trace the configuration management file and the configuration rule used in generating the meta file through the log information, so as to modify the configuration management file and/or the configuration rule, and enable the modified meta file to meet the expectation.
The resource import manager can also provide a modification interface for modifying the configuration management file for a user, so that the user can modify the configuration management file through interface operation. Specifically, the resource import manager may receive, through the modification interface, an instruction carrying a resource file name and/or a configuration rule name, which is input by a user, so as to query a corresponding resource file and/or a configuration rule; the modification of the configuration management file can be realized by receiving an instruction for adding the configuration rule in the configuration management file (i.e. an instruction for adding the configuration rule) and/or an instruction for modifying the existing configuration rule in the configuration management file (i.e. an instruction for modifying the configuration rule) input by a user through the modification interface.
In this embodiment, if a new meta file modification rule is added, only a configuration management file needs to be newly created in a corresponding folder range, the corresponding rule is added and set through a graphical interface, and extra code writing and modification are not needed.
According to the meta file modification method for the resource file, provided by the embodiment of the invention, when the configuration management file does not contain the configuration rule matched with the file to be configured, the configuration management file can be searched in the recursive direction, so that the probability of generating the meta file of the file to be configured is improved. In addition, a modification interface can be provided for a user, the configuration management file is modified through the modification interface, the method is also very friendly to non-professional programmers, is simpler and more convenient, and greatly saves maintenance cost and communication cost.
EXAMPLE III
Fig. 4 is a schematic structural diagram of a meta file modification apparatus for a resource file according to a third embodiment of the present invention. The method for modifying the meta file of the resource file provided by any embodiment of the invention can be realized by applying the modifying device.
Referring to fig. 4, a meta file modification apparatus of a resource file includes:
a to-be-configured file determining module 410, configured to, when an import event of a resource file is monitored, take the imported resource file as the to-be-configured file;
the configuration management file searching module 420 is configured to search, according to a preset searching algorithm, a configuration management file having a shortest path distance to a file to be configured;
a configuration rule determining module 430, configured to determine whether the configuration management file contains a configuration rule matching the file to be configured;
the meta file modifying module 440 is configured to modify the meta file of the to-be-configured file according to the configuration rule if the configuration management file includes the configuration rule matched with the to-be-configured file.
Optionally, the configuration management file searching module is specifically configured to: when a path change event of the folder is monitored, taking at least one resource file in the folder with the changed path as an imported resource file; and sequentially selecting the current files to be configured from at least one imported resource file.
Optionally, the configuration management file searching module is specifically configured to: taking the path node of the file to be configured as a starting point, and gradually and upwards searching whether the folder of each father path node contains the configuration management file or not; and taking the first searched configuration management file as the configuration management file with the shortest path distance with the file to be configured.
Optionally, the configuration rule determining module is specifically configured to: judging whether the configuration management file contains a configuration rule corresponding to the file type of the file to be configured; if so, judging whether the file to be configured comprises a rule application directory corresponding to the configuration rule; if so, judging whether the relative path of the file to be configured and the configuration management file meets a preset regular expression screening rule or not.
Further, the configuration rule determining module is further specifically configured to:
determining a relative path between the file to be configured and the configuration management file according to the path node of the file to be configured and the path node of the configuration management file; judging whether the relative path meets a preset inclusion rule represented by a regular expression or not; and/or judging whether the relative path meets a preset exclusion rule represented by a regular expression.
Optionally, the configuration management file searching module is further configured to: if the configuration management file does not contain the configuration rule matched with the file to be configured, circularly searching the configuration management file with the shortest path distance to the file to be configured except the searched configuration management file according to a preset searching algorithm; and stopping searching the configuration management file until the configuration management file contains a configuration rule matched with the file to be configured or the path root node is searched.
Optionally, the meta file modification apparatus for the resource file further includes:
the modification module is used for receiving a modification instruction acting on the modification interface and modifying the corresponding configuration management file according to the modification instruction; the modification instruction is an instruction for adding the configuration rule and/or an instruction for modifying the configuration rule.
The meta file modification device for the resource file provided by the embodiment of the invention can execute the meta file modification method for the resource file provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. For details of the technology that are not described in detail, reference may be made to the meta file modification method of the resource file provided in any embodiment of the present invention.
Example four
Fig. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention. FIG. 5 illustrates a block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention. The electronic device 12 shown in fig. 5 is only an example and should not bring any limitation to the function and the scope of use of the embodiment of the present invention. Device 12 is typically an electronic device that assumes cross-system program interfacing functionality.
As shown in FIG. 5, electronic device 12 is embodied in the form of a general purpose computing device. The components of electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a memory 28, and a bus 18 that couples the various components (including the memory 28 and the processing unit 16).
The processor 16 executes various functional applications and data processing by running the program stored in the memory 28, for example, implementing a meta file modification method for a resource file provided by the above embodiment of the present invention, including:
when an import event of the resource file is monitored, taking the imported resource file as a file to be configured;
searching a configuration management file with the shortest path distance to a file to be configured according to a preset searching algorithm;
judging whether the configuration management file contains a configuration rule matched with the file to be configured;
and if so, modifying the meta file of the file to be configured according to the configuration rule.
Of course, those skilled in the art can understand that the processor may also implement the technical solution of the meta file modification method for the resource file provided in any embodiment of the present invention.
EXAMPLE five
The fifth embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a meta file modification method for a resource file provided in the fifth embodiment of the present invention, where the method includes:
when an import event of the resource file is monitored, taking the imported resource file as a file to be configured;
searching a configuration management file with the shortest path distance to a file to be configured according to a preset searching algorithm;
judging whether the configuration management file contains a configuration rule matched with the file to be configured;
and if so, modifying the meta file of the file to be configured according to the configuration rule.
Of course, the computer program stored on the computer readable storage medium provided in the embodiments of the present invention is not limited to the above method operations, and may also execute the meta file modification method of the resource file provided in any embodiment of the present invention.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor device, apparatus, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution apparatus, device, or apparatus.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution apparatus, device, or apparatus.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, or the like, as well as conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will appreciate that the present invention is not limited to the particular embodiments described herein, and that various obvious changes, rearrangements and substitutions will now be apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (10)
1. A meta file modification method of a resource file is characterized by comprising the following steps:
when an import event of the resource file is monitored, taking the imported resource file as a file to be configured;
searching the configuration management file with the shortest path distance to the file to be configured according to a preset searching algorithm;
judging whether the configuration management file contains a configuration rule matched with the file to be configured;
and if so, modifying the meta file of the file to be configured according to the configuration rule.
2. The method according to claim 1, wherein the step of taking the imported resource file as the file to be configured when the import event of the resource file is monitored comprises:
when a path change event of the folder is monitored, taking at least one resource file in the folder with the changed path as an imported resource file;
and sequentially selecting the current files to be configured from the at least one imported resource file.
3. The method according to claim 1, wherein the searching for the configuration management file having the shortest path distance to the file to be configured according to a preset search algorithm comprises:
taking the path node of the file to be configured as a starting point, and gradually and upwards searching whether a folder of each father path node contains a configuration management file;
and taking the first found configuration management file as the configuration management file with the shortest path distance with the file to be configured.
4. The method according to claim 1, wherein the determining whether the configuration management file contains the configuration rule matching with the file to be configured comprises:
judging whether the configuration management file contains a configuration rule corresponding to the file type of the file to be configured;
if so, judging whether the file to be configured contains a rule application directory corresponding to the configuration rule;
and if so, judging whether the relative path of the file to be configured and the configuration management file meets a preset regular expression screening rule or not.
5. The method according to claim 4, wherein the determining whether the relative path between the file to be configured and the configuration management file meets a preset regular expression screening rule includes:
determining a relative path between the file to be configured and the configuration management file according to the path node of the file to be configured and the path node of the configuration management file;
judging whether the relative path meets a preset inclusion rule represented by a regular expression or not; and/or the presence of a gas in the gas,
and judging whether the relative path meets a preset exclusion rule represented by a regular expression.
6. The method according to any one of claims 1-5, further comprising:
if the configuration management file does not contain the configuration rule matched with the file to be configured, circularly searching the configuration management file with the shortest path distance to the file to be configured except the searched configuration management file according to the preset searching algorithm;
and stopping searching the configuration management file until the configuration management file contains the configuration rule matched with the file to be configured or the path root node is searched.
7. The method according to any one of claims 1-5, further comprising:
receiving a modification instruction acted on a modification interface, and modifying the corresponding configuration management file according to the modification instruction;
wherein, the modification instruction is an instruction for adding configuration rules and/or an instruction for modifying configuration rules.
8. A meta file modification apparatus for a resource file, comprising:
the device comprises a to-be-configured file determining module, a to-be-configured file determining module and a to-be-configured file determining module, wherein the to-be-configured file determining module is used for taking an imported resource file as a to-be-configured file when an import event of the resource file is monitored;
the configuration management file searching module is used for searching the configuration management file with the shortest path distance to the file to be configured according to a preset searching algorithm;
the configuration rule judging module is used for judging whether the configuration management file contains a configuration rule matched with the file to be configured;
and the meta file modification module is used for modifying the meta file of the file to be configured according to the configuration rule if the configuration management file contains the configuration rule matched with the file to be configured.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the meta file modification method of the resource file according to any one of claims 1 to 7 when executing the program.
10. A computer-readable storage medium on which a computer program is stored, the program implementing the meta file modification method of the resource file according to any one of claims 1 to 7 when executed by a processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110389732.4A CN112988278B (en) | 2021-04-12 | 2021-04-12 | Meta file modification method and device of resource file, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110389732.4A CN112988278B (en) | 2021-04-12 | 2021-04-12 | Meta file modification method and device of resource file, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112988278A CN112988278A (en) | 2021-06-18 |
CN112988278B true CN112988278B (en) | 2022-09-06 |
Family
ID=76337983
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110389732.4A Active CN112988278B (en) | 2021-04-12 | 2021-04-12 | Meta file modification method and device of resource file, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112988278B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114404996A (en) * | 2022-01-26 | 2022-04-29 | 厦门雅基软件有限公司 | Resource data processing method, system, editor, electronic device and storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1657864A2 (en) * | 2004-11-12 | 2006-05-17 | Alcatel | Communication traffic control rule generation methods and systems |
CN108388604A (en) * | 2018-02-06 | 2018-08-10 | 平安科技(深圳)有限公司 | User right data administrator, method and computer readable storage medium |
CN111274274A (en) * | 2020-02-06 | 2020-06-12 | 北京百度网讯科技有限公司 | Rule matching method and device, electronic equipment and storage medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6591418B2 (en) * | 1999-03-26 | 2003-07-08 | Dell U.S.A., L.P. | Factory software management system |
-
2021
- 2021-04-12 CN CN202110389732.4A patent/CN112988278B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1657864A2 (en) * | 2004-11-12 | 2006-05-17 | Alcatel | Communication traffic control rule generation methods and systems |
CN108388604A (en) * | 2018-02-06 | 2018-08-10 | 平安科技(深圳)有限公司 | User right data administrator, method and computer readable storage medium |
CN111274274A (en) * | 2020-02-06 | 2020-06-12 | 北京百度网讯科技有限公司 | Rule matching method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112988278A (en) | 2021-06-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10324909B2 (en) | Omega names: name generation and derivation utilizing nested three or more attributes | |
US10579344B2 (en) | Converting visual diagrams into code | |
US10042746B2 (en) | Callpath finder | |
US8108360B2 (en) | Database object update order determination | |
US8086642B2 (en) | Apparatus, system, and method for processing hierarchical data in disparate data repositories | |
US11907203B2 (en) | Path encoded tree structures for operations | |
WO2009039072A2 (en) | System for development and hosting of network applications | |
US10552127B2 (en) | Method and system for developing relation-context specific software applications | |
US9483508B1 (en) | Omega names: name generation and derivation | |
CN110764748B (en) | Code calling method, device, terminal and storage medium | |
CN113010476A (en) | Metadata searching method, device and equipment and computer readable storage medium | |
CN112988278B (en) | Meta file modification method and device of resource file, electronic equipment and storage medium | |
CN114356964A (en) | Data blood margin construction method and device, storage medium and electronic equipment | |
CN112835638A (en) | Configuration information management method and device based on embedded application program | |
US11036478B2 (en) | Automated determination of transformation objects | |
CN116483707A (en) | Test method, test device, test apparatus, test program, and test program | |
WO2023103432A1 (en) | Code file editing method and apparatus, electronic device, and storage medium | |
CN115964042A (en) | Menu generation method and device, storage medium and electronic equipment | |
EP3923155A2 (en) | Method and apparatus for processing snapshot, device, medium and product | |
CN115221360A (en) | Tree structure configuration method and system | |
US9208259B2 (en) | Using symbols to search local and remote data stores | |
US20210288938A1 (en) | Network Data Processing Method, Apparatus, Electronic Device, and Storage Medium | |
US20230289151A1 (en) | Generation and consumption of templates based on source code examples | |
CN117215791A (en) | Task grade determining method, device, equipment and medium | |
CN110960858A (en) | Game resource processing method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |