CN107924397B - File editing method and file editor - Google Patents

File editing method and file editor Download PDF

Info

Publication number
CN107924397B
CN107924397B CN201580080837.4A CN201580080837A CN107924397B CN 107924397 B CN107924397 B CN 107924397B CN 201580080837 A CN201580080837 A CN 201580080837A CN 107924397 B CN107924397 B CN 107924397B
Authority
CN
China
Prior art keywords
file
data unit
file block
editor
basic data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201580080837.4A
Other languages
Chinese (zh)
Other versions
CN107924397A (en
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.)
Shenzhen A&E Intelligent Technology Institute Co Ltd
Original Assignee
Shenzhen A&E Intelligent Technology Institute 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 Shenzhen A&E Intelligent Technology Institute Co Ltd filed Critical Shenzhen A&E Intelligent Technology Institute Co Ltd
Publication of CN107924397A publication Critical patent/CN107924397A/en
Application granted granted Critical
Publication of CN107924397B publication Critical patent/CN107924397B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a file editing method and a file editor (400, 500 and 600), wherein the method comprises the following steps: when the file editors (400, 500 and 600) carry out target modification (101, 204 and 301) on a first file block of a file to be processed, the file editors (400, 500 and 600) record target modification information and position information (102, 205 and 302) of the first file block to obtain a target basic data unit; when the file editor (400, 500 and 600) receives a recovery or undo instruction (105, 211 and 309), the file editor (400, 500 and 600) can determine that the basic data unit corresponding to the recovery or undo instruction is the target basic data unit (106, 212 and 310), the file editor (400, 500 and 600) reads the first file block (107, 213 and 311) from the external storage according to the position information of the first file block, and the file editor (400, 500 and 600) recovers or undoes the first file block (108, 215 and 312) according to the target modified information. Since the file editors (400, 500 and 600) do not need to load the whole file content into the memory when recovering or revoking the file content, the system performance is not affected.

Description

File editing method and file editor
Technical Field
The present invention relates to the field of file processing, and in particular, to a file editing method and a file editor.
Background
Users typically need to perform editing operations such as reading, modifying, restoring and undoing the contents of a file through a file editor. The editing of the file content by the file editor needs to be established on the basis of loading the file content into the memory.
In the prior art, a file editor needs to load all file contents into a memory first, when a user modifies the file contents, the file editor records the modified file contents and the positions of the modified file contents in a file to generate a basic data unit, and then can perform recovery and revocation operations on the file contents loaded into the memory according to the basic data unit.
In the prior art, when a file editor recovers and cancels the file content, all the file content of the file is loaded into a memory first, and particularly, as the capacity of the file gradually increases, the memory resource occupied by loading all the file content becomes larger and larger, which affects the system performance.
Disclosure of Invention
An aspect of an embodiment of the present invention provides a file editing method, including:
the file editor carries out target modification on a first file block of a file to be processed and records target modification information and position information of the first file block to obtain a target basic data unit, wherein the target modification information comprises target modification content and position information of the target modification content in the first file block;
the file editor stores the target basic data unit behind the first basic data unit pointed by the current modification identifier in the data linked list and points the current modification identifier to the target basic data unit;
the file editor receives a recovery or revocation instruction;
the file editor determines the basic data unit corresponding to the recovery or revocation instruction as a target basic data unit according to the current modification identifier;
the file editor reads the first file block from the external memory according to the position information of the first file block;
and the file editor recovers or cancels the first file block according to the target modified information.
With reference to the first aspect, in a first possible implementation manner of the first aspect, the file editor receives a save instruction; and the file editor stores the first file block and points the storage modification identifier to a second basic data unit, wherein the second basic data unit is the basic data unit pointed by the current modification identifier.
With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the file editor restores or cancels the first file block according to an order from a start point to an end point of a target basic data unit segment of the data link list, where the start point of the basic data unit segment is a second basic data unit to which the storage modification identifier points, and the end point of the basic data unit segment is a third basic data unit to which the current modification identifier points.
With reference to any one of the first aspect, the first possible implementation manner of the first aspect, and the second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, the location information of the first file block includes at least two of a start location, an end location, and a length of the first file block in a file overall.
With reference to the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, and the third possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, the location information of the first file block is a storage location of the first file block in the external memory.
With reference to the third possible implementation manner of the first aspect, in a fifth possible implementation manner of the first aspect, the file editor receives a save instruction; the file editor updates the location information of the first file block in the target base data unit.
With reference to the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, the third possible implementation manner of the first aspect, the fourth possible implementation manner of the first aspect, and the fifth possible implementation manner of the first aspect, in a sixth possible implementation manner of the first aspect, the file editor deletes the first file block from the memory, and reads and displays the second file block of the file to be processed from the external storage.
With reference to the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, the third possible implementation manner of the first aspect, the fourth possible implementation manner of the first aspect, the fifth possible implementation manner of the first aspect, and the sixth possible implementation manner of the first aspect, in a seventh possible implementation manner of the first aspect, the file editor stores the first file block according to the location information of the first file block.
With reference to the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, the third possible implementation manner of the first aspect, the fourth possible implementation manner of the first aspect, the fifth possible implementation manner of the first aspect, the sixth possible implementation manner of the first aspect, and the seventh possible implementation manner of the first aspect, in an eighth possible implementation manner of the first aspect, the file editor determines whether the second file block and the first file block are the same file block;
if so, triggering the operation of recovering or canceling the first file block according to the target modified information;
if not, triggering the operation of reading the first file block from the external memory according to the position information of the first file block.
With reference to any one of the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, the third possible implementation manner of the first aspect, the fourth possible implementation manner of the first aspect, the fifth possible implementation manner of the first aspect, the sixth possible implementation manner of the first aspect, the seventh possible implementation manner of the first aspect, and the eighth possible implementation manner of the first aspect, in a ninth possible implementation manner of the first aspect, the file editor points the current modification identifier to the target basic data unit.
With reference to any one of the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, the third possible implementation manner of the first aspect, the fourth possible implementation manner of the first aspect, the fifth possible implementation manner of the first aspect, the sixth possible implementation manner of the first aspect, the seventh possible implementation manner of the first aspect, the eighth possible implementation manner of the first aspect, and the ninth possible implementation manner of the first aspect, in a tenth possible implementation manner of the first aspect, the file editor points the current modification identifier to the first basic data unit.
With reference to any one of the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, the third possible implementation manner of the first aspect, the fourth possible implementation manner of the first aspect, the fifth possible implementation manner of the first aspect, the sixth possible implementation manner of the first aspect, the seventh possible implementation manner of the first aspect, the eighth possible implementation manner of the first aspect, the ninth possible implementation manner of the first aspect, and the tenth possible implementation manner of the first aspect, in the eleventh possible implementation manner of the first aspect, the target modified content includes deleted file content and/or added file content.
A second aspect of an embodiment of the present invention provides a file editor, including:
the modification module is used for carrying out target modification on a first file block of the file to be processed;
the recording module is used for recording target modification information and position information of the first file block to obtain a target basic data unit, wherein the target modification information comprises target modification content and position information of the target modification content in the first file block;
the first storage module is used for storing the target basic data unit behind the first basic data unit pointed by the current modification identifier in the data linked list;
the first pointing module is used for pointing the current modification identifier to the target basic data unit;
the first receiving module is used for receiving a recovery or revocation instruction;
the determining module is used for determining the basic data unit corresponding to the recovering or canceling instruction as the target basic data unit according to the current modification identifier;
the first reading module is used for reading the first file block from the external memory according to the position information of the first file block;
the first recovery module is used for recovering the first file block according to the target modified information;
and the first revocation module is used for revoking the first file block according to the target modified information.
With reference to the second aspect, in a first possible implementation manner of the second aspect, the file editor further includes:
the second receiving module is used for receiving a storage instruction;
the storage module is used for storing the first file block;
and the second directing module is used for directing the storage modification identifier to a second basic data unit, and the second basic data unit is the basic data unit pointed by the current modification identifier.
With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the file editor further includes:
the second recovery module is used for recovering the first file block according to the sequence from the starting point to the end point of the target basic data unit segment of the data linked list;
the second revocation module is used for revoking the first file block according to the sequence from the starting point to the end point of the target basic data unit segment of the data linked list;
the start point of the basic data unit segment is the second basic data unit pointed to by the storage modification identifier, and the end point of the basic data unit segment is the third basic data unit pointed to by the current modification identifier.
With reference to the second aspect, any one of the first possible implementation manner of the second aspect, and the second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the location information of the first file block includes at least two of a start location, an end location, and a length of the first file block in the entire file.
With reference to the second aspect, or any one of the first possible implementation manner of the second aspect, the second possible implementation manner of the second aspect, and the third possible implementation manner of the second aspect, in a fourth possible implementation manner of the second aspect, the location information of the first file block is a storage location of the first file block in the external memory.
With reference to the third possible implementation manner of the second aspect, in a fifth possible implementation manner of the second aspect, the file editor further includes:
the third receiving module is used for receiving a storage instruction;
and the updating module is used for updating the position information of the first file block in the target basic data unit.
With reference to the second aspect, the first possible implementation manner of the second aspect, the second possible implementation manner of the second aspect, the third possible implementation manner of the second aspect, the fourth possible implementation manner of the second aspect, and the fifth possible implementation manner of the second aspect, in a sixth possible implementation manner of the second aspect, the file editor further includes:
the deleting module is used for deleting the first file block from the memory;
the second reading module is used for reading a second file block of the file to be processed from the external memory;
and the display module is used for displaying the second file block of the file to be processed.
With reference to the sixth possible implementation manner of the second aspect, in a seventh possible implementation manner of the second aspect, the file editor further includes a second storage module, configured to store the first file block according to the location information of the first file block.
With reference to the sixth possible implementation manner of the second aspect, in an eighth possible implementation manner of the second aspect, the file editor further includes:
the judging module is used for judging whether the second file block and the first file block are the same file block;
the first trigger module is used for triggering the operation of recovering or cancelling the first file block according to the target modified information when the second file block and the first file block are the same file block;
and the second triggering module is used for triggering the operation of reading the first file block from the external memory according to the position information of the first file block when the second file block and the first file block are not the same file block.
With reference to any one of the second aspect, the first possible implementation manner of the second aspect, the second possible implementation manner of the second aspect, the third possible implementation manner of the second aspect, the fourth possible implementation manner of the second aspect, the fifth possible implementation manner of the second aspect, the sixth possible implementation manner of the second aspect, the seventh possible implementation manner of the second aspect, and the eighth possible implementation manner of the second aspect, in a ninth possible implementation manner of the second aspect, the file editor further includes a third pointing module, configured to point the current modification identifier to the target basic data unit.
With reference to the second aspect, the first possible implementation manner of the second aspect, the second possible implementation manner of the second aspect, the third possible implementation manner of the second aspect, the fourth possible implementation manner of the second aspect, the fifth possible implementation manner of the second aspect, the sixth possible implementation manner of the second aspect, the seventh possible implementation manner of the second aspect, the eighth possible implementation manner of the second aspect, and the ninth possible implementation manner of the second aspect, in a tenth possible implementation manner of the second aspect, the file editor further includes a fourth pointing module configured to point the current modification identifier to the first basic data unit.
In the scheme provided by the embodiment of the application, the editing of the file by the file editor is established on the basis of loading the content of the file into the memory in blocks, and the file editor only reads and displays one file block each time. When the file block is restored or cancelled, the file block can be read through the file block position information in the basic data unit, and the restoration or cancellation operation is performed on the file block. When the file editor recovers or cancels the file content, the file editor does not need to load all the file content into the memory, thereby avoiding affecting the system performance.
Drawings
FIG. 1 is a schematic diagram of one embodiment of a file editing method of the present invention;
FIG. 2 is a schematic diagram of another embodiment of the file editing method of the present invention;
FIG. 3 is a schematic diagram of another embodiment of the file editing method of the present invention;
FIG. 4 is a schematic diagram of one embodiment of a file editor in accordance with the present invention;
FIG. 5 is a schematic diagram of another embodiment of a file editor in accordance with the invention;
FIG. 6 is a schematic diagram of another embodiment of a file editor in accordance with the invention.
Detailed Description
The embodiment of the invention provides a file editing method, which is used for recovering or canceling file contents without loading all the file contents into a memory, so that the influence on the system performance is avoided.
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For convenience of understanding, a specific flow in the embodiment of the present invention is described below, and referring to fig. 1, an embodiment of a file editing method in the embodiment of the present invention includes:
101. the file editor carries out target modification on a first file block of a file to be processed;
the file editor reads and displays the first file block of the file to be processed from the external memory, and then target modification can be carried out on the first file block.
102. The file editor records the target modification information and the position information of the first file block to obtain a target basic data unit;
when the file editor carries out target modification on the first file block, the file editor records target modification information and position information of the first file block to obtain a target basic data unit, and the target modification information comprises target modification content and position information of the target modification content in the first file block. Each elementary data unit represents a step of the undo/redo operation, which is the smallest unit of execution of the undo/redo operation.
103. After the file editor stores the target basic data unit in a first basic data unit in a data linked list, the first basic data unit is a basic data unit pointed by the current modification identifier;
the recovery or revocation operation information recorded in the basic data unit is uniformly recorded in the basic data unit data linked list, and in the present application, the data linked list refers to the basic data unit data linked list. After obtaining the target basic data unit, the file editor may store the target basic data unit in the data link table after the first basic data unit, where the first basic data unit is the basic data unit pointed by the current modification identifier.
104. The file editor points the current modification identification to the target basic data unit;
after the file editor stores the target basic data unit in the data link list, the file editor points the current modification identifier to the target basic data unit, indicating that the target basic data unit represents the current modification state of the file to be processed.
105. The file editor receives a recovery or revocation instruction;
the file editor may receive a restore or undo instruction after modifying the file to be processed.
106. The file editor determines the basic data unit corresponding to the recovery or revocation instruction as a target basic data unit according to the current modification identifier;
after receiving the restoring or canceling instruction, the file editor may determine, in the data link table, according to the basic data unit pointed by the current modification identifier, that the basic data unit corresponding to the restoring or canceling instruction is the target basic data unit.
107. The file editor reads the first file block from the external memory according to the position information of the first file block;
and the file editor reads the target basic data unit, acquires the position information of the first file block and reads the first file block from the external storage according to the position information of the first file block.
108. And the file editor recovers or cancels the first file block according to the target modified information.
After the file editor reads the first file block, the first file block can be restored or revoked according to the target modified information in the target basic data unit.
It should be noted that, in the foregoing embodiment, after the file editor modifies the file block of the file to be processed, the modified file block may be automatically saved in the external memory, or the modified file block may be saved in the external memory only when a save instruction is received, which is described below:
firstly, the file editor saves the modified file block to an external memory when receiving a saving instruction:
in this embodiment, after the file editor modifies the file block of the file to be processed, the modified file block is saved into the external memory only when the file editor receives a save instruction, and referring to fig. 2 specifically, another embodiment of the file editing method of the present invention includes:
201. the file editor receives a storage instruction;
when a user modifies a first file block of a file to be processed through a file editor, the file editor records modified information and position information of the first file block, generates and stores a second basic data unit in a data link table, and points a current modification identifier to the second basic data unit. If the user needs to save the changed file content of the first file block into the external memory, the user may input a saving instruction to the file editor, and the file editor may receive the saving instruction input by the user.
202. The file editor saves the first file block;
and after the file editor receives the saving instruction, the first file block can be saved, and the changed file content of the first file block is saved in the external memory.
203. The file editor points the storage modification identification to the second basic data unit;
after receiving the save instruction, the file editor may point the save modification identifier to the second basic data unit, where the second basic data unit is the basic data unit pointed by the current modification identifier. This step may be performed before step 202, may be performed after step 202, and may also be performed simultaneously with step 202, which is not specifically limited herein.
The base data unit contains the modified information and the location information of the modified file block. The location information of the file block may include at least two of a start location, an end location, and a length of the file block in the entire file. The starting position of the file block in the whole file may be an offset generated when the file pointer moves from the starting position of the file to the starting position of the file block, the ending position of the file block in the whole file may be an offset generated when the file pointer moves from the starting position of the file to the ending position of the file block, and the starting and ending positions of the file block in the whole file may also be indicated in other manners, which is not specifically limited herein. When the file editor receives the saving instruction, the file editor writes the modification of the file to be modified before receiving the saving instruction into the file to be modified in the external memory, which may cause the change of the initial position and the end position of the file block in the whole file and the length of the file block, and therefore the position information of the file block of the basic data unit in the data link table also needs to be updated. Taking the example that the position information of the file block includes the start position and the end position of the file block in the whole file, the basic data units in the data link list can be modified one by one from the beginning of the link, and the specific method may be as follows:
note that the base data unit currently being modified is Ix, where the start and end positions of the recorded file blocks are denoted as P1 and P2, respectively, and traverse the data chain table to determine the base data units whose modification positions of all records are located before P1, such as I1, I2, I3, and I4, and the character offsets caused by the modification are Δ 1, Δ 2, Δ 3, and Δ 4, respectively. For example, if a modification deletes 5 characters and adds 2 characters in a file block, the character offset Δ caused by the modification is-3 characters. Adding Δ 1, Δ 2, Δ 3, Δ 4 and P1, the Ix corrected P1 is obtained. The method for correcting P2 of Ix is similar to the method for correcting P1, and is not described herein again. The updating of the location information of the file block of the basic data unit in the data link table may also be performed by other methods, which are not specifically limited herein.
In order to avoid the influence of storage modification on the location information of the file block, the file block may be stored in the external memory by other methods, for example, the file block may be stored in different external memory areas in a distributed manner, for example, the first file block is stored in a first storage area of the external memory, where the first storage area is large enough to store the modified first file block, and then the location information of the first file block is the first storage area. When the file editor needs to read the first file block, the file editor only needs to read out all the file contents stored in the first storage area. In a specific application, the file block may also be stored in other methods as long as the influence of storage and modification on the location information of the file block can be avoided. It can be seen that in this case the file editor does not update the location information of the file blocks in the elementary data unit when receiving the save instruction.
Steps 204 to 207 in this embodiment are the same as steps 101 to 104 in the embodiment shown in fig. 1, and are not repeated here.
208. The file editor reads the second file block from the external memory;
when the user needs to edit the contents of the second file block, the file editor reads the second file block from the external memory.
209. The file editor deletes the first file block from the memory;
when the user needs to edit the content of the second file block, the file editor may delete the first file block from the memory to load the second file block into the file editor. It should be noted that the execution sequence of step 208 and step 209 may be interchanged, that is, the file editor deletes the first file block from the memory first, and then reads the second file block from the external storage, which is not limited herein.
210. The file editor displays a second file block of the file to be processed;
the file editor may display the second file block of the file to be processed to the user after reading the second file block from the external storage and deleting the first file block from the internal storage.
Steps 208 to 210 are used to describe the case when the file editor receives a restore or cancel instruction and the file block corresponding to the restore or cancel operation is not the currently displayed file block, and in actual use, steps 208 to 210 may not occur, that is, the file block corresponding to the restore or cancel operation is the currently displayed file block.
211. The file editor receives a recovery or revocation instruction;
the user may input a restore instruction to the file editor to restore a previously revoked modification operation, the file editor may receive the restore instruction, the user may also input a revoke instruction to the file editor to revoke the previously revoked modification operation, and the file editor may receive the revoke instruction.
212. The file editor determines the basic data unit corresponding to the recovery or revocation instruction as a target basic data unit according to the current modification identifier;
if the file editor receives the restore instruction, the file editor may determine the basic data unit pointed to by the current modification identifier, and if the current modification identifier points to the first basic data unit, the file editor may determine, in the data link table, that the basic data unit corresponding to the restore instruction is the target basic data unit.
If the file editor receives the undo instruction, the file editor may determine the basic data unit pointed to by the current modification identifier, and if the current modification identifier points to the target basic data unit, the file editor may determine, in the data link table, that the basic data unit corresponding to the undo instruction is the target basic data unit.
Step 213 in this embodiment is the same as step 107 in the embodiment shown in fig. 1, and is not described here again.
214. The file editor recovers or cancels the first file block according to the sequence from the starting point to the end point of the target basic data unit segment of the data linked list;
and the file editor recovers the first file block according to the sequence from the starting point to the end point of the target basic data unit segment of the data linked list to obtain the first file block in the current modification state, wherein the starting point of the basic data unit segment is a second basic data unit pointed by the storage modification identifier, and the end point of the basic data unit segment is a third basic data unit pointed by the current modification identifier. If the file editor receives a restore command, the third base data unit is the first base data unit, and if the undo command is received, the third base data unit is the target base data unit.
In actual use, steps 201 to 203 may not occur, and even the file editor may not receive the saving instruction before receiving the recovery instruction, then the file editor recovers the first file block according to the sequence from the head of the linked list to the third basic data unit pointed by the current modification identifier. Or the storage modification identifier may point to a base data unit following the first base data unit in the data link list, the file editor revokes the first file block in the order from the start point to the end point of the target base data unit segment of the data link list.
If the first file block is the file block currently displayed by the file editor, steps 213 and 214 may not be executed.
215. The file editor recovers or cancels the first file block according to the target modified information;
and after the read first file block is converted into the current modification state from the modification state stored last time by the file editor, the converted first file block can be recovered or cancelled according to the target modification information.
After receiving the recovery instruction and determining that the basic data unit pointed by the current modification identifier is the first basic data unit, the file editor may point the current modification identifier to the target basic data unit. And after receiving the undo instruction and determining that the basic data unit pointed by the current modification identifier is the target basic data unit, the file editor may point the current modification identifier to the first basic data unit.
The file editor automatically saves the modified file blocks into an external memory:
in this embodiment, after the file editor performs the target modification on the first file block of the file to be processed, the modified first file block may be automatically saved in the external storage to backup the first file block in the current modification state, and referring to fig. 3 specifically, another embodiment of the file editing method of the present invention includes:
steps 301 to 304 in this embodiment are the same as steps 101 to 104 in the embodiment shown in fig. 1, and are not repeated here.
305. The file editor stores the first file block subjected to target modification into an external memory;
after the file editor performs the target modification on the first file block of the file to be processed, the modified first file block can be saved in the external memory. The modified first file block is saved in the external memory, the whole file block can be written into the external memory and the original file block is deleted, the modified content can be written into the original file block in the external memory, and other methods can be used as long as the first file block saved in the external memory can be updated to the current modified state. In this embodiment, the timing sequence between step 305 and any one of steps 302 to 304 is not specifically limited, as long as the file editor has saved the first file block in the current modification state to the external storage before deleting the first file block from the internal storage.
Steps 306 to 311 in this embodiment are the same as steps 208 to 213 in the embodiment shown in fig. 2, and step 312 in this embodiment is the same as step 215 in the embodiment shown in fig. 2, and are not repeated here.
The file editing method in the embodiment of the present invention is described above, and a file editor in the embodiment of the present invention is described below.
Referring to fig. 4, an embodiment of the file editor 400 according to the present invention includes:
a modification module 401, configured to perform target modification on a first file block of a file to be processed;
a recording module 402, configured to record target modification information and location information of the first file block to obtain a target basic data unit, where the target modification information includes target modified content and location information of the target modified content in the first file block;
a first storage module 403, configured to store the target basic data unit in a data linked list after a first basic data unit, where the first basic data unit is a basic data unit pointed by a current modification identifier;
a first pointing module 404, configured to point the current modification identifier to the target base data unit;
a first receiving module 405, configured to receive a recovery or revocation instruction;
a determining module 406, configured to determine, according to the current modification identifier, that the basic data unit corresponding to the recovery or revocation instruction is the target basic data unit;
a first reading module 407, configured to read the first file block from the external memory according to the location information of the first file block;
a first restoring module 408, configured to restore the first file block according to the target modified information;
the first revocation module 409 is configured to revoke the first file block according to the target modified information.
The relationship between the modules of the file editor in this embodiment refers to the embodiment corresponding to fig. 1, and is not described herein again.
It should be noted that, in the foregoing embodiment, after the file editor modifies the file block of the file to be processed, the modified file block may be automatically saved in the external memory, or the modified file block may be saved in the external memory only when a save instruction is received, which is described below:
firstly, the file editor saves the modified file block to an external memory when receiving a saving instruction:
in this embodiment, after the file editor modifies the file block of the file to be processed, only when the file editor receives the saving instruction, the modified file block is saved in the external memory, specifically referring to fig. 5, another embodiment of the file editor 500 of the present invention includes:
a second receiving module 501, configured to receive a saving instruction;
a saving module 502, configured to save the first file block;
a second directing module 503, configured to direct the storage modification identifier to the second basic data unit;
the module 504 in this embodiment is the same as the module 401, the module 505, the module 402, the module 506, the module 403, and the module 507 in the embodiment shown in fig. 4, and the functions performed by the module 404 are the same, which are not described herein again.
A second reading module 508, configured to read a second file block from the external memory;
a deleting module 509, configured to delete the first file block from the memory;
a display module 510, configured to display a second file block of the file to be processed;
a first receiving module 511, configured to receive a recovery or revocation instruction;
a determining module 512, configured to determine, according to the current modification identifier, that the basic data unit corresponding to the recovery or revocation instruction is a target basic data unit;
the module 513 in this embodiment is the same as the module 407 in the embodiment shown in fig. 4 in terms of executing functions, and is not described here again.
A second restoring module 514, configured to restore the first file block according to an order from a starting point to an end point of a target basic data unit segment of the data link list;
a second revocation module 515, configured to revoke the first file block according to an order from a start point to an end point of a target basic data unit segment of the data link table;
a first recovery module 516, configured to recover the first file block according to the target modified information;
the first revocation module 517 is configured to revoke the first file block according to the target modified information.
The relationship between the modules of the file editor in this embodiment refers to the embodiment corresponding to fig. 2, and is not described herein again.
The file editor automatically saves the modified file blocks into an external memory:
in this embodiment, after the file editor performs the target modification on the first file block of the file to be processed, the modified first file block may be automatically saved in the external memory to backup the first file block in the current modification state, specifically referring to fig. 6, another embodiment of the file editor 600 of the present invention includes:
steps 601 to 604 in this embodiment are the same as steps 401 to 404 in the embodiment shown in fig. 1, and are not repeated here.
A second storage module 605, configured to store the first file block subjected to the target modification in an external storage;
in this embodiment, the functions performed by the module 606, the modules 508, 607, 509, the modules 608, 510, the modules 609, 511, the modules 610, 512, the modules 611, 513, the modules 612, 516, the modules 613, and the modules 517 in the embodiment shown in fig. 5 are the same, and are not described herein again.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (19)

1. A method of editing a file, comprising:
the file editor carries out target modification on a first file block of a file to be processed, and records target modification information and position information of the first file block to obtain a target basic data unit, wherein the target modification information comprises target modification content and position information of the target modification content in the first file block;
after the file editor stores the target basic data unit in a first basic data unit in a data linked list, the first basic data unit is a basic data unit pointed by a current modification identifier, and the current modification identifier is pointed to the target basic data unit;
the file editor receives a recovery or revocation instruction;
the file editor determines the basic data unit corresponding to the recovery or revocation instruction as the target basic data unit according to the current modification identifier;
the file editor reads the first file block from an external memory according to the position information of the first file block;
the file editor recovers or cancels the first file block according to the target modified information;
after the file editor stores the target base data unit in the data link list, before the file editor receives a restore or undo instruction, the method further comprises:
the file editor deletes the first file block from the memory and reads and displays a second file block of the file to be processed from the external memory;
after the file editor determines, according to the current modification identifier, that the basic data unit corresponding to the restore or cancel instruction is the target basic data unit, before the file editor reads the first file block from an external storage according to the location information of the first file block, the method further includes:
the file editor judges whether the second file block and the first file block are the same file block;
if yes, triggering the operation of recovering or cancelling the first file block according to the target modified information;
if not, triggering the operation of reading the first file block from an external memory according to the position information of the first file block.
2. The method of editing a file of claim 1, wherein prior to the file editor receiving a restore or undo instruction, the method further comprises:
the file editor receives a storage instruction;
and the file editor stores the first file block and points a storage modification identifier to a second basic data unit, wherein the second basic data unit is the basic data unit pointed by the current modification identifier.
3. The method for editing the file according to claim 2, wherein after the file editor reads the first file block from an external storage according to the location information of the first file block, before the file editor restores or revokes the first file block according to the target modification information, the method further comprises:
and the file editor restores or cancels the first file block according to the sequence from the starting point to the end point of a target basic data unit segment of the data linked list, wherein the starting point of the basic data unit segment is a second basic data unit pointed by the storage modification identifier, and the end point of the basic data unit segment is a third basic data unit pointed by the current modification identifier.
4. The file editing method according to claim 1, wherein the position information of the first file block includes at least two of a start position, an end position, and a length of the first file block in a file entirety of the first file block.
5. The file editing method according to claim 1, wherein the location information of the first file block is a storage location of the first file block in an external memory.
6. The method of file editing according to claim 4, wherein after the file editor stores the target base data unit in the data link list, before the file editor receives a restore or undo instruction, the method further comprises:
the file editor receives a storage instruction;
the file editor updates location information of a first file block in the target base data unit.
7. The method according to any one of claims 1 to 6, wherein after the file editor performs the target modification on the first file block of the file to be processed, before the file editor deletes the first file block from the memory, the method further comprises:
and the file editor stores the first file block according to the position information of the first file block.
8. The method according to any one of claims 1 to 6, wherein if the file editor receives a restore instruction, after the file editor restores the first file block according to the target modified information, the method further includes:
the file editor directs the current modification identification to the target base data unit.
9. The method for editing the file according to any one of claims 1 to 6, wherein if the file editor receives an undo instruction, after the file editor undoes the first file block according to the target modified information, the method further comprises:
the file editor points the current modification identification to a first base data unit.
10. The file editing method according to any one of claims 1 to 6, wherein the target modified content includes deleted file content and/or added file content.
11. A file editor, comprising:
the modification module is used for carrying out target modification on a first file block of the file to be processed;
a recording module, configured to record the target modification information and the location information of the first file block to obtain a target basic data unit, where the target modification information includes the target modified content and the location information of the target modified content in the first file block;
the first storage module is used for storing the target basic data unit in a data linked list after a first basic data unit, wherein the first basic data unit is a basic data unit pointed by the current modification identifier;
a first pointing module for pointing the current modification identification to the target base data unit;
the first receiving module is used for receiving a recovery or revocation instruction;
a determining module, configured to determine, according to the current modification identifier, that a basic data unit corresponding to the recovery or revocation instruction is the target basic data unit;
the first reading module is used for reading the first file block from an external memory according to the position information of the first file block;
the first recovery module is used for recovering the first file block according to the target modified information;
the first revocation module is used for revoking the first file block according to the target modified information;
the file editor further comprises:
the deleting module is used for deleting the first file block from the memory;
the second reading module is used for reading a second file block of the file to be processed from the external memory;
the display module is used for displaying a second file block of the file to be processed;
the judging module is used for judging whether the second file block and the first file block are the same file block;
the first trigger module is used for triggering the operation of recovering or cancelling the first file block according to the target modified information when the second file block and the first file block are the same file block;
and the second triggering module is used for triggering the operation of reading the first file block from an external memory according to the position information of the first file block when the second file block and the first file block are not the same file block.
12. The file editor of claim 11 further comprising:
the second receiving module is used for receiving a storage instruction;
the storage module is used for storing the first file block;
and the second directing module is used for directing the storage modification identifier to a second basic data unit, and the second basic data unit is the basic data unit directed by the current modification identifier.
13. The file editor of claim 12 further comprising:
the second recovery module is used for recovering the first file block according to the sequence from the starting point to the end point of the target basic data unit segment of the data linked list;
the second revocation module is used for revoking the first file block according to the sequence from the starting point to the end point of the target basic data unit segment of the data linked list;
the starting point of the basic data unit segment is a second basic data unit pointed by the storage modification identifier, and the end point of the basic data unit segment is a third basic data unit pointed by the current modification identifier.
14. The file editor of claim 11 wherein the location information for the first file block includes at least two of a start location, an end location, and a length of the first file block for the first file block throughout the file.
15. The file editor of claim 11 wherein the location information of the first file block is a storage location of the first file block in an external memory.
16. The file editor of claim 14 wherein the file editor further comprises:
the third receiving module is used for receiving a storage instruction;
and the updating module is used for updating the position information of the first file block in the target basic data unit.
17. The file editor of claim 11 further comprising:
and the second storage module is used for storing the first file block according to the position information of the first file block.
18. The file editor of any of claims 11 to 16, further comprising:
a third pointing module for pointing the current modification identification to the target base data unit.
19. The file editor of any of claims 11 to 16, further comprising:
and the fourth pointing module is used for pointing the current modification identifier to the first basic data unit.
CN201580080837.4A 2015-12-31 2015-12-31 File editing method and file editor Active CN107924397B (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/100168 WO2017113317A1 (en) 2015-12-31 2015-12-31 File editing method and file editor

Publications (2)

Publication Number Publication Date
CN107924397A CN107924397A (en) 2018-04-17
CN107924397B true CN107924397B (en) 2021-12-03

Family

ID=59224207

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201580080837.4A Active CN107924397B (en) 2015-12-31 2015-12-31 File editing method and file editor

Country Status (2)

Country Link
CN (1) CN107924397B (en)
WO (1) WO2017113317A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111352909A (en) * 2019-05-07 2020-06-30 鸿合科技股份有限公司 File saving and loading method and device, electronic device and storage medium
CN110389796A (en) * 2019-07-01 2019-10-29 北京字节跳动网络技术有限公司 Edit operation processing method, device and electronic equipment
CN112416325A (en) * 2019-08-22 2021-02-26 福建天泉教育科技有限公司 Method and terminal for constructing ab package in Unity
CN112363708B (en) * 2020-12-04 2023-03-10 中信银行股份有限公司 Context protection method and system under Eclipse supporting tool
CN113312212B (en) * 2021-06-02 2024-05-07 广联达科技股份有限公司 Method, apparatus, device and readable storage medium for protecting parameters of model member

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102737032A (en) * 2011-04-06 2012-10-17 腾讯科技(深圳)有限公司 Method and device for file recovery
CN103294957A (en) * 2013-05-06 2013-09-11 北京赛思信安技术有限公司 Data protection method for file system supporting repeating data deletion during data updating
CN104199967A (en) * 2014-09-22 2014-12-10 广东欧珀移动通信有限公司 Cellphone file recovery method and device
CN104199856A (en) * 2014-08-13 2014-12-10 北京配天技术有限公司 Method and device for presenting file

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7464116B2 (en) * 2005-12-28 2008-12-09 Network Appliance, Inc. Method and apparatus for cloning filesystems across computing systems
US7913003B2 (en) * 2006-02-24 2011-03-22 Intel Corporation Reclaim algorithm for fast edits in a nonvolatile file system
CN101551793A (en) * 2008-04-03 2009-10-07 鸿富锦精密工业(深圳)有限公司 Method for saving and editing files
TWI425375B (en) * 2010-01-20 2014-02-01 Inventec Corp Method of file management of server
CN101751478A (en) * 2010-02-20 2010-06-23 浪潮(北京)电子信息产业有限公司 File backup method and system
US9411687B2 (en) * 2011-06-03 2016-08-09 Apple Inc. Methods and apparatus for interface in multi-phase restore
JP5831235B2 (en) * 2012-01-06 2015-12-09 ティアック株式会社 File editing device
WO2013160942A2 (en) * 2012-04-25 2013-10-31 Hitachi, Ltd. File storage system and file cloning method
US9348840B2 (en) * 2012-12-14 2016-05-24 Intel Corporation Adaptive data striping and replication across multiple storage clouds for high availability and performance
CN103440181A (en) * 2013-09-06 2013-12-11 珠海金山网络游戏科技有限公司 Method and system for modifying files
CN104092780A (en) * 2014-07-29 2014-10-08 中国联合网络通信集团有限公司 File modification method and device and monofile synchronization method and device based on file blocks

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102737032A (en) * 2011-04-06 2012-10-17 腾讯科技(深圳)有限公司 Method and device for file recovery
CN103294957A (en) * 2013-05-06 2013-09-11 北京赛思信安技术有限公司 Data protection method for file system supporting repeating data deletion during data updating
CN104199856A (en) * 2014-08-13 2014-12-10 北京配天技术有限公司 Method and device for presenting file
CN104199967A (en) * 2014-09-22 2014-12-10 广东欧珀移动通信有限公司 Cellphone file recovery method and device

Also Published As

Publication number Publication date
CN107924397A (en) 2018-04-17
WO2017113317A1 (en) 2017-07-06

Similar Documents

Publication Publication Date Title
CN107924397B (en) File editing method and file editor
US8538930B2 (en) Method and system for database recovery
US20190287626A1 (en) Data overwriting device and data overwriting method
EP3474143B1 (en) Method and apparatus for incremental recovery of data
CN103559301A (en) Method of data update, database trigger and SE (search engine)
WO2012097691A1 (en) Data backup method and device
CN109634774A (en) Data backup, restoration methods and device
US20130024466A1 (en) System event logging system
CN105573788B (en) The method and apparatus of patch processing and the method and apparatus for generating patch
CN111984597A (en) File storage method, device, equipment and medium
CN105224423A (en) Terminal data backup method and device
CN107770207A (en) The method of data syn-chronization between multi-terminal equipment
CN104750755A (en) Method and system for recovering data after switching between main database and standby database
CN104834749A (en) File synchronization method and synchronization system for mobile terminal and PC terminal
CN109298873A (en) A kind of method for upgrading system and device
CN108037932B (en) SPI-NAND configuration file acquisition method and device
CN110865903B (en) Node abnormal reconnection multiplexing method and system based on erasure code distributed storage
CN106155838A (en) A kind of database back-up data restoration methods and device
CN106096447A (en) A kind of document protection method and device
CN109753381B (en) Continuous data protection method based on object storage
CN106201570A (en) A kind of application program exempts from installation and operation method and device
CN104077053B (en) Terminal information operating method and device and mobile terminal
EP2966572B1 (en) Database device, program, and data processing method
CN110659295A (en) Method, apparatus and medium for recording valid data based on HAWQ
CN103645967A (en) Read-only snapshot rollback method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant