CN112000340A - File processing method and device, electronic equipment and storage medium - Google Patents

File processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112000340A
CN112000340A CN202010837989.7A CN202010837989A CN112000340A CN 112000340 A CN112000340 A CN 112000340A CN 202010837989 A CN202010837989 A CN 202010837989A CN 112000340 A CN112000340 A CN 112000340A
Authority
CN
China
Prior art keywords
resource file
file
variable
definition value
definition
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.)
Pending
Application number
CN202010837989.7A
Other languages
Chinese (zh)
Inventor
国霄
张祖俭
刘庆锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010837989.7A priority Critical patent/CN112000340A/en
Publication of CN112000340A publication Critical patent/CN112000340A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Library & Information Science (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the disclosure discloses a file processing method, a file processing device, an electronic device and a storage medium, wherein the method comprises the following steps: respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one by one; changing the definition value of the first variable in the current original resource file based on the definition value of the first variable and the definition value of the second variable in the current original resource file to obtain a new resource file after changing; executing compiling operation on the new resource file to obtain a second resource file; replacing the first resource file with a second resource file; and packaging the second resource file into a target file. The technical scheme of the embodiment of the disclosure realizes the separate definition of the first variable and the second variable in a specific development environment, provides support on a syntax level, and facilitates the maintenance of the combined variable of the first variable and the second variable in the later period.

Description

File processing method and device, electronic equipment and storage medium
Technical Field
The embodiment of the disclosure relates to the technical field of computers, and in particular relates to a file processing method and device, an electronic device and a storage medium.
Background
At present, almost all Android engineering developers can adopt the Android Studio recommended by Google as an Android development environment, and the Android Studio provides a lot of development resources. When the Android Studio is adopted for engineering development, a construction tool Gradle is used, and through a series of construction operations of the Gradle, the developed engineering code can be converted into an APK (Android Package) which can run on a mobile phone terminal.
However, the Android Studio does not support the definition of color values of colors separately from transparency, if the transparency is represented by decimal numbers, the value range of the transparency is 0-255, the same color values will derive 256 color values ARGB with transparency at most due to different transparencies, which results in that the color values in a file (such as color.
Disclosure of Invention
The embodiment of the disclosure provides a file processing method and device, an electronic device and a storage medium, which implement separate definition of a first variable and a second variable in a specific development environment, provide support in a syntax level, and facilitate maintenance of a combined variable of the first variable and the second variable in a later stage.
In a first aspect, an embodiment of the present disclosure provides a file processing method, where the method includes:
respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one by one;
for each original resource file, changing the definition value of a first variable in the current original resource file based on the definition value of the first variable and the definition value of a second variable in the current original resource file to obtain a new changed resource file, wherein the first variable and the second variable are defined in the current original resource file separately;
executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file;
replacing the first resource file with the second resource file;
and packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, wherein the target file can be operated in terminal equipment to realize a set function.
In a second aspect, an embodiment of the present disclosure further provides a file processing apparatus, where the apparatus includes:
the first compiling module is used for respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one by one;
the change module is used for changing the definition value of a first variable in each original resource file based on the definition value of the first variable and the definition value of a second variable in the current original resource file to obtain a new changed resource file, wherein the first variable and the second variable are defined in the original resource file separately;
the second compiling module is used for executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file;
a replacement module for replacing the first resource file with the second resource file;
and the packaging module is used for packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, and the target file can be operated in terminal equipment to realize a set function.
In a third aspect, an embodiment of the present disclosure further provides an apparatus, where the apparatus includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the file processing method according to any one of the embodiments of the present disclosure.
In a fourth aspect, the embodiments of the present disclosure also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are used for executing the file processing method according to any one of the embodiments of the present disclosure.
According to the technical scheme of the embodiment of the disclosure, the compiling operation is respectively executed on each original resource file to obtain first resource files corresponding to each original resource file one to one; for each original resource file, changing the definition value of a first variable in the current original resource file based on the definition value of the first variable and the definition value of a second variable in the current original resource file to obtain a new changed resource file, wherein the first variable and the second variable are defined in the current original resource file separately; executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file; replacing the first resource file with the second resource file; and packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, wherein the target file can be operated in terminal equipment to realize a technical means of setting functions, so that the first variable and the second variable are separately defined in a specific development environment, the support of a syntax level is provided, and the aim of maintaining the combined variable of the first variable and the second variable at a later stage is facilitated.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
Fig. 1 is a schematic flow chart of a file processing method according to a first embodiment of the disclosure;
fig. 2 is a schematic diagram illustrating a task execution flow according to a first embodiment of the disclosure;
fig. 3 is a schematic diagram illustrating another task execution flow provided in the first embodiment of the disclosure;
FIG. 4 is a schematic flow chart illustrating another exemplary document processing method according to an embodiment of the present disclosure;
fig. 5 is a schematic flowchart of a file processing method according to a second embodiment of the disclosure;
fig. 6 is a schematic flowchart of a file processing method according to a third embodiment of the disclosure;
fig. 7 is a schematic flowchart of another file processing method according to a third embodiment of the disclosure;
fig. 8 is a schematic structural diagram of a document processing apparatus according to a fourth embodiment of the disclosure;
fig. 9 is a schematic structural diagram of an electronic device according to a fifth embodiment of the disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
Example one
Fig. 1 is a schematic flow chart of a file processing method according to a first embodiment of the disclosure. The file processing method provided by the embodiment can be applied to various engineering development environments which do not support the separate definition of specific variables, such as Android Studio recommended by Google, and the development environments do not support the separate definition of color variables and transparency variables, so that 256 different colors can be derived from each color due to different transparencies, thereby causing color expansion and being not easy to maintain and manage. In view of this problem, the present embodiment provides a file processing method that can be executed by a file processing apparatus, which can be implemented in the form of software and/or hardware.
As shown in fig. 1, the method of this embodiment includes the following steps:
and 110, respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one to one.
Wherein, the original resource file refers to a source code file in a development project. Each development project basically depends on a specific development environment to improve the project development efficiency, and the development environment can provide a great number of resource libraries (such as library functions, application interfaces and the like) which can be directly used, so that developers can develop the projects by means of the specific development environment. It can be understood that the development environment provides services for most engineering developments, and therefore cannot provide very complete services for specific engineering, such as the Android Studio recommended by Google, and the development environment does not support the separate definition of color variables and transparency variables, resulting in that each color can derive 256 different colors due to different transparencies, thereby resulting in color bloat and not easy to maintain and manage. Similar engineering problems are numerous, for example, some development environments may not support the separate definition of the line shape and the line thickness, which may cause that a great number of lines are derived from the same line shape due to different thicknesses, which causes line expansion and is not easy to maintain and manage.
In this embodiment, the Android Studio recommended by Google is taken as a development environment to illustrate the file processing method flow. When engineering development is performed based on the development environment, a construction tool called Gradle is used, and engineering codes developed by developers can be converted into APKs (Android packages) capable of running on mobile phone terminals through a series of operations of the Gradle. A series of operation processes of the Gradle are called as construction processes, in the construction process of the Gradle, a plurality of steps exist, each step is called as a Task, so that a plurality of Task tasks are executed in the construction process, each Task is responsible for completing different transactions, a strict sequence exists among some Task tasks, and the Gradle executes each Task according to the sequence among the Task tasks. In the construction process of the Gradle, tasks of the mergeResourcesTask and processResourceeTask are tasks specially responsible for processing resources, the mergeResourcesTask is responsible for collecting the resources and compiling the resources, and after compiling, outputting a flat file; the processResourcesTask is responsible for linking resources, and outputting the apk file after linking. And the mergerresourcesTask and processResourcesTask have strict sequence, and the mergerresourcesTask is executed first and then the processResourcesTask is executed.
In Android development, patterns displayed on an interface can be defined in an xml file, the patterns are called drawable, and colors can be specified in the drawable file through Android: color in a solid label. The color used in Android development is in the format of ARGB, namely the color is divided into four parts: alpha (transparency), red (red), green (green), blue (blue). Each section is represented by a two-digit hexadecimal number, such as android: color ═ # FF886655, "where" FF "represents transparency and" 886655 "represents RGB values. The development environment Android Studio does not support separate definition of a color variable and a transparency variable, in Android development, in order to unify colors in a specification project, a set of RGB colors needs to be specified, colors used in a subsequent development project can only be colors meeting the specification, but the transparency A in ARGB cannot be specified, if the transparency is represented in decimal, the value range of the transparency A is 0-255, so that 256 ARGB colors can be derived from each RGB color due to different transparencies, so that the most ARGB colors are not beneficial to later maintenance and management, and the best solution is to separately define the colors RGB and the transparency A.
To solve the above problem, first, a compiling operation is respectively performed on each original resource file in the development project, that is, a mergeresourcesatask is performed, so as to obtain a first resource file corresponding to each original resource file one by one, where the first resource file is a flat file, for example, the flat file is usually placed in a directory of build/intermedia/res/merger/{ viewer }/{ buildType }, and when the processresourcesatask runs subsequently, the directory is read, and then files below the directory (that is, the first resource file and the flat file) are linked to generate a final target file, that is, an apk file, which can be an installation package file operated by a terminal device. The original resource file comprises an xml file, and in the original resource file (for example, dracable _ demo. xml), the first variable color and the second variable transparency are defined separately, for example, in the dracable _ demo. xml file, the following statements exist:
android:color="#1F2329";
android:alpha="#0";
step 120, for each original resource file, changing the definition value of the first variable in the current original resource file based on the definition value of the first variable and the definition value of the second variable in the current original resource file to obtain a new changed resource file, where the first variable and the second variable are separately defined in the current original resource file.
Taking the above example as an example, in the current original resource file, drawable _ demo.
Exemplarily, the modifying the definition value of the first variable in the current original resource file based on the definition value of the first variable and the definition value of the second variable in the current original resource file to obtain a modified new resource file includes:
determining a combined definition value of the first variable and the second variable based on the definition value of the first variable and the definition value of the second variable in the current original resource file;
and changing the definition value of the first variable in the current original resource file into the combined definition value to obtain a new resource file after changing.
Further, if the first variable is a color and the second variable is a transparency, determining a combined definition value of the first variable and the second variable based on the definition value of the first variable and the definition value of the second variable in the current original resource file includes:
converting the definition value of the second variable into a two-bit hexadecimal number based on a set conversion rule;
and splicing the two-bit hexadecimal digit and the six-bit hexadecimal digit of the first variable according to a preset format to obtain the combined definition value.
For example, within a dram _ demo. xml file, there is a statement as follows:
android:color="#1F2329";
android:alpha="#0";
correspondingly, the defined value of the first variable is "1F 2329", and the defined value of the second variable is "0".
The set conversion rule is that if the transparency alpha is 0, the hexadecimal '00' is corresponded, and the complete transparency is represented; if the transparency alpha is 1, it corresponds to "FF" in hexadecimal, indicating complete opacity. The preset format is ARGB, each bit is represented by two hexadecimal numbers, the first two bits from the left represent transparency, the remaining six bits represent color, for example, the definition value of the first variable is "1F 2329", the definition value of the second variable is "0", and the calculated combination definition value of the first variable and the second variable is "001F 2329".
Illustratively, if the definition attribute of the first variable is direct coding, the changing the definition value of the first variable in the current original resource file to the combined definition value includes:
and changing the encoding of the definition value of the first variable into the encoding of the combined definition value.
Continuing with the above example as an example, the defined value of the first variable before the change is: color ═ #1F2329 ";
the definition value of the modified first variable is as follows: color ═ #001F 2329. The source code of the original resource file Drawable _ demo is modified, wherein a statement android, color, or "#1F2329" exists before modification, the processed statement android, color, or "#001F2329" exists, and the processed color definition is provided with transparency. The reason why the Android < alpha > < 1 > is not required to be modified in any way in the definition statement Android < alpha > < 0 > of the transparency in the original resource file Drawable _ demo.xml is that the Android Studio does not support the separate definition of the color variable and the transparency variable in the current development environment, and therefore, syntax errors cannot be generated even if the Android Studio is not modified; and the modification to 1 is made by the way, in consideration of avoiding syntax errors if the Android Studio supports the separate definition of the color variable and the transparency variable in the future.
And step 130, performing a compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file.
Step 140, replacing the first resource file with the second resource file.
Wherein the color definition in the second resource file has been transparency-loaded.
And 150, packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, wherein the target file can be operated in a terminal device to realize a set function.
The step 150 is essentially an execution process of processresourcescTask, i.e. a process of packaging files generated by compiling.
According to the technical scheme of the embodiment of the disclosure, compiling operation is respectively executed on each original resource file in development engineering to obtain first resource files corresponding to each original resource file one by one; for each original resource file in a development project, changing the definition value of a first variable in the current original resource file based on the definition value of the first variable and the definition value of a second variable in the current original resource file to obtain a new changed resource file, wherein the first variable and the second variable are defined in the current original resource file separately; executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file; replacing the first resource file with the second resource file; and packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, wherein the target file can be operated in terminal equipment to realize a technical means of setting functions, so that the first variable and the second variable are separately defined in a specific development environment, the support of a syntax level is provided, and the aim of maintaining the combined variable of the first variable and the second variable at a later stage is facilitated.
On the basis of the above technical solution, further, the operations of step 120, step 130 and step 140 may be performed by creating a Task, which is called a handling color transparency Task handleAlphaColorTask, and is inserted between the tasks mergeResourceTask and processResourceTask through an API (application program interface) provided by Gradle. Exemplarily, referring to a task execution flow diagram shown in fig. 2, first, a task mergeResourceTask is executed to obtain a flat file corresponding to each original resource file, then, a handleAlphaColorTask is executed through a plug-in tool to replace each flat file, and then, a task processResourceTask is continuously executed to link the replaced flat files. Wherein, the tasks mergeResourceTask and processResourceTask use apt 2(Android Asset packing Tool, Tool for compiling and packing resources by Android), apt2 is a Tool for compiling and packing resources in Android development, and the Android Gradle Plugin 3.0.0 or higher default opens aapt 2. Correspondingly, referring to another task execution flow diagram shown in FIG. 3, the portion of FIG. 2 where the flat file is replaced by a plug-in tool is executed by handleAlphaColorTask.
More specifically, taking the current original resource file as "drawable _ degree.xml" as an example, referring to another file processing method flow diagram shown in fig. 4, the method specifically includes the following steps:
acquiring a to-be-processed original resource file drawable _ demo.xml (namely a current original resource file);
analyzing the file dry _ demo to obtain a definition value of a first variable and a definition value of a second variable, namely android, color and android, alpha;
copying a file drawable _ demo.xml to a new directory, such as a new directory/workDir/;
calculating a final combined definition value, namely a color with transparency, according to the definition value of color and the definition value of alpha;
assigning the calculated combined definition value to a first variable in the/workDir/drawable _ demo.xml, namely color variable android;
compiling/workDir/drawable _ demo.xml to obtain/workDir/drawable _ demo.xml.flat;
replacing a drawable _ demo.xml.flat file corresponding to the drawable _ demo.xml of the original resource file to be processed by the/workDir/drawable _ demo.xml.flat file;
and packing the dram _ table.xml.flat file under the directory according to the storage directory of the dram _ table.xml.flat file corresponding to the original resource file to be processed.
Example two
Fig. 5 is a flowchart illustrating a file processing method according to a second embodiment of the disclosure. On the basis of the above embodiments, the present embodiment optimizes the definition attributes of the first variable and the second variable. In engineering development, in order to facilitate management and maintenance, variables are not defined by directly using variable values, and are defined by reference. The method includes the steps that an identification key is quoted, then the corresponding relation between the identification key and a specific value is stored in a definition file, when a specific value needs to be modified, only the value in the definition file needs to be modified, and maintenance and management are easy. In the development environment Android Studio, definitions of variable colors are typically written in color. In the execution process of the task mergeReesourceTask, all color definitions in the project are placed in build/intermedia/incremental/merge $ { variantName } Resources/merged.di/values/values.xml, namely the content in the color.xml, and meanwhile, the file value.xml is compiled to obtain the value.xml.flat, and then the value.xml.flat is packaged through the execution of the processResourceTask.
As shown in fig. 5, the method includes:
and 510, respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one to one.
Specifically, each original resource file in the development project is compiled by executing the task mergeReesourceTask, and a flat file, i.e., a first resource file, corresponding to each original resource file is obtained, and meanwhile, the first variables (e.g., colors) in each original resource file are collected, and all the collected first variables (e.g., colors) are placed in the following directories:
the value is the original setting file as follows.
Step 520, acquiring the first variable from an original setting file, and generating a definition file of the first variable; the original setting file comprises the first variable in each original resource file, the original setting file is obtained by respectively executing compiling operation on each original resource file in the development project, the definition file comprises an identification ID (identity) of the first variable and a corresponding definition value, and the definition file stores the mapping relation between the key of the first variable and the corresponding value.
For example, the first variable is defined as: and (3) android, wherein color is @ color/lkui _ N900, the corresponding identifier ID, namely key is color/lkui _ N900, and the definition file has the following mapping relationship:
color/lkui _ N900: #1F2329, i.e., color/lkui _ N900 as key corresponds to a value of 1F 2329.
Color: the essence of @ color/lkui _ N900 is: color ═ 1F 2329.
Step 530, analyzing the current original resource file to obtain a reference identifier of the first variable in the current original resource file; and determining a definition value corresponding to the reference identifier from the definition file based on the reference identifier, and determining the definition value as the definition value of the first variable in the current original resource file.
And 540, determining a combined definition value of the first variable and the second variable based on the definition value of the first variable and the definition value of the second variable in the current original resource file.
Step 550, generating a reference identifier corresponding to the combined definition value code based on a preset rule; and changing the reference identifier of the first variable into the reference identifier corresponding to the combined definition value code to obtain a new resource file after change.
For example, the definition of the first variable before modification is: color ═ color/lkui _ N900 "; the modified definition of the first variable is as follows: and (2) android, wherein color is @ color/reset _ tmp _ color _ lkui _ N900_ alpha _0_ 5', namely the reference identifier of the first variable is lkui _ N900, and the reference identifier corresponding to the combination definition value code is reset _ tmp _ color _ lkui _ N900_ alpha _0_ 5.
It can be understood that, if the definition attribute of the first variable is a reference, the generated mapping relationship between the reference identifier corresponding to the combined definition value code and the combined definition value code needs to be updated to the original setting file values.
Step 560, writing the mapping relationship between the reference identifier corresponding to the combined definition value code and the combined definition value code into an intermediate file; and when the definition value of the first variable in each original resource file in the development project is changed, writing the mapping relation in the intermediate file into the original setting file to obtain a latest setting file.
In order to improve the processing efficiency, preferentially writing the mapping relation between the reference identifier corresponding to the combined definition value code and the combined definition value code into an intermediate file; and when the definition value of the first variable in each original resource file in the development project is changed, writing the mapping relation in the intermediate file into the original setting file to obtain a latest setting file.
Step 570, performing a compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file; and executing compiling operation on the latest setting file to obtain a second setting file corresponding to the latest setting file.
It can be understood that, in order to ensure that each resource file operates normally, the compiling operation needs to be performed on the latest setting file again to obtain a second setting file corresponding to the latest setting file, and the second setting file is packaged.
Step 580, replacing the first resource file with the second resource file, and replacing the first setting file obtained when the compiling operation is performed on the original setting file with the second setting file.
Step 590, packaging the second setting file and the second resource file into a target file according to the storage directory of the first setting file and the storage directory of the first resource file.
In the technical solution of the embodiment of the present disclosure, the definition attribute of the first variable is a reference, and after a mergereaesourcestask is executed on each original resource file in the development project, the definition attribute of the first variable is:
obtaining all first variables from a value.xml file in the build/interfaces/associated $ { variable name } Resources/associated.dir/values/values.xml, generating a definition file of the first variables, then determining a definition value of the first variables through the definition file based on the reference identifier of the first variables in the current original resource file, further determining a combination definition value of the first variables and the second variables based on the definition value of the first variables and the definition value of the second variables in the current original resource file, correspondingly generating a reference key of the combination definition value, then replacing the reference identifier of the first variables in the current original resource file with the reference key of the combination definition value, and updating the mapping relationship between the reference key of the combination definition value and the coding value of the combination definition value to the build/interfaces/associated/value. Compiling the updated values.xml again to obtain values.xml.flat, replacing the values.xml.flat, and finally packaging the new values.xml.flat, so that the purpose that the first variable and the second variable are defined separately when the variables are defined in a reference mode is achieved.
EXAMPLE III
Fig. 6 is a flowchart illustrating a file processing method according to a third embodiment of the disclosure. On the basis of the above embodiment, the present embodiment adds the related processing operation for the rename file. Because a lot of personnel participate in engineering development and no unified file naming standard exists at present, resource files with the same name often appear. When replacing the flat file corresponding to the resource file with the same name, it is necessary to determine in advance which resource file is currently processed. In view of the above problem, referring to a schematic flow chart of a file processing method shown in fig. 6, the method includes:
and 610, respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one to one.
Step 620, for each original resource file, copying the current original resource file to a new directory, and changing the definition value of the first variable in the current original resource file in the new directory based on the definition value of the first variable and the definition value of the second variable in the current original resource file to obtain a changed new resource file, wherein the first variable and the second variable are defined separately in the current original resource file.
Step 630, performing associated storage on the name of the current original resource file, the storage directory of the current original resource file, and the storage directory of the new resource file to obtain a storage record, and determining the resource file with the same name based on the storage record.
The specific storage format is as follows: the name of the parent file of the original resource file, the name of the resource file and the storage directory of the original resource file before the change are as follows: and the storage directory of the new resource file is changed. For example: dracable/aab.xml [/Users/guoxino/ResPluginDemo/app/src/main/res/dracable/aab.xml:/Users/guoxino/ResPluginDemo/app/build/coloralpha/res/dracable/aab.xml ]
The name of each original resource file, the storage directory of the original resource file before being changed and the storage directory of the new resource file after being changed are stored in a correlated mode to obtain a storage record, whether the original resource file with the same name as the current original resource file exists or not can be determined based on the storage record, and if the original resource file with the same name as the current original resource file exists, the following operation is executed.
Step 640, performing a compiling operation based on a storage directory of a target original resource file in the original resource files with the same name to obtain a first target resource file corresponding to the target original resource file; and generating the information abstract value of the first target resource file.
Specifically, one of the original resource files having the same name as the current original resource file is compiled to obtain the first target resource file, i.e., the flat file.
Step 650, comparing the information digest value of the first target resource file with the information digest values of the first resource files in the storage directory of the first resource files, and determining the first resource file consistent with the information digest value of the first target resource file as the first resource file corresponding to the current original resource file.
It can be understood that, after the step 610 "separately executes a compiling operation on each original resource file in the development project to obtain first resource files corresponding to each original resource file one to one" is completed, a great number of first resource files are generated in a specific directory, that is, in a storage directory of the first resource file (for example, directory build/identities/res/aggregated/{ flavour }), if the original resource files have the same-name file, a great number of first resource files with the same name are generated in the directory build/identities/res/aggregated/{ flavour }, and then it is necessary to determine which first resource file is the one corresponding to the current original resource file when replacing the first resource file corresponding to the current original resource file. This problem is solved by the above steps 630-650.
And step 660, replacing the first resource file with the second resource file.
Step 670, packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, where the target file can be run in a terminal device to implement a setting function.
For illustrating the above process, correspondingly, referring to another schematic flow chart of the file processing method shown in fig. 7, the method includes:
acquiring a to-be-processed original resource file (i.e. current original resource file), assuming that a storage directory of the to-be-processed resource file is mywork/Drawable _ demo.xml, and simultaneously acquiring all color definitions from an original setting file/merged.
And analyzing the file/mywork/drawable _ demo. xml to obtain a color definition value and a transparency definition value, namely android, color and android, alpha.
And copying the file/mywork/drawable _ demo.xml to a new directory, such as the new directory, and obtaining/workDir/drawable _ demo.xml.
Color type is judged, if the color type is a reference type, specific color values are determined from a definition file color xml, and if the color type is a direct coding type, the color and transparency are directly combined and calculated to determine the final color, namely the color with the transparency.
And calculating a final combined definition value according to the definition value of color and the definition value of alpha.
And assigning the calculated combined definition value to a color variable android in the new directory/workDir/drawable _ demo.
And compiling the original resource file before modification, namely/mywork/drawable _ demo.
Calculating an information abstract value of/myword/Drawable _ demo.xml.flat, comparing the information abstract value with information abstract values of various Drawable _ demo.flat under a directory of built/interleaved/res/compiled/{ flat }, and if the information abstract value of the first Drawable _ demo.xml.flat under the directory of built/interleaved/res/merged/{ flat } is determined to be the same as the information abstract value of/myword/Drawable _ demo.xml.flat, indicating that a flat file corresponding to the current original resource file/myword/Drawable _ demo.xml.xml.xml.flat is found, and compiling/word/Drawable _ demo.xml.flat to obtain the result of compiling.
Replace the first drawable _ demo. xml. flat under the directory build/mediadata/res/aggregated/{ browser }/{ build type } with/workDir/drawable _ demo.
Pack each fly file under the directory build/mediates/res/merged/{ viewer }/{ buildType }.
According to the technical scheme of the embodiment, the parent file name, the resource file name, the original storage directory and the modified storage directory of the new resource file of each modified source code are stored in an associated manner, and the search and the processing of the resource files with the same name are realized based on the matching of the information abstract values of the second resource files.
Example four
Fig. 8 is a document processing apparatus according to a fourth embodiment of the present disclosure, the apparatus including: a first compiling module 810, a changing module 820, a second compiling module 830, a replacing module 840 and a packing module 850.
The first compiling module 810 is configured to perform a compiling operation on each original resource file, so as to obtain first resource files corresponding to each original resource file one to one; a modification module 820, configured to modify, for each original resource file, a definition value of a first variable in a current original resource file based on a definition value of the first variable and a definition value of a second variable in the current original resource file, to obtain a modified new resource file, where the first variable and the second variable are defined separately in the original resource file; a second compiling module 830, configured to perform a compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file; a replacing module 840, configured to replace the first resource file with the second resource file; and a packaging module 850, configured to package the second resource file corresponding to each new resource file into an object file according to the storage directory of the first resource file, where the object file may be run on a terminal device to implement a setting function.
On the basis of the above technical solution, the apparatus further includes: a definition file generation module, configured to obtain a first variable from an original setting file before changing a definition value of the first variable in the current resource file based on the definition value of the first variable and a definition value of a second variable in the current original resource file, and generate a definition file of the first variable; the analysis module is used for analyzing the current original resource file to obtain a reference identifier of the first variable in the current original resource file; a first variable definition value determining module, configured to determine, based on the reference identifier, a definition value corresponding to the reference identifier from the definition file, and determine the definition value as a definition value of the first variable in the current original resource file; the original setting file comprises the first variable in each original resource file, the original setting file is obtained by respectively executing compiling operation on each original resource file in the development project, and the definition file comprises an identification ID (identity) of the first variable and a corresponding definition value.
On the basis of the above technical solutions, the changing module 820 includes: a determining unit, configured to determine a combined definition value of the first variable and the second variable based on a definition value of the first variable and a definition value of the second variable in a current original resource file; and the changing unit is used for changing the definition value of the first variable in the current original resource file into the combined definition value to obtain a new changed resource file.
On the basis of the above technical solutions, if the first variable is a color and the second variable is a transparency, the determining unit is specifically configured to convert the definition value of the second variable into a two-bit hexadecimal number based on a set conversion rule; and splicing the two-bit hexadecimal digit and the six-bit hexadecimal digit of the first variable according to a preset format to obtain the combined definition value.
On the basis of the above technical solutions, if the defined attribute of the first variable is direct coding, the changing unit is specifically configured to: and changing the encoding of the definition value of the first variable into the encoding of the combined definition value.
On the basis of the above technical solutions, if the definition attribute of the first variable is a reference, the changing unit is specifically configured to: generating a reference identifier corresponding to the combined definition value code based on a preset rule;
changing the reference identifier of the first variable into a reference identifier corresponding to the combined definition value code;
writing the mapping relation between the reference identifier corresponding to the combined definition value code and the combined definition value code into an intermediate file;
and when the definition value of the first variable in each original resource file in the development project is changed, writing the mapping relation in the intermediate file into the original setting file to obtain a latest setting file.
On the basis of the above technical solutions, the first compiling module 810 is further configured to: compiling the latest setting file to obtain a second setting file corresponding to the latest setting file; the replacement module 840 is further configured to: replacing a first setting file obtained when compiling operation is performed on the original setting file by using the second setting file; the packing module 850 is further configured to: and packaging the second setting file and the second resource file into a target file according to the storage directory of the first setting file and the storage directory of the first resource file.
On the basis of the above technical solutions, the apparatus further includes: and the storage module is used for performing associated storage on the name of the current original resource file, the storage directory of the current original resource file and the storage directory of the new resource file after the changed new resource file is obtained, so as to obtain a storage record, and determining the resource file with the same name based on the storage record.
On the basis of the above technical solutions, the apparatus further includes: a determining module of a first resource file corresponding to the current original resource file, configured to determine, based on the storage record, whether an original resource file having a same name as the current original resource file exists before the compiling operation is performed on the new resource file, and if so, perform the compiling operation based on a storage directory of a target original resource file in the original resource file having the same name, to obtain a first target resource file corresponding to the target original resource file; generating an information abstract value of the first target resource file; comparing the information abstract value of the first target resource file with the information abstract value of each first resource file in the storage directory of the first resource file; and determining the first resource file consistent with the information abstract value of the first target resource file as the first resource file corresponding to the current original resource file.
On the basis of the above technical solutions, the formats of the first resource file and the second resource file are flat formats, and the original resource file includes an xml file.
According to the technical scheme of the embodiment of the disclosure, compiling operation is respectively executed on each original resource file in development engineering to obtain first resource files corresponding to each original resource file one by one; for each original resource file in a development project, changing the definition value of a first variable in the current original resource file based on the definition value of the first variable and the definition value of a second variable in the current original resource file to obtain a new changed resource file, wherein the first variable and the second variable are defined in the current original resource file separately; executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file; replacing the first resource file with the second resource file; and packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, wherein the target file can be operated in terminal equipment to realize a technical means of setting functions, so that the first variable and the second variable are separately defined in a specific development environment, the support of a syntax level is provided, and the aim of maintaining the combined variable of the first variable and the second variable at a later stage is facilitated.
The file processing device provided by the embodiment of the disclosure can execute the file processing method provided by any embodiment of the disclosure, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, the units and modules included in the apparatus are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the embodiments of the present disclosure.
EXAMPLE five
Referring now to fig. 9, a schematic diagram of an electronic device (e.g., the terminal device or the server in fig. 9) 400 suitable for implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 9, the electronic device 400 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 401 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage device 406 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the electronic apparatus 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
Generally, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 406 including, for example, magnetic tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device 400 to communicate wirelessly or by wire with other devices to exchange data. While fig. 9 illustrates an electronic device 400 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 409, or from the storage means 406, or from the ROM 402. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 401.
The terminal provided by the embodiment of the present disclosure and the file processing method provided by the embodiment belong to the same inventive concept, and technical details that are not described in detail in the embodiment of the present disclosure can be referred to the embodiment, and the embodiment of the present disclosure have the same beneficial effects.
EXAMPLE six
The disclosed embodiments provide a computer storage medium having stored thereon a computer program that, when executed by a processor, implements the file processing method provided by the above-described embodiments.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: 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 present disclosure, 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 system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either 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 also 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 system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to:
respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one by one;
for each original resource file, changing the definition value of a first variable in the current original resource file based on the definition value of the first variable and the definition value of a second variable in the current original resource file to obtain a new changed resource file, wherein the first variable and the second variable are defined in the current original resource file separately;
executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file;
replacing the first resource file with the second resource file;
and packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, wherein the target file can be operated in terminal equipment to realize a set function.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and 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).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a cell does not in some cases constitute a limitation on the cell itself, for example, an editable content display cell may also be described as an "editing cell".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on 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.
According to one or more embodiments of the present disclosure, [ example one ] there is provided a document processing method, including:
respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one by one;
for each original resource file, changing the definition value of a first variable in the current original resource file based on the definition value of the first variable and the definition value of a second variable in the current original resource file to obtain a new changed resource file, wherein the first variable and the second variable are defined in the current original resource file separately;
executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file;
replacing the first resource file with the second resource file;
and packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, wherein the target file can be operated in terminal equipment to realize a set function.
According to one or more embodiments of the present disclosure, in example two, there is provided a file processing method, optionally, before the modifying the defined value of the first variable in the current resource file based on the defined value of the first variable and the defined value of the second variable in the current original resource file, the method further includes:
acquiring the first variable from an original setting file, and generating a definition file of the first variable;
analyzing the current original resource file to obtain a reference identifier of the first variable in the current original resource file;
determining a definition value corresponding to the reference identifier from the definition file based on the reference identifier, and determining the definition value as the definition value of the first variable in the current original resource file;
the original setting file comprises the first variable in each original resource file, the original setting file is obtained by respectively executing compiling operation on each original resource file in the development project, and the definition file comprises an identification ID (identity) of the first variable and a corresponding definition value.
According to one or more embodiments of the present disclosure, in an example three, there is provided a file processing method, optionally, the modifying the definition value of the first variable in the current original resource file based on the definition value of the first variable and the definition value of the second variable in the current original resource file to obtain a modified new resource file, including:
determining a combined definition value of the first variable and the second variable based on the definition value of the first variable and the definition value of the second variable in the current original resource file;
and changing the definition value of the first variable in the current original resource file into the combined definition value to obtain a new resource file after changing.
According to one or more embodiments of the present disclosure, [ example four ] there is provided a document processing method, further comprising:
if the first variable is a color and the second variable is a transparency, determining a combined definition value of the first variable and the second variable based on the definition value of the first variable and the definition value of the second variable in the current original resource file includes:
converting the definition value of the second variable into a two-bit hexadecimal number based on a set conversion rule;
and splicing the two-bit hexadecimal digit and the six-bit hexadecimal digit of the first variable according to a preset format to obtain the combined definition value.
According to one or more embodiments of the present disclosure, [ example five ] there is provided a document processing method, further comprising:
optionally, if the definition attribute of the first variable is direct coding, changing the definition value of the first variable in the current original resource file to the combined definition value includes:
and changing the encoding of the definition value of the first variable into the encoding of the combined definition value.
According to one or more embodiments of the present disclosure, [ example six ] there is provided a method of establishing a multi-person session, further comprising:
optionally, if the definition attribute of the first variable is a reference, changing the definition value of the first variable in the current original resource file to the combined definition value includes:
generating a reference identifier corresponding to the combined definition value code based on a preset rule;
changing the reference identifier of the first variable into a reference identifier corresponding to the combined definition value code;
writing the mapping relation between the reference identifier corresponding to the combined definition value code and the combined definition value code into an intermediate file;
and when the definition value of the first variable in each original resource file in the development project is changed, writing the mapping relation in the intermediate file into the original setting file to obtain a latest setting file.
According to one or more embodiments of the present disclosure, [ example seven ] there is provided a document processing method, further comprising:
optionally, when the compiling operation is performed on the new resource file, the method further includes:
compiling the latest setting file to obtain a second setting file corresponding to the latest setting file;
replacing a first setting file obtained when compiling operation is performed on the original setting file by using the second setting file;
correspondingly, the step of packaging the second resource file corresponding to each new resource file into an object file according to the storage directory of the first resource file, where the object file can be run on a terminal device to implement a setting function, includes:
and packaging the second setting file and the second resource file into a target file according to the storage directory of the first setting file and the storage directory of the first resource file.
According to one or more embodiments of the present disclosure, [ example eight ] there is provided a document processing method, further comprising:
optionally, after obtaining the changed new resource file, the method further includes:
and performing associated storage on the name of the current original resource file, the storage directory of the current original resource file and the storage directory of the new resource file to obtain a storage record, and determining the resource file with the same name based on the storage record.
According to one or more embodiments of the present disclosure, [ example nine ] there is provided a document processing method, further comprising:
optionally, before the performing the compiling operation on the new resource file, the method further includes:
determining whether an original resource file with the same name as the current original resource file exists or not based on the storage record, if so, executing compilation operation based on a storage directory of a target original resource file in the original resource file with the same name to obtain a first target resource file corresponding to the target original resource file;
generating an information abstract value of the first target resource file;
comparing the information abstract value of the first target resource file with the information abstract value of each first resource file in the storage directory of the first resource file;
and determining the first resource file consistent with the information abstract value of the first target resource file as the first resource file corresponding to the current original resource file.
According to one or more embodiments of the present disclosure, [ example ten ] there is provided a document processing method, further comprising:
optionally, the format of the first resource file and the format of the second resource file are flat format, and the original resource file includes an xml file.
According to one or more embodiments of the present disclosure, [ example eleven ] there is provided a document processing apparatus including:
the first compiling module is used for respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one by one;
a modification module, configured to modify, for each original resource file, a definition value of a first variable in a current original resource file based on a definition value of the first variable and a definition value of a second variable in the current original resource file, to obtain a modified new resource file, where the first variable and the second variable are defined separately in the original resource file;
the second compiling module is used for executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file;
a replacement module for replacing the first resource file with the second resource file;
and the packaging module is used for packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, and the target file can be operated in terminal equipment to realize a set function.
According to one or more embodiments of the present disclosure, [ example twelve ] there is provided an electronic device comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the file processing method of any one of claims 1-10.
According to one or more embodiments of the present disclosure, [ example thirteen ] there is provided a storage medium containing computer-executable instructions for performing the file processing method according to any one of claims 1 to 10 when executed by a computer processor.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims (12)

1. A file processing method, comprising:
respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one by one;
for each original resource file, changing the definition value of a first variable in the current original resource file based on the definition value of the first variable and the definition value of a second variable in the current original resource file to obtain a new changed resource file, wherein the first variable and the second variable are defined in the current original resource file separately;
executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file;
replacing the first resource file with the second resource file;
and packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, wherein the target file can be operated in terminal equipment to realize a set function.
2. The method according to claim 1, wherein before changing the definition value of the first variable in the current resource file based on the definition value of the first variable and the definition value of the second variable in the current original resource file, the method further comprises:
acquiring the first variable from an original setting file, and generating a definition file of the first variable;
analyzing the current original resource file to obtain a reference identifier of the first variable in the current original resource file;
determining a definition value corresponding to the reference identifier from the definition file based on the reference identifier, and determining the definition value as the definition value of the first variable in the current original resource file;
the original setting file comprises the first variable in each original resource file, the original setting file is obtained by respectively executing compiling operation on each original resource file in the development project, and the definition file comprises an identification ID (identity) of the first variable and a corresponding definition value.
3. The method according to claim 2, wherein the modifying the definition value of the first variable in the current original resource file based on the definition value of the first variable and the definition value of the second variable in the current original resource file to obtain a modified new resource file comprises:
determining a combined definition value of the first variable and the second variable based on the definition value of the first variable and the definition value of the second variable in the current original resource file;
and changing the definition value of the first variable in the current original resource file into the combined definition value to obtain a new resource file after changing.
4. The method of claim 3, wherein if the first variable is color and the second variable is transparency, the determining the combined definition value of the first variable and the second variable based on the definition value of the first variable and the definition value of the second variable in the current original resource file comprises:
converting the definition value of the second variable into a two-bit hexadecimal number based on a set conversion rule;
and splicing the two-bit hexadecimal digit and the six-bit hexadecimal digit of the first variable according to a preset format to obtain the combined definition value.
5. The method according to claim 3, wherein if the definition attribute of the first variable is direct coding, the changing the definition value of the first variable in the current original resource file to the combined definition value comprises:
and changing the encoding of the definition value of the first variable into the encoding of the combined definition value.
6. The method according to claim 3, wherein if the definition attribute of the first variable is a reference, the changing the definition value of the first variable in the current original resource file to the combined definition value comprises:
generating a reference identifier corresponding to the combined definition value code based on a preset rule;
changing the reference identifier of the first variable into a reference identifier corresponding to the combined definition value code;
writing the mapping relation between the reference identifier corresponding to the combined definition value code and the combined definition value code into an intermediate file;
and when the definition value of the first variable in each original resource file in the development project is changed, writing the mapping relation in the intermediate file into the original setting file to obtain a latest setting file.
7. The method of claim 6, wherein when performing the compilation operation on the new resource file, further comprising:
compiling the latest setting file to obtain a second setting file corresponding to the latest setting file;
replacing a first setting file obtained when compiling operation is performed on the original setting file by using the second setting file;
correspondingly, the packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file includes:
and packing the second setting file and the second resource file corresponding to each new resource file into a target file according to the storage directory of the first setting file and the storage directory of the first resource file.
8. The method according to any one of claims 1-7, wherein after obtaining the changed new resource file, further comprising:
and performing associated storage on the name of the current original resource file, the storage directory of the current original resource file and the storage directory of the new resource file to obtain a storage record, and determining the resource file with the same name based on the storage record.
9. The method of claim 8, wherein before performing the compilation operation on the new resource file, further comprising:
determining whether an original resource file with the same name as the current original resource file exists or not based on the storage record, if so, executing compilation operation based on a storage directory of a target original resource file in the original resource file with the same name to obtain a first target resource file corresponding to the target original resource file;
generating an information abstract value of the first target resource file;
comparing the information abstract value of the first target resource file with the information abstract value of each first resource file in the storage directory of the first resource file;
and determining the first resource file consistent with the information abstract value of the first target resource file as the first resource file corresponding to the current original resource file.
10. A document processing apparatus, characterized by comprising:
the first compiling module is used for respectively executing compiling operation on each original resource file to obtain first resource files corresponding to the original resource files one by one;
a modification module, configured to modify, for each original resource file, a definition value of a first variable in a current original resource file based on a definition value of the first variable and a definition value of a second variable in the current original resource file, to obtain a modified new resource file, where the first variable and the second variable are defined separately in the original resource file;
the second compiling module is used for executing compiling operation on the new resource file to obtain a second resource file corresponding to the new resource file;
a replacement module for replacing the first resource file with the second resource file;
and the packaging module is used for packaging the second resource file corresponding to each new resource file into a target file according to the storage directory of the first resource file, and the target file can be operated in terminal equipment to realize a set function.
11. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the file processing method of any one of claims 1-9.
12. A storage medium containing computer-executable instructions for performing the file processing method of any of claims 1-9 when executed by a computer processor.
CN202010837989.7A 2020-08-19 2020-08-19 File processing method and device, electronic equipment and storage medium Pending CN112000340A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010837989.7A CN112000340A (en) 2020-08-19 2020-08-19 File processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010837989.7A CN112000340A (en) 2020-08-19 2020-08-19 File processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112000340A true CN112000340A (en) 2020-11-27

Family

ID=73473673

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010837989.7A Pending CN112000340A (en) 2020-08-19 2020-08-19 File processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112000340A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2463771A1 (en) * 2010-12-09 2012-06-13 Bull HN Information Systems Inc. Method for translating a cobol source program into readable and maintainable program code in an object oriented second programming language
CN107122219A (en) * 2017-03-31 2017-09-01 腾讯科技(深圳)有限公司 The acquisition methods and device of installation file
WO2017185606A1 (en) * 2016-04-29 2017-11-02 乐视控股(北京)有限公司 Overlay mechanism-based apk development method and system
CN107368292A (en) * 2017-03-29 2017-11-21 阿里巴巴集团控股有限公司 A kind of resource Compilation Method and device
CN107506182A (en) * 2017-07-27 2017-12-22 努比亚技术有限公司 Software layout method, software merit rating device and computer-readable recording medium
CN111309335A (en) * 2020-02-28 2020-06-19 腾讯音乐娱乐科技(深圳)有限公司 Plug-in application compiling method and device and computer readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2463771A1 (en) * 2010-12-09 2012-06-13 Bull HN Information Systems Inc. Method for translating a cobol source program into readable and maintainable program code in an object oriented second programming language
WO2017185606A1 (en) * 2016-04-29 2017-11-02 乐视控股(北京)有限公司 Overlay mechanism-based apk development method and system
CN107368292A (en) * 2017-03-29 2017-11-21 阿里巴巴集团控股有限公司 A kind of resource Compilation Method and device
CN107122219A (en) * 2017-03-31 2017-09-01 腾讯科技(深圳)有限公司 The acquisition methods and device of installation file
CN107506182A (en) * 2017-07-27 2017-12-22 努比亚技术有限公司 Software layout method, software merit rating device and computer-readable recording medium
CN111309335A (en) * 2020-02-28 2020-06-19 腾讯音乐娱乐科技(深圳)有限公司 Plug-in application compiling method and device and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
JAVASHUO: "Android 颜色色值与 alpha 分离解决方案", pages 1 - 4, Retrieved from the Internet <URL:http://www.javashuo.com/article/p-djialzrk-x.html> *

Similar Documents

Publication Publication Date Title
CN111324342B (en) Method, device, medium and electronic equipment for generating interface layer code
CN112395253B (en) Index file generation method, terminal device, electronic device and medium
CN109726217B (en) Database operation method, device, equipment and storage medium
CN111309375B (en) Method, device, medium and electronic equipment for generating remote procedure call toolkit
CN114035879A (en) Page theme color changing method and device, electronic equipment and computer readable medium
CN110764748A (en) Code calling method, device, terminal and storage medium
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN112965713B (en) Development method, device, equipment and storage medium of visual editor
CN113407165B (en) SDK generation and self-upgrade method, device, readable medium and equipment
CN111124541A (en) Configuration file generation method, device, equipment and medium
CN112416303B (en) Software development kit hot repair method and device and electronic equipment
CN110704050B (en) Module initializing method and device, electronic equipment and computer readable storage medium
CN112000340A (en) File processing method and device, electronic equipment and storage medium
CN111078230A (en) Code generation method and device
CN109815455A (en) Item file treating method and apparatus
CN113391811B (en) Function compiling method, function compiling device, electronic equipment and computer readable storage medium
CN111625232B (en) Method and device for generating application program installation package, readable medium and electronic equipment
CN111008178B (en) Data processing method, device, electronic equipment and computer readable storage medium
CN113709171A (en) Method and device for cross-component state communication
CN112162755A (en) Data processing method, device, medium and electronic equipment
CN111240657A (en) Method and device for generating SDK and electronic equipment
CN113918164B (en) Method and device for generating application program package, readable medium and electronic equipment
CN114047922B (en) Transcoding method, device, medium and equipment for precompiled device
CN115617818B (en) Batch updating method, electronic device and storage medium for MPT trees in block chain
CN111382389B (en) Multi-theme page generation method and device, electronic 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