File processing method, terminal and computer readable storage medium

文档序号:510411 发布日期:2021-05-28 浏览:2次 中文

阅读说明:本技术 文件处理方法、终端及计算机可读存储介质 (File processing method, terminal and computer readable storage medium ) 是由 魏新宇 张攀 陈伦广 曹菲 于 2021-01-22 设计创作,主要内容包括:本发明提出一种文件处理方法、终端及计算机可读存储介质,所述方法包括步骤:在接收到整理运行指令时,获取所述整理运行指令对应的执行目录;生成与所述执行目录对应的第一源文件列表,并判断所述执行目录中是否包括历史源文件列表;若是,则获取在所述第一源文件列表中,且不在所述历史源文件列表中的待执行文件;对所述待执行文件执行整理操作,并根据所述第一源文件列表对所述历史源文件列表进行更新。通过查找并仅针对未执行过整理操作的文件进行整理操作,极大地降低了操作的时间。(The invention provides a file processing method, a terminal and a computer readable storage medium, wherein the method comprises the following steps: when a sorting operation instruction is received, acquiring an execution catalog corresponding to the sorting operation instruction; generating a first source file list corresponding to the execution catalog, and judging whether the execution catalog comprises a history source file list or not; if yes, acquiring a file to be executed in the first source file list and not in the history source file list; and executing a sorting operation on the file to be executed, and updating the history source file list according to the first source file list. By searching and only carrying out the sorting operation on the files which are not subjected to the sorting operation, the operation time is greatly reduced.)

1. A method of file processing, the method comprising:

when a sorting operation instruction is received, acquiring an execution catalog corresponding to the sorting operation instruction;

generating a first source file list corresponding to the execution catalog, and judging whether the execution catalog comprises a history source file list or not;

if yes, acquiring a file to be executed in the first source file list and not in the history source file list;

and executing a sorting operation on the file to be executed, and updating the history source file list according to the first source file list.

2. The file processing method of claim 1, wherein said step of determining whether the execution directory includes a list of historical source files further comprises, after said step of determining whether the execution directory includes a list of historical source files:

and if not, taking the file in the first source file list as a file to be executed.

3. The file processing method according to claim 1, wherein the step of generating the first source file list corresponding to the execution directory comprises:

acquiring the file name and the characteristic data of each file in the execution directory;

and associating the file name of each file with the characteristic data to obtain the first source file list.

4. The file processing method according to claim 3, wherein the step of performing a sorting operation on the file to be executed comprises:

acquiring each file name suffix, and judging the processing type of each file according to each file name suffix;

dividing each file into a buffer area corresponding to the processing type according to the processing type of each file;

and performing sorting operation corresponding to the buffer area on the file in each buffer area.

5. The file processing method according to claim 4, wherein the processing type includes a picture type, a JSON file type, and other types; the step of performing the sorting operation corresponding to the buffer area in which the file is located on each buffer area comprises the following steps:

when the buffer area is the buffer area corresponding to the picture type, compressing the file in the buffer area and outputting the compressed file to a preset output path corresponding to the buffer area;

when the buffer zone is a buffer zone corresponding to the JSON file type, compressing the file in the buffer zone and outputting the compressed file to a preset output path corresponding to the buffer zone;

when the buffer area is the buffer area corresponding to other types, the file in the buffer area is copied, and the obtained copied file is output to the preset output path corresponding to the buffer area.

6. The file processing method according to claim 5, wherein the step of generating the first source file list corresponding to the execution directory is preceded by:

and clearing the preset output path.

7. The document processing method according to any one of claims 1 to 6, further comprising:

acquiring the number of the files to be executed, and acquiring the finished number of the files which are finished with the finishing operation in real time in the process of executing the finishing operation on the files to be executed;

obtaining operation progress according to the number of the files to be executed and the completion number;

and displaying the operation progress.

8. The file processing method according to claim 7, wherein the step of determining whether the execution directory includes the list of history source files is preceded by:

judging whether the execution directory is an empty directory;

if yes, displaying empty directory prompt information;

if not, executing the following steps: it is determined whether a history source file list is included in the execution directory.

9. A terminal, characterized in that it comprises a memory, a processor and a computer program stored on said memory and executable on said processor, said computer program, when executed by said processor, implementing the steps of the file processing method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that a computer program is stored thereon, which computer program, when being executed by a processor, carries out the steps of the file processing method according to any one of claims 1 to 8.

Technical Field

The present invention relates to the field of software development, and in particular, to a file processing method, a terminal, and a computer-readable storage medium.

Background

With the rapid development of mini games, more and more platforms have started to build their own mini game ecology, which is called mini games because these game resources are stored in a CDN (Content Delivery Network) remote server through operations such as sorting, compression, and the like, thereby ensuring that the parent package body is small. However, the existing scheme can operate on all files each time the compression is finished, so that the finishing time is long.

Disclosure of Invention

The invention mainly aims to provide a file processing method, a terminal and a computer readable storage medium, and aims to solve the problem that in the prior art, the arrangement time is long because all files are operated when the compression is arranged each time.

In order to achieve the above object, the present invention provides a file processing method, including the steps of:

when a sorting operation instruction is received, acquiring an execution catalog corresponding to the sorting operation instruction;

generating a first source file list corresponding to the execution catalog, and judging whether the execution catalog comprises a history source file list or not;

if yes, acquiring a file to be executed in the first source file list and not in the history source file list;

and executing a sorting operation on the file to be executed, and updating the history source file list according to the first source file list.

Optionally, after the step of determining whether the execution directory includes the history source file list, the method further includes:

and if not, taking the file in the first source file list as a file to be executed.

Optionally, the step of generating a first source file list corresponding to the execution directory includes:

acquiring the file name and the characteristic data of each file in the execution directory;

and associating the file name of each file with the characteristic data to obtain the first source file list.

Optionally, the step of performing a sorting operation on the file to be executed includes:

acquiring each file name suffix, and judging the processing type of each file according to each file name suffix;

dividing each file into a buffer area corresponding to the processing type according to the processing type of each file;

and performing sorting operation corresponding to the buffer area on the file in each buffer area.

Optionally, the processing type includes a picture type, a JSON file type, and other types; the step of performing the sorting operation corresponding to the buffer area in which the file is located on each buffer area comprises the following steps:

when the buffer area is the buffer area corresponding to the picture type, compressing the file in the buffer area and outputting the compressed file to a preset output path corresponding to the buffer area;

when the buffer zone is a buffer zone corresponding to the JSON file type, compressing the file in the buffer zone and outputting the compressed file to a preset output path corresponding to the buffer zone;

when the buffer area is the buffer area corresponding to other types, the file in the buffer area is copied, and the obtained copied file is output to the preset output path corresponding to the buffer area.

Optionally, the step of generating the first source file list corresponding to the execution directory includes:

and clearing the preset output path.

Optionally, the method further comprises:

acquiring the number of the files to be executed, and acquiring the finished number of the files which are finished with the finishing operation in real time in the process of executing the finishing operation on the files to be executed;

obtaining operation progress according to the number of the files to be executed and the completion number;

and displaying the operation progress.

Optionally, the step of determining whether the execution directory includes the history source file list includes:

judging whether the execution directory is an empty directory;

if yes, displaying empty directory prompt information;

if not, executing the following steps: it is determined whether a history source file list is included in the execution directory.

To achieve the above object, the present invention further provides a terminal including a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program implementing the steps of the file processing method as described above when executed by the processor.

To achieve the above object, the present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the file processing method as described above.

According to the file processing method, the terminal and the computer readable storage medium, when a sorting operation instruction is received, an execution directory corresponding to the sorting operation instruction is obtained; generating a first source file list corresponding to the execution catalog, and judging whether the execution catalog comprises a history source file list or not; if yes, acquiring a file to be executed in the first source file list and not in the history source file list; and executing a sorting operation on the file to be executed, and updating the history source file list according to the first source file list. By acquiring the files to be executed in the first source file list and not in the history source file list, only the files which are not subjected to the sorting operation can be processed in the sorting operation, and the files which are subjected to the sorting operation are not processed, so that the operation time is greatly reduced.

Drawings

FIG. 1 is a schematic flow chart diagram illustrating a first embodiment of a document processing method according to the present invention;

FIG. 2 is a detailed flowchart of step S20 of the document processing method according to the third embodiment of the present invention;

fig. 3 is a schematic structural diagram of a module of the terminal of the present invention.

Detailed Description

It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

The invention provides a file processing method, which is applied to a terminal, and referring to fig. 1, fig. 1 is a schematic flow diagram of a first embodiment of the file processing method, and the method comprises the following steps:

step S10, when a sorting operation instruction is received, acquiring an execution catalog corresponding to the sorting operation instruction;

and the sorting operation instruction is sent by a user through selecting a corresponding operation button on an operation interface. The user can also perform related setting on the operation interface, such as executing a directory, presetting an output path, and the like, where the executing directory is a source directory, a file included in the executing directory is an object that needs to be subjected to a sorting operation, and the executing directory in this embodiment is a processDir; the preset output path is an output directory, and the files after the sorting operation are output to the preset output path, where the preset output path in this embodiment is output dir.

Step S20, generating a first source file list corresponding to the execution directory, and determining whether the execution directory includes a history source file list;

traversing all files in the execution directory, and generating a first source file list according to the information of each file; the information of all files in the execution catalog is recorded in the first source file list in a one-to-one correspondence manner; the history source file list is a source file list formed according to files in the execution directory at the time when the sorting operation is executed last time. The first source file list name and the history source file list name in this embodiment are: lathprojectres.

Further, when the user sends a sorting operation instruction, the user can select full-amount sorting or incremental sorting on an operation interface; if the user selects the increment finishing, the terminal starts to execute the step S20 when receiving a finishing operation instruction of the increment finishing; if the user selects the full collation, the terminal, when receiving the collation execution instruction of the full collation, does not need to execute the operation of generating the source file list in step S20, and directly performs the collation operation on all the files in the execution directory. The user can select the full amount or the increment sorting according to the actual requirement, and the flexibility of the scheme is improved.

Step S30, if yes, acquiring a file to be executed in the first source file list, which is not in the history source file list;

when the execution directory has a history source file list, the files in the execution directory are subjected to the sorting operation before, and at this time, for the files subjected to the sorting operation in the last sorting operation, the sorting operation does not need to be executed again; therefore, files which are already subjected to the sorting operation in the first source file list, namely files in the history source file list, need to be excluded; and only files which are in the first source file list and are not in the history source file list are reserved and taken as files to be executed.

Step S40, performing a sorting operation on the file to be executed, and updating the history source file list according to the first source file list.

After the sorting operation is performed on the files to be executed, the files on which the sorting operation is performed need to be recorded, so that the files can be eliminated when the sorting operation is performed next time, and therefore, the history source file list is updated according to the first source file list; specifically, information corresponding to the execution files in the first source file list is added to the history source file list to form a new history source file list.

In the embodiment, by acquiring the files to be executed in the first source file list and not in the history source file list, only the files which are not subjected to the sorting operation can be processed in the sorting operation, and the files which are subjected to the sorting operation once are not processed, so that the operation time is greatly reduced.

Further, in the second embodiment of the file processing method according to the present invention proposed based on the first embodiment of the present invention, the step S20 is followed by the step of:

step S50, if not, taking the file in the first source file list as the file to be executed.

When the execution directory does not have a history file list, the finishing operation is not executed before, and all files in the execution directory need to be executed at the moment; all files in the directory, i.e., files in the first source file list, are executed as files to be executed.

When the sorting operation is executed for the first time, the sorting operation can be reasonably executed on all files in the execution directory.

Further, referring to fig. 2, in a third embodiment of the file processing method according to the present invention proposed based on the first embodiment of the present invention, the step of generating the first source file list corresponding to the execution directory in the step S20 includes:

step S21, obtaining the file name and the characteristic data of each file in the execution directory;

step S22, associating the file name of each file with the feature data to obtain the first source file list.

The file name of the file consists of a file name and a file name suffix; the characteristic data is used for characterizing the file, and in the embodiment, the characteristic data comprises an MD5 value and a file size value; associating the file name corresponding to the file with the characteristic data to obtain a group of source file data corresponding to the key; the set of source file data corresponding to all files in the execution directory is the first source file list.

When judging whether the files in the first source file list are in the history source file list, firstly judging different files in the first source file list and the history source file list through file names, and when the file names are different, determining that the two files are different; and further screening files with the same name in the first source file list and the historical source file list by taking the MD5 value and the file size value of the files as the basis, and when any one of the MD5 value and the file size value is different, considering that the two files are different.

The embodiment can reasonably judge whether the files in the first source file list and the history source file list are the same.

Further, in a fourth embodiment of the file processing method according to the present invention proposed based on the third embodiment of the present invention, the step S40 includes the steps of:

step S41, acquiring each file name suffix, and judging the processing type of each file according to each file name suffix;

step S42, dividing each file into buffer areas corresponding to the processing types according to the processing types of each file;

in step S43, a sorting operation corresponding to the buffer is performed on the file in each buffer.

The step S43 includes the steps of:

step S431, when the buffer area is a buffer area corresponding to the picture type, compressing the file in the buffer area and outputting the compressed file to a preset output path corresponding to the buffer area;

step S432, when the buffer area is the buffer area corresponding to the JSON file type, compressing the file in the buffer area and outputting the compressed file to a preset output path corresponding to the buffer area;

step S433, when the buffer area is a buffer area corresponding to another type, copying the file in the buffer area, and outputting the obtained copied file to a preset output path corresponding to the buffer area.

The step S20 is preceded by the steps of:

step S60, clearing the preset output path.

The sorting operation instruction further comprises a file sorting standard list; the list of file sorting criteria may be set by a user at an operation interface, which characterizes the correspondence between the file name suffix and the processing type. Specifically, in the present embodiment, the processing types include a picture type, a JSON (JavaScript Object Notation) file type, and other types; the file name suffixes corresponding to the picture types comprise ". jpg", ". png", ". gif", and ". ico"; the filename suffix corresponding to the JSON file type includes ". JSON"; the file name suffixes which are divided into other types or are not divided into the picture type or the JSON file type in the file classification standard list are file name suffixes corresponding to other types, such as ". mp 3" and ". ttf". It is understood that the suffix of the file name corresponding to the file type can be extended or reduced according to the existing classification rules and the user's needs. It should be noted that, the user may increase or decrease the types of the file types according to the actual requirement, for example, increase the types of videos or text types; while correspondingly increasing or decreasing the buffer.

The arranging and running instruction further comprises a path list which records preset output paths corresponding to the files, and the preset output paths are identified by absolute paths, so that the relative paths of the files which are arranged and the files which are subjected to the arranging operation at this time are not changed.

Before the sorting operation is executed, the files and the folders in the preset output path are deleted, so that the conflict with the files subjected to the sorting operation is avoided. Meanwhile, each buffer area is clear, and conflict with files needing to be sorted is avoided.

In this embodiment, the buffer corresponding to the picture type is IMAGEFILES _ CACHE; the buffer area corresponding to the JSON file type is JSONFILES _ CACHE; the other type of corresponding buffer is OTHERFOLES _ CACHE. The picture type files are stored in IMAGEFILES _ CACHE, the json type files are stored in JSONFILES _ CACHE, and other types of files are stored in OTHERFOLES _ CACHE.

After the files in the execution directory are divided into the corresponding buffer areas, the files in the buffer areas are orderly arranged. Specifically, all files in the OTHERFOLES _ CACHE are copied, and the copied files are sequentially stored into a preset output path in an absolute path; then, compressing the file in the JSONFILES _ CACHE, in this embodiment, compressing the file in the JSONFILES _ CACHE by a self-contained deffler of JDK (Java Development Kit, Java Development tool), and saving the compressed json file to a preset output path in an absolute path; finally, the files in IMAGEFILES _ CACHE are sequentially taken out for compression operation; in the embodiment, a picture compression plug-in is used for compressing the file in IMAGEFILES _ CACHE, and the picture compression plug-in the embodiment adopts imageminJpegtran and imageminPngquant; meanwhile, setting the quality of the plug-in unit as a quality parameter of 0.5, 0.6; and saving the compressed picture type file to a preset output path by an absolute path.

The embodiment can reasonably carry out the sorting operation on various types of files.

Further, in a fifth embodiment of the file processing method according to the present invention proposed based on the first embodiment of the present invention, the method further includes the steps of:

step S70, acquiring the number of the files to be executed, and acquiring the finished number of the files which have finished the finishing operation in real time in the process of executing the finishing operation on the files to be executed;

step S80, obtaining operation progress according to the number of the files to be executed and the completion number;

and step S90, displaying the operation progress.

The number of the files to be executed is the target processing number, the completion number and the current completion progress of the sorting operation. And displaying the operation progress obtained according to the number of the files to be executed and the completion number in real time, so that the user can observe the operation progress in real time. The operation progress can be displayed in a percentage mode; and displaying by adopting a specific completion proportion number, namely, the numerator is the completion number, and the denominator is the number of the files to be executed. Furthermore, the operation progress can be displayed for each buffer zone independently. The user can select a suitable display mode according to actual needs, and is not limited herein.

The embodiment can enable a user to clearly see the whole flow and the file sorting progress.

Further, in a sixth embodiment of the file processing method according to the present invention as set forth in the fifth embodiment of the present invention, the step of determining whether the execution directory includes the history source file list in said step S20 is preceded by the steps of:

step S23, determining whether the execution directory is an empty directory;

step S24, if yes, displaying empty directory prompt information;

step S25, if not, executing the steps of: it is determined whether a history source file list is included in the execution directory.

When the execution directory is an empty directory, the file does not exist in the execution directory at the moment, and therefore empty directory prompt information is displayed to remind a user whether the execution directory is set to be wrong or not. When the execution directory is not an empty directory, the execution of the finishing operation may begin.

The embodiment can remind the user when the user sets the execution directory error so that the user can check in time.

Referring to fig. 3, the terminal may include components of a communication module 10, a memory 20, and a processor 30 in a hardware structure. In the terminal, the processor 30 is connected to the memory 20 and the communication module 10, respectively, the memory 20 stores thereon a computer program, which is executed by the processor 30 at the same time, and when executed, implements the steps of the above-mentioned method embodiments.

The communication module 10 may be connected to an external communication device through a network. The communication module 10 may receive a request from an external communication device, and may also send a request, an instruction, and information to the external communication device, where the external communication device may be another terminal, a server, or an internet of things device, such as a television.

The memory 20 may be used to store software programs as well as various data. The memory 20 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (for example, generating a first source file list corresponding to the execution directory, and determining whether the execution directory includes a history source file list), and the like; the storage data area may include a database, and the storage data area may store data or information created according to use of the system, or the like. Further, the memory 20 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.

The processor 30, which is a control center of the terminal, connects various parts of the entire terminal using various interfaces and lines, and performs various functions of the terminal and processes data by operating or executing software programs and/or modules stored in the memory 20 and calling data stored in the memory 20, thereby performing overall monitoring of the terminal. Processor 30 may include one or more processing units; alternatively, the processor 30 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 30.

Although not shown in fig. 3, the terminal may further include a circuit control module for connecting with a power supply to ensure the normal operation of other components. Those skilled in the art will appreciate that the terminal structure shown in fig. 3 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.

The invention also proposes a computer-readable storage medium on which a computer program is stored. The computer-readable storage medium may be the Memory 20 in the terminal in fig. 3, and may also be at least one of a ROM (Read-Only Memory)/RAM (Random Access Memory), a magnetic disk, and an optical disk, and the computer-readable storage medium includes several instructions for enabling a terminal device (which may be a television, an automobile, a mobile phone, a computer, a server, a terminal, or a network device) having a processor to execute the method according to the embodiments of the present invention.

In the present invention, the terms "first", "second", "third", "fourth" and "fifth" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance, and those skilled in the art can understand the specific meanings of the above terms in the present invention according to specific situations.

In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.

Although the embodiment of the present invention has been shown and described, the scope of the present invention is not limited thereto, it should be understood that the above embodiment is illustrative and not to be construed as limiting the present invention, and that those skilled in the art can make changes, modifications and substitutions to the above embodiment within the scope of the present invention, and that these changes, modifications and substitutions should be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

12页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种图形特征的动画文件查找系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!