WO2017113317A1 - 一种文件编辑方法和文件编辑器 - Google Patents

一种文件编辑方法和文件编辑器 Download PDF

Info

Publication number
WO2017113317A1
WO2017113317A1 PCT/CN2015/100168 CN2015100168W WO2017113317A1 WO 2017113317 A1 WO2017113317 A1 WO 2017113317A1 CN 2015100168 W CN2015100168 W CN 2015100168W WO 2017113317 A1 WO2017113317 A1 WO 2017113317A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
data unit
editor
basic data
block
Prior art date
Application number
PCT/CN2015/100168
Other languages
English (en)
French (fr)
Inventor
裴廷斌
Original Assignee
深圳配天智能技术研究院有限公司
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 深圳配天智能技术研究院有限公司 filed Critical 深圳配天智能技术研究院有限公司
Priority to CN201580080837.4A priority Critical patent/CN107924397B/zh
Priority to PCT/CN2015/100168 priority patent/WO2017113317A1/zh
Publication of WO2017113317A1 publication Critical patent/WO2017113317A1/zh

Links

Images

Classifications

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

Definitions

  • the embodiment of the present application relates to the field of file processing, and in particular, to a file editing method and a file editor.
  • Editing the contents of a file by the file editor needs to be based on loading the contents of the file into memory.
  • the file editor needs to load all the contents of the file into the memory first.
  • the file editor records the modified file content and the position of the modified file in the file to generate the basic data unit. Then, the content of the file that has been loaded into the memory can be restored and undone according to the basic data unit.
  • An aspect of the embodiments of the present invention provides a file editing method, including:
  • the file editor performs target modification on the first file block of the processed file, and records the target modified information and the position information of the first file block to obtain the target basic data unit, and the target modified information includes the target modified content and the target modified content. Location information in the first file block;
  • the file editor stores the target basic data unit in the data link table behind the first basic data unit pointed to by the current modification identifier, and points the current modification identifier to the target basic data unit;
  • the file editor receives a resume or undo instruction
  • the file editor determines, according to the current modification identifier, that the basic data unit corresponding to the recovery or revocation instruction is the target basic data unit;
  • the file editor reads the first file block from the external memory according to the location information of the first file block;
  • the file editor restores or revokes the first file block based on the information modified by the target.
  • the file editor receives the save instruction; the file editor saves the first file block and points the save modification identifier to the second base
  • the basic data unit, the second basic data unit is the basic data unit pointed to by the current modification identifier.
  • the file editor processes the first file in an order from the start point to the end point of the target base data unit segment of the data link table.
  • the block is restored or revoked, and the starting point of the basic data unit segment is the second basic data unit pointed to by the save 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.
  • the first The location information of the file block includes at least two of a start position of the first file block in the full text of the file, an end position, and a length of the first file block.
  • the location information of the first file block is a storage location of the first file block in the external memory.
  • the file editor receives the save instruction; the location of the first file block in the target base data unit by the file editor The information is updated.
  • the file editor deletes the first file block from the memory and from the external memory.
  • the second file block in which the file to be processed is read and displayed.
  • the file editor is The location information of the first file block stores the first file block.
  • the file editor determines whether the second file block and the first file block are the same file. Piece;
  • the file editor directs the current modification identifier to the target base data unit.
  • the file editor directs the current modification identifier to the first base data unit.
  • the first possible implementation of the first aspect, the second possible implementation of the first aspect, the third possible implementation of the first aspect, the fourth possible aspect of the first aspect The implementation manner, 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 Any one of the ninth possible implementation of the first aspect and the tenth possible implementation of the first aspect.
  • the target modification includes Deleted file content and/or added file content.
  • a second aspect of the embodiments of the present invention provides a file editor, including:
  • a recording module configured to record the information of the target modification and the location information of the first file block to obtain the target basic data unit, where the target modified information includes the content of the target modification and the location information of the content of the target modification in the first file block;
  • a first storage module configured to store the target basic data unit behind the first basic data unit pointed to by the current modification identifier in the data link table
  • a first pointing module configured to point the current modified identifier to the target basic data unit
  • a first receiving module configured to receive a resume or revocation instruction
  • a determining module 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 configured to read the first file block from the external memory according to the location information of the first file block
  • a first recovery module configured to recover the first file block according to the information modified by the target
  • the first undo module is configured to cancel the first file block according to the information modified by the target.
  • the file editor further includes:
  • a second receiving module configured to receive a save instruction
  • the second pointing module is configured to point the save modification identifier to the second basic data unit, where the second basic data unit is the basic data unit pointed to by the current modification identifier.
  • the file editor further includes:
  • a second recovery module configured to recover the first file block in an order from a start point to an end point of the target basic data unit segment of the data link table
  • a second revocation module configured to revoke the first file block in an order from a start point to an end point of the target basic data unit segment of the data link table
  • the starting point of the basic data unit segment is the second basic data unit pointed to by the save 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.
  • 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 first The location information of the file block includes at least two of a start position of the first file block in the full text of the file, an end position, and a length of the first file block.
  • the location information of the first file block is a storage location of the first file block in the external memory.
  • the file editor further includes:
  • a third receiving module configured to receive a save instruction
  • an update module configured to update location information of the first file block in the target basic data unit.
  • the file editor further includes:
  • a second reading module configured to read a second file block of the file to be processed from the external memory
  • a display module for displaying a second file block of the file to be processed.
  • the file editor further includes a second storage module, configured to perform, according to the location information of the first file block, the first File blocks are stored.
  • the file editor further includes:
  • a determining module configured to determine whether the second file block and the first file block are the same file block
  • a first triggering module configured to: when the second file block and the first file block are the same file block, trigger an operation of restoring or revoking the first file block according to the information modified by the target;
  • the second triggering module is configured to trigger an operation of reading the first file block from the external memory according to the location information of the first file block when the second file block and the first file block are not the same file block.
  • the file editor further includes a third pointing module, configured to point the current modified identifier to the target basic data unit.
  • the file editor further includes a fourth pointing module, configured to point the current modified identifier to An underlying data unit.
  • the file editor performs editing on the file based on the file content being loaded into the memory, and the file editor only reads and displays one file block at a time.
  • the file block can be read and restored or undone by the file block location information in the underlying data unit. Since the file editor restores or undoes the contents of the file, it is not necessary to load all the contents of the file into memory, thereby avoiding affecting system performance.
  • FIG. 1 is a schematic diagram of an embodiment of a file editing method of the present invention
  • FIG. 2 is a schematic diagram of another embodiment of a file editing method of the present invention.
  • FIG. 3 is a schematic diagram of another embodiment of a file editing method of the present invention.
  • FIG. 4 is a schematic diagram of an embodiment of a file editor of the present invention.
  • Figure 5 is a schematic view of another embodiment of the file editor of the present invention.
  • Figure 6 is a schematic illustration of another embodiment of the file editor of the present invention.
  • the embodiment of the invention provides a file editing method, which is used for restoring or revoking the file content, and does not need to load all the file contents into the memory, thereby avoiding affecting system performance.
  • an embodiment of the file editing method in the embodiment of the present invention includes:
  • the file editor performs a target modification on the first file block of the processed file
  • the file editor reads and displays the first file block of the file to be processed from the external memory, and then the target file block can be modified.
  • the file editor records the target modified information and the location information of the first file block to obtain the target basic data unit.
  • Each base data unit represents an undo/redo operation step and is the smallest unit of execution for the undo/redo operation.
  • the file editor stores the target basic data unit after the first basic data unit in the data link table, where the first basic data unit is a basic data unit pointed to by the current modification identifier;
  • the recovery or undo operation information recorded in the basic data unit is uniformly included in the basic data unit data link table.
  • the data link table refers to the basic data unit data link table.
  • the file editor points the current modification identifier to the target basic data unit
  • the file editor After the file editor stores the target base data unit in the data link table, the file editor points the current modification identifier to the target base data unit, indicating that the target base data unit represents the current modification status of the file to be processed.
  • the file editor receives a resume or revocation instruction
  • the file editor can receive recovery or undo instructions after modifying the file to be processed.
  • the file editor determines, according to the current modification identifier, that the basic data unit corresponding to the recovery or revocation instruction is the target basic data unit;
  • the file editor may determine, in the data link table, the basic data unit corresponding to the recovery or revocation instruction as the target basic data unit according to the basic data unit pointed to by the current modification identifier.
  • the file editor reads the first file block from the external memory according to the location information of the first file block.
  • the file editor reads the target basic data unit, acquires location information of the first file block, and reads the first file block from the external memory according to the location information of the first file block.
  • the file editor restores or revokes the first file block according to the information modified by the target.
  • the first file block After the file editor reads the first file block, the first file block can be restored or revoked according to the information modified by the target in the target basic data unit.
  • the modified file block may be automatically saved to the external memory, or may be saved to the save command when the save command is received.
  • the external memory the following are explained separately:
  • the file editor saves the modified file block to the external memory when receiving the save instruction:
  • Another embodiment of the file editing method of the present invention includes:
  • the file editor receives the save instruction.
  • the file editor After the user modifies the first file block of the file to be processed by the file editor, the file editor records the modified information and the location information of the first file block, generates and stores the second basic data unit in the data link table, and The current modification identifier points to the second base data unit. If the user needs to save the file content of the first file block to the external memory, the user can input a save instruction to the file editor, and the file editor can receive the save instruction input by the user.
  • the file editor saves the first file block.
  • the first file block may be saved, and the file content changed by the first file block is saved to the external memory.
  • the file editor points the save modification identifier to the second basic data unit.
  • 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 to by the current modification identifier.
  • This step may be performed before step 202, or 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 position, a termination position, and a length of the file block of the file block in the full text of the file.
  • the starting position of the file block in the full text of the file can be the offset generated by the file pointer moving from the beginning position of the file to the beginning position of the file block.
  • the end position of the file block in the full text of the file can be the file pointer from the file.
  • the offset from the start position of the file block to the end position of the file block may also be used to indicate the start and end positions of the file block in the full text of the file, which is not specifically limited herein.
  • the file editor When the file editor receives the save instruction, the file editor will write the modification to the modified file before receiving the save instruction to the file to be modified in the external memory, which may result in the start position and the end position of the file block in the full text of the file. And the length of the file block changes, so the location information of the file block of the underlying data unit in the data link table needs to be updated.
  • the location information of the file block includes the starting position and the ending position of the file block in the full text of the file, and the basic data unit in the data link table may be corrected one by one from the beginning of the chain.
  • the specific method may be:
  • the basic data unit currently being corrected is Ix, wherein the starting position and the ending position of the recorded file block are respectively recorded as P 1 and P 2 , and the data link table is traversed to determine the basic data of all the recorded modified positions before P 1 .
  • the elements, such as I 1 , I 2 , I 3 , and I 4 are modified to produce a character offset of ⁇ 1 , ⁇ 2 , ⁇ 3 , and ⁇ 4 , respectively .
  • the character offset ⁇ caused by the modification is -3 characters.
  • Adding ⁇ 1 , ⁇ 2 , ⁇ 3 , ⁇ 4 , and P 1 yields I 1 corrected P 1 .
  • the method of correcting P 2 of Ix is similar to the above method of correcting P 1 and will not be described herein.
  • the location information of the file block of the basic data unit in the data link table may be updated by other methods, which are not specifically limited herein.
  • the file block may be distributedly stored in different external memory areas, for example, the first file block may be stored.
  • the first storage area is large enough to store the modified first file block
  • the location information of the first file block is the first storage area.
  • file blocks can also be stored in other ways. As long as you can avoid saving the impact of the modification on the location of the file block. It can be seen that in this case, the file editor does not need to update the location information of the file block in the underlying 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 details are not described herein again.
  • the file editor reads the second file block from the external memory.
  • the file editor reads the second file block from the external memory.
  • the file editor deletes the first file block from the memory
  • the file editor can 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 order of the steps 208 and 209 can be interchanged, that is, the file editor first deletes the first file block from the memory, and then reads the second file block from the external memory, which is not specifically limited herein.
  • the file editor displays a second file block of the file to be processed.
  • the second file block of the file to be processed can be displayed to the user.
  • Steps 208 to 210 are used to describe the case where the file block corresponding to the recovery or undo operation is not the currently displayed file block when the file editor receives the recovery or revocation instruction. In actual use, steps 208 to 210 may also be used. Does not occur, that is, the file block corresponding to the recovery or undo operation is the currently displayed file block.
  • the file editor receives a resume or revocation instruction
  • the user can input a recovery instruction to the file editor to restore the previously revoked modification operation, the file editor can receive the recovery instruction, and the user can also input a revocation instruction to the file editor to cancel the previous modification operation, the file editor. Can receive an undo command.
  • the file editor determines, according to the current modification identifier, that the basic data unit corresponding to the recovery or revocation instruction is the target basic data unit;
  • the file editor determines the basic data unit pointed to by the current modification identifier. If the current modification identifier points to the first basic data unit, the file editor may determine the corresponding recovery instruction in the data link table.
  • the underlying data unit is the target underlying data unit.
  • the file editor will determine what the current modification identifier points to.
  • the basic data unit 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 revocation 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 details are not described herein again.
  • the file editor restores or revokes the first file block according to an order from a start point to an end point of the target basic data unit segment of the data link table.
  • the file editor restores the first file block according to the order from the start point to the end point of the target data unit segment of the data link table, and obtains the first file block in the current modified state, and the starting point of the basic data unit segment is pointed to by the save modification identifier.
  • the second basic data unit, the end point of the basic data unit segment is the third basic data unit pointed to by the current modification identifier. If the file editor receives the resume instruction, 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.
  • Steps 201 to 203 mainly explain the specific operations performed by the file editor when receiving the save instruction.
  • steps 201 to 203 may not occur, and even the file editor may not receive the save instruction before receiving the resume instruction.
  • the file editor restores the first file block in the order from the beginning of the data link table to the third basic data unit pointed to by the current modification identifier.
  • the save modification identifier may point to the basic data unit behind the first basic data unit in the data link table, and then the file editor undoes 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 table.
  • steps 213 and 214 may not be performed.
  • the file editor restores or revokes the first file block according to the information modified by the target.
  • the converted first file block After the file editor converts the read first file block from the modified state at the time of the last save to the current modified state, the converted first file block can be restored or revoked according to the information modified by the target.
  • the file editor may point the current modification identifier to the target basic data unit.
  • the file editor may point the current modification identifier to the first basic data unit.
  • the modified first file block may be automatically saved to the external memory to back up the first file block in the current modified state.
  • FIG. 3 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 details are not described herein again.
  • the file editor saves the first file block that has been modified by the target to the external storage.
  • the modified first file block can be saved to the external memory. Saving the modified first file block to the external memory, by writing the entire file block to the external memory and deleting the original file block, or by writing the modified content to the original file block in the external memory, Other methods, as long as the first file block saved in the external memory can be updated to the current modified state.
  • the timing between step 305 and step 302 to step 304 is not specifically limited, as long as the file editor has the first modified state before the first file block is deleted from the memory.
  • the file block can be saved to the external memory.
  • the steps 306 to 311 in the embodiment are the same as the steps 208 to 213 in the embodiment shown in FIG. 2, and the step 312 in this embodiment is the same as the step 215 in the embodiment shown in FIG. Narration.
  • an embodiment of the file editor 400 in the embodiment of the present invention includes:
  • the modifying module 401 is configured to perform target modification on the first file block of the file to be processed
  • the recording module 402 is configured to record the target modified information and the location information of the first file block to obtain the target basic data unit, where the target modified information includes the target modified content and the 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 after the first basic data unit in the data link table, where the first basic data unit is a basic data unit pointed to by the current modification identifier;
  • a first pointing module 404 configured to point the current modification identifier to the target basic data unit
  • a first receiving module 405, configured to receive a resume or revocation instruction
  • a determining module 406 configured to determine, according to the current modification identifier, a base number corresponding to the recovery or revocation instruction According to the unit as the target data unit;
  • the first reading module 407 is configured to read the first file block from the external memory according to the location information of the first file block;
  • the first recovery module 408 is configured to recover the first file block according to the information modified by the target;
  • the first revocation module 409 is configured to rectify the first file block according to the information modified by the target.
  • the modified file block may be automatically saved to the external memory, or may be saved to the save command when the save command is received.
  • the external memory the following are explained separately:
  • the file editor saves the modified file block to the external memory when receiving the save instruction:
  • the modified file block is saved to the external memory only when the file editor receives the save instruction, as shown in FIG. 5 .
  • Another embodiment of the file editor 500 of the present invention includes:
  • the second receiving module 501 is configured to receive a save instruction.
  • a saving module 502 configured to save the first file block
  • a second pointing module 503, configured to point the save modification identifier to the second basic data unit
  • module 504 in this embodiment and the module 401, the module 505 and the module 402, the module 506 and the module 403, the module 507 and the module 404 in the embodiment shown in FIG. 4 are respectively the same, and 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
  • the first receiving module 511 is configured to receive a resume or revocation instruction
  • the determining module 512 is 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;
  • the module 513 in this embodiment performs the same function as the module 407 in the embodiment shown in FIG. 4, and details are not described herein again.
  • a second recovery module 514 configured to follow a starting point from a target base data unit segment of the data linked list The order of the end points restores the first file block;
  • a second revocation module 515 configured to revoke the first file block in an order from a start point to an end point of the target basic data unit segment of the data link table;
  • the first recovery module 516 is configured to recover the first file block according to the information modified by the target;
  • the first revocation module 517 is configured to rectify the first file block according to the information modified by the target.
  • the modified first file block may be automatically saved to the external memory to back up the first file block in the current modified state.
  • 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 details are not described herein again.
  • a second storage module 605, configured to store the first file block that has been modified by the target into an external memory
  • the module 606 in this embodiment and the module 508 in the embodiment shown in FIG. 5, the module 607 and the module 509, the module 608 and the module 510, the module 609 and the module 511, the module 610 and the module 512, the module 611 and the module 513, the module 612 and module 516, module 613 and module 517 perform the same functions, and are not described herein again.
  • the disclosed system, apparatus, and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of cells is only a logical function division.
  • multiple units or components may be combined or integrated. Go to another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated as a unit
  • the displayed components may or may not be physical units, ie may be located in one place, or may be distributed over multiple network elements. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • An integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, can be stored in a computer readable storage medium.
  • the technical solution of the present invention which is essential or contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product stored in a storage medium.
  • a number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes.

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

一种文件编辑方法和文件编辑器(400,500,600),该方法包括:文件编辑器(400,500,600)对待处理文件的第一文件块进行目标修改(101,204,301),文件编辑器(400,500,600)记录目标修改的信息和第一文件块的位置信息(102,205,302)得到目标基础数据单元;文件编辑器(400,500,600)接收恢复或撤销指令(105,211,309),文件编辑器(400,500,600)确定恢复或撤销指令对应的基础数据单元为目标基础数据单元(106,212,310),文件编辑器(400,500,600)根据第一文件块的位置信息从硬盘中读取第一文件块(107,213,311),文件编辑器(400,500,600)根据目标修改的信息对第一文件块进行恢复或撤销(108,215,312)。由于文件编辑器(400,500,600)在对文件内容进行恢复或撤销时,不需将全部文件内容载入内存中,从而避免影响***性能。

Description

一种文件编辑方法和文件编辑器 技术领域
本申请实施例涉及到文件处理领域,尤其涉及一种文件编辑方法和文件编辑器。
背景技术
用户通常需要通过文件编辑器来对文件内容进行阅读、修改、恢复和撤销等编辑操作。文件编辑器对文件内容进行编辑需要建立在将文件内容载入内存的基础上。
现有技术中,文件编辑器需要先将全部文件内容载入内存,当用户对文件内容进行修改时,文件编辑器会记录修改的文件内容和所做修改在文件中的位置,生成基础数据单元,然后可以根据该基础数据单元对已载入内存的文件内容进行恢复、撤销操作。
现有技术中,文件编辑器在对文件内容进行恢复、撤销操作时,会先将此文件的全部文件内容载入到内存中,尤其是随着文件的容量逐渐增大,载入全部文件内容所占用的内存资源会越来越大,影响了***性能。
发明内容
本发明实施例的一方面提供了一种文件编辑方法,包括:
文件编辑器对待处理文件的第一文件块进行目标修改,并记录目标修改的信息和第一文件块的位置信息得到目标基础数据单元,目标修改的信息包括目标修改的内容和目标修改的内容在第一文件块中的位置信息;
文件编辑器将目标基础数据单元存储于数据链表中当前修改标识所指向的第一基础数据单元的后面,并将当前修改标识指向目标基础数据单元;
文件编辑器接收恢复或撤销指令;
文件编辑器根据当前修改标识确定恢复或撤销指令对应的基础数据单元为目标基础数据单元;
文件编辑器根据第一文件块的位置信息从外存储器中读取第一文件块;
文件编辑器根据目标修改的信息对第一文件块进行恢复或撤销。
结合第一方面,在第一方面的第一种可能的实现方式中,文件编辑器接收保存指令;文件编辑器对第一文件块进行保存,并将保存修改标识指向第二基 础数据单元,第二基础数据单元为当前修改标识所指向的基础数据单元。
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,文件编辑器按照从数据链表的目标基础数据单元段的起点至终点的顺序对第一文件块进行恢复或撤销,基础数据单元段的起点为保存修改标识指向的第二基础数据单元,基础数据单元段的终点为当前修改标识指向的第三基础数据单元。
结合第一方面、第一方面的第一种可能的实现方式和第一方面的第二种可能的实现方式之中任意一种,在第一方面的第三种可能的实现方式中,第一文件块的位置信息包括第一文件块在文件全文中的起始位置、终止位置和第一文件块的长度中的至少两个。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式和第一方面的第三种可能的实现方式之中任意一种,在第一方面的第四种可能的实现方式中,第一文件块的位置信息为第一文件块在外存储器中的存储位置。
结合第一方面的第三种可能的实现方式,在第一方面的第五种可能的实现方式中,文件编辑器接收保存指令;文件编辑器对目标基础数据单元中的第一文件块的位置信息进行更新。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式、第一方面的第四种可能的实现方式和第一方面的第五种可能的实现方式之中任意一种,在第一方面的第六种可能的实现方式中,文件编辑器从内存中删除第一文件块,并从外存储器中读取、显示待处理文件的第二文件块。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式、第一方面的第四种可能的实现方式、第一方面的第五种可能的实现方式和第一方面的第六种可能的实现方式之中任意一种,在第一方面的第七种可能的实现方式中,文件编辑器根据第一文件块的位置信息对第一文件块进行存储。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式、第一方面的第四种可能的实现方式、第一方面的第五种可能的实现方式、第一方面的第六种可能的实现 方式和第一方面的第七种可能的实现方式之中任意一种,在第一方面的第八种可能的实现方式中,文件编辑器判断第二文件块与第一文件块是否为同一文件块;
若是,则触发根据目标修改的信息对第一文件块进行恢复或撤销的操作;
若否,则触发根据第一文件块的位置信息从外存储器中读取第一文件块的操作。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式、第一方面的第四种可能的实现方式、第一方面的第五种可能的实现方式、第一方面的第六种可能的实现方式、第一方面的第七种可能的实现方式和第一方面的第八种可能的实现方式之中任意一种,在第一方面的第九种可能的实现方式中,文件编辑器将当前修改标识指向目标基础数据单元。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式、第一方面的第四种可能的实现方式、第一方面的第五种可能的实现方式、第一方面的第六种可能的实现方式、第一方面的第七种可能的实现方式、第一方面的第八种可能的实现方式和第一方面的第九种可能的实现方式之中任意一种,在第一方面的第十种可能的实现方式中,文件编辑器将当前修改标识指向第一基础数据单元。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式、第一方面的第四种可能的实现方式、第一方面的第五种可能的实现方式、第一方面的第六种可能的实现方式、第一方面的第七种可能的实现方式、第一方面的第八种可能的实现方式、第一方面的第九种可能的实现方式和第一方面的第十种可能的实现方式之中任意一种,在第一方面的第十一种可能的实现方式中,目标修改的内容包括删除的文件内容和/或添加的文件内容。
本发明实施例的第二方面提供了一种文件编辑器,包括:
修改模块,用于对待处理文件的第一文件块进行目标修改;
记录模块,用于记录目标修改的信息和第一文件块的位置信息得到目标基础数据单元,目标修改的信息包括目标修改的内容和目标修改的内容在第一文件块中的位置信息;
第一存储模块,用于将目标基础数据单元存储于数据链表中当前修改标识所指向的第一基础数据单元的后面;
第一指向模块,用于将当前修改标识指向目标基础数据单元;
第一接收模块,用于接收恢复或撤销指令;
确定模块,用于根据当前修改标识确定恢复或撤销指令对应的基础数据单元为目标基础数据单元;
第一读取模块,用于根据第一文件块的位置信息从外存储器中读取第一文件块;
第一恢复模块,用于根据目标修改的信息对第一文件块进行恢复;
第一撤销模块,用于根据目标修改的信息对第一文件块进行撤销。
结合第二方面,在第二方面的第一种可能的实现方式中,文件编辑器还包括:
第二接收模块,用于接收保存指令;
保存模块,用于对第一文件块进行保存;
第二指向模块,用于将保存修改标识指向第二基础数据单元,第二基础数据单元为当前修改标识所指向的基础数据单元。
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,文件编辑器还包括:
第二恢复模块,用于按照从数据链表的目标基础数据单元段的起点至终点的顺序对第一文件块进行恢复;
第二撤销模块,用于按照从数据链表的目标基础数据单元段的起点至终点的顺序对第一文件块进行撤销;
基础数据单元段的起点为保存修改标识指向的第二基础数据单元,基础数据单元段的终点为当前修改标识指向的第三基础数据单元。
结合第二方面、第二方面的第一种可能的实现方式和第二方面的第二种可能的实现方式之中任意一种,在第二方面的第三种可能的实现方式中,第一文件块的位置信息包括第一文件块在文件全文中的起始位置、终止位置和第一文件块的长度中的至少两个。
结合第二方面、第二方面的第一种可能的实现方式、第二方面的第二种可能的实现方式和第二方面的第三种可能的实现方式之中任意一种,在第二方面 的第四种可能的实现方式中,第一文件块的位置信息为第一文件块在外存储器中的存储位置。
结合第二方面的第三种可能的实现方式,在第二方面的第五种可能的实现方式中,文件编辑器还包括:
第三接收模块,用于接收保存指令;
更新模块,用于对目标基础数据单元中的第一文件块的位置信息进行更新。
结合第二方面、第二方面的第一种可能的实现方式、第二方面的第二种可能的实现方式、第二方面的第三种可能的实现方式、第二方面的第四种可能的实现方式和第二方面的第五种可能的实现方式之中任意一种,在第二方面的第六种可能的实现方式中,文件编辑器还包括:
删除模块,用于从内存中删除第一文件块;
第二读取模块,用于从外存储器中读取待处理文件的第二文件块;
显示模块,用于显示待处理文件的第二文件块。
结合第二方面的第六种可能的实现方式,在第二方面的第七种可能的实现方式中,文件编辑器还包括第二存储模块,用于根据第一文件块的位置信息对第一文件块进行存储。
结合第二方面的第六种可能的实现方式,在第二方面的第八种可能的实现方式中,文件编辑器还包括:
判断模块,用于判断第二文件块与第一文件块是否为同一文件块;
第一触发模块,用于当第二文件块与第一文件块为同一文件块时,触发根据目标修改的信息对第一文件块进行恢复或撤销的操作;
第二触发模块,用于当第二文件块与第一文件块不为同一文件块时,触发根据第一文件块的位置信息从外存储器中读取第一文件块的操作。
结合第二方面、第二方面的第一种可能的实现方式、第二方面的第二种可能的实现方式、第二方面的第三种可能的实现方式、第二方面的第四种可能的实现方式、第二方面的第五种可能的实现方式、第二方面的第六种可能的实现方式、第二方面的第七种可能的实现方式和第二方面的第八种可能的实现方式之中任意一种,在第二方面的第九种可能的实现方式中,文件编辑器还包括第三指向模块,用于将当前修改标识指向目标基础数据单元。
结合第二方面、第二方面的第一种可能的实现方式、第二方面的第二种可能的实现方式、第二方面的第三种可能的实现方式、第二方面的第四种可能的实现方式、第二方面的第五种可能的实现方式、第二方面的第六种可能的实现方式、第二方面的第七种可能的实现方式、第二方面的第八种可能的实现方式和第二方面的第九种可能的实现方式之中任意一种,在第二方面的第十种可能的实现方式中,文件编辑器还包括第四指向模块,用于将当前修改标识指向第一基础数据单元。
本申请实施例提供的方案中,文件编辑器对文件所进行的编辑建立在将文件内容分块载入内存的基础上,文件编辑器每次只读取并显示一个文件块。在对文件块进行恢复或者撤销操作时,可以通过基础数据单元中的文件块位置信息读取该文件块,并对其进行恢复或者撤销操作。由于文件编辑器在对文件内容进行恢复或撤销时,不需将全部文件内容载入内存中,从而避免影响***性能。
附图说明
图1是本发明文件编辑方法一个实施例示意图;
图2是本发明文件编辑方法另一个实施例示意图;
图3是本发明文件编辑方法另一个实施例示意图;
图4是本发明文件编辑器一个实施例示意图;
图5是本发明文件编辑器另一个实施例示意图;
图6是本发明文件编辑器另一个实施例示意图。
具体实施方式
本发明实施例提供了一种文件编辑方法,用于对文件内容进行恢复或撤销时,不需将全部文件内容载入内存中,从而避免影响***性能。
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。
本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的 顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、***、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
为便于理解,下面对本发明实施例中的具体流程进行描述,请参阅图1,本发明实施例中文件编辑方法一个实施例包括:
101、文件编辑器对待处理文件的第一文件块进行目标修改;
文件编辑器从外存储器中读取并显示待处理文件的第一文件块,之后可以对第一文件块进行目标修改。
102、文件编辑器记录目标修改的信息和第一文件块的位置信息得到目标基础数据单元;
当文件编辑器对第一文件块进行目标修改时,文件编辑器会记录目标修改的信息和第一文件块的位置信息,得到目标基础数据单元,目标修改的信息包括目标修改的内容和目标修改的内容在第一文件块中的位置信息。每一个基础数据单元代表着一个撤销/恢复操作步骤,是撤销/恢复操作的最小执行单元。
103、文件编辑器将所述目标基础数据单元存储于数据链表中第一基础数据单元之后,所述第一基础数据单元为当前修改标识所指向的基础数据单元;
基础数据单元中记录的恢复或撤销操作信息会统一收录在基础数据单元数据链表中,在本申请文件中,数据链表即指基础数据单元数据链表。文件编辑器在得到目标基础数据单元后,可以将目标基础数据单元存储在数据链表中第一基础数据单元之后,第一基础数据单元为当前修改标识所指向的基础数据单元。
104、文件编辑器将当前修改标识指向目标基础数据单元;
文件编辑器将目标基础数据单元存储在数据链表中后,文件编辑器会将当前修改标识指向目标基础数据单元,表明目标基础数据单元代表着待处理文件的当前修改状态。
105、文件编辑器接收恢复或撤销指令;
文件编辑器在对待处理文件进行修改后,可以接收恢复或者撤销指令。
106、文件编辑器根据当前修改标识确定恢复或撤销指令对应的基础数据单元为目标基础数据单元;
文件编辑器在接收恢复或撤销指令后,可以在数据链表中根据当前修改标识所指向的基础数据单元确定此恢复或撤销指令对应的基础数据单元为目标基础数据单元。
107、文件编辑器根据第一文件块的位置信息从外存储器中读取第一文件块;
文件编辑器读取目标基础数据单元,获取第一文件块的位置信息,并根据第一文件块的位置信息从外存储器中读取第一文件块。
108、文件编辑器根据目标修改的信息对第一文件块进行恢复或撤销。
文件编辑器读取第一文件块后,可以根据目标基础数据单元中的目标修改的信息对第一文件块进行恢复或撤销。
需要说明的是,上述实施例中,文件编辑器对待处理文件的文件块进行修改后,可以将修改后的文件块自动保存至外存储器中,也可以在接收到保存指令时才将其保存至外存储器中,下面分别进行说明:
一、文件编辑器在接收到保存指令时才将修改后的文件块保存至外存储器中:
在本实施例中,文件编辑器对待处理文件的文件块进行修改后,只有当文件编辑器接收到保存指令时,才会将修改后的文件块保存至外存储器中,具体请参阅图2,本发明文件编辑方法另一实施例包括:
201、文件编辑器接收保存指令;
当用户通过文件编辑器对待处理文件的第一文件块进行修改后,文件编辑器会记录修改的信息和第一文件块的位置信息,生成并在数据链表中存储第二基础数据单元,并将当前修改标识指向第二基础数据单元。若用户需要将第一文件块发生改变的文件内容保存到外存储器中,用户可以向文件编辑器输入保存指令,文件编辑器可以接收到用户输入的保存指令。
202、文件编辑器对第一文件块进行保存;
当文件编辑器接收到保存指令后,可以对第一文件块进行保存,将第一文件块发生改变的文件内容保存到外存储器中。
203、文件编辑器将保存修改标识指向第二基础数据单元;
文件编辑器接收到保存指令后,可以将保存修改标识指向第二基础数据单元,第二基础数据单元为当前修改标识所指向的基础数据单元。本步骤可以在步骤202之前执行,也可以在步骤202之后执行,还可以与步骤202同时执行,此处不做具体限定。
基础数据单元包含修改的信息和被修改的文件块的位置信息。文件块的位置信息可以包括文件块在文件全文中的起始位置、终止位置和文件块的长度中的至少两个。文件块在文件全文中的起始位置可以为文件指针从文件的起始位置移动到文件块的起始位置所产生的偏移量,文件块在文件全文中的终止位置可以为文件指针从文件起始位置移动到文件块的终止位置所产生的偏移量,还可以用其他方式来指示文件块在文件全文中的起始和终止位置,此处不做具体限定。当文件编辑器接收保存指令时,文件编辑器会将接收保存指令之前对待修改文件所做的修改写入外存储器中的待修改文件,可能导致文件块在文件全文中的起始位置、终止位置和文件块的长度发生改变,因此还需要对数据链表中基础数据单元的文件块的位置信息进行更新。以文件块的位置信息包括文件块在文件全文中的起始位置和终止位置为例,可以从链首开始对数据链表中的基础数据单元逐个进行修正,具体方法可以为:
记当前正在进行修正的基础数据单元为Ix,其中记录的文件块的起始位置和终止位置分别记为P1和P2,遍历数据链表,确定所有记录的修改位置位于P1之前的基础数据单元,如I1、I2、I3和I4,记修改所造成的字符偏移量分别为Δ1、Δ2、Δ3和Δ4。例如,如果某项修改为在文件块中删除了5各字符,添加了2个字符,则该项修改所造成的字符偏移量Δ为-3个字符。将Δ1、Δ2、Δ3、Δ4和P1相加,则得到Ix修正后的P1。对Ix的P2进行修正的方法与上述对P1的修正方法类似,此处不再赘述。对数据链表中基础数据单元的文件块的位置信息进行更新还可以通过其他方法,此处不做具体限定。
为避免保存修改对文件块的位置信息造成的影响,可以在外存储器中采取其他方法存储文件块,例如,可以将文件块在不同的外存储器区域进行分布式存储,比如,将第一文件块存储在外存储器的第一存储区域,第一存储区域足够大,足够存储修改后的第一文件块,那么第一文件块的位置信息为第一存储区域。当文件编辑器需要读取第一文件块时,只需将第一存储区域存储的文件内容全部读取出来即可。在具体应用中,还可以以其他方法对文件块进行存储, 只要可以避免保存修改对文件块的位置信息造成的影响即可。可见,在这种情况下,文件编辑器在接收保存指令时,不用对基础数据单元中文件块的位置信息进行更新。
本实施例中的步骤204至步骤207与图1所示实施例中的步骤101至104相同,此处不再赘述。
208、文件编辑器从外存储器中读取第二文件块;
当用户需要编辑第二文件块的内容时,文件编辑器会从外存储器中读取第二文件块。
209、文件编辑器从内存中删除第一文件块;
当用户需要编辑第二文件块的内容时,文件编辑器可以从内存中删除第一文件块,以将第二文件块载入文件编辑器。需要说明的是,步骤208和步骤209的执行顺序可以互换,即文件编辑器先从内存中删除第一文件块,再从外存储器中读取第二文件块,此处不做具体限定。
210、文件编辑器显示待处理文件的第二文件块;
文件编辑器在从外存储器中读取第二本件块并从内存中删除第一文件块之后,可以向用户显示待处理文件的第二文件块。
步骤208至步骤210用于说明当文件编辑器接收恢复或撤销指令时,恢复或撤销操作对应的文件块不为当前显示的文件块时的情况,在实际使用中,步骤208至步骤210也可以不发生,即恢复或撤销操作对应的文件块为当前显示的文件块。
211、文件编辑器接收恢复或撤销指令;
用户可以向文件编辑器输入恢复指令,用以恢复之前撤销的修改操作,文件编辑器可以接收到恢复指令,用户也可以向文件编辑器输入撤销指令,用以撤销之前的修改操作,文件编辑器可以接收到撤销指令。
212、文件编辑器根据当前修改标识确定恢复或撤销指令对应的基础数据单元为目标基础数据单元;
若文件编辑器接收到恢复指令,文件编辑器会确定当前修改标识所指向的基础数据单元,若当前修改标识指向第一基础数据单元,那么文件编辑器可以在数据链表中确定此恢复指令对应的基础数据单元为目标基础数据单元。
若文件编辑器接收到撤销指令,文件编辑器会确定当前修改标识所指向的 基础数据单元,若当前修改标识指向目标基础数据单元,那么文件编辑器可以在数据链表中确定此撤销指令对应的基础数据单元为目标基础数据单元。
本实施例中的步骤213与图1所示实施例中的步骤107相同,此处不再赘述。
214、文件编辑器按照从数据链表的目标基础数据单元段的起点至终点的顺序对第一文件块进行恢复或撤销;
文件编辑器按照从数据链表的目标基础数据单元段的起点至终点的顺序对第一文件块进行恢复,得到当前修改状态下的第一文件块,基础数据单元段的起点为保存修改标识指向的第二基础数据单元,基础数据单元段的终点为当前修改标识指向的第三基础数据单元。若文件编辑器接收到恢复指令,则第三基础数据单元为第一基础数据单元,若接收到撤销指令,则第三基础数据单元为目标基础数据单元。
步骤201至步骤203主要解释了文件编辑器接收保存指令时所进行的具体操作,在实际使用中,步骤201至步骤203可以不发生,甚至文件编辑器在接收恢复指令前可以没有接收过保存指令,那么文件编辑器按照从数据链表的链首至当前修改标识指向的第三基础数据单元的顺序对第一文件块进行恢复。或者保存修改标识可以指向数据链表中第一基础数据单元后面的基础数据单元,那么文件编辑器按照从数据链表的目标基础数据单元段的起点至终点的顺序对第一文件块进行撤销。
若第一文件块即为文件编辑器当前显示的文件块,那么步骤213和步骤214也可以不执行。
215、文件编辑器根据目标修改的信息对第一文件块进行恢复或撤销;
文件编辑器将读取到的第一文件块由上次保存时的修改状态转化为当前修改状态后,可以根据目标修改的信息对转化后的第一文件块进行恢复或撤销。
文件编辑器在接收到恢复指令,并确定当前修改标识所指向的基础数据单元为第一基础数据单元后,可以将当前修改标识指向目标基础数据单元。而文件编辑器在接收到撤销指令,并确定当前修改标识所指向的基础数据单元为目标基础数据单元后,可以将当前修改标识指向第一基础数据单元。
二、文件编辑器将修改后的文件块自动保存至外存储器中:
在本实施例中,文件编辑器对待处理文件的第一文件块进行目标修改后,可以将修改后的第一文件块自动保存至外存储器中,以备份当前修改状态下的第一文件块,具体请参阅图3,本发明文件编辑方法另一实施例包括:
本实施例中的步骤301至步骤304与图1所示实施例中的步骤101至步骤104相同,此处不再赘述。
305、文件编辑器将进行了目标修改的第一文件块保存至外存储器中;
文件编辑器在对待处理文件的第一文件块进行目标修改后,可以将修改的第一文件块保存到外存储器中。将修改的第一文件块保存到外存储器中,可以通过将整个文件块写入外存储器并删除原文件块,也可以通过将修改的内容写入外存储器中的原文件块中,还可以通过其他方法,只要可以将外存储器中保存的第一文件块更新为当前修改状态即可。本实施例对步骤305和步骤302至步骤304中任一步骤之间的时序不做具体限定,只要在将第一文件块从内存中删除之前,文件编辑器已经将当前修改状态下的第一文件块保存至外存储器即可。
本实施例中的步骤306至步骤311与图2所示实施例中的步骤208至步骤213相同,本实施例中的步骤312与图2所示实施例中的步骤215相同,此处不再赘述。
上面对本发明实施例中的文件编辑方法进行了描述,下面对本发明实施例中的文件编辑器进行描述。
请参阅图4,本发明实施例中文件编辑器400的一个实施例包括:
修改模块401,用于对待处理文件的第一文件块进行目标修改;
记录模块402,用于记录目标修改的信息和第一文件块的位置信息得到目标基础数据单元,目标修改的信息包括目标修改的内容和目标修改的内容在第一文件块中的位置信息;
第一存储模块403,用于将所述目标基础数据单元存储于数据链表中第一基础数据单元之后,所述第一基础数据单元为当前修改标识所指向的基础数据单元;
第一指向模块404,用于将当前修改标识指向目标基础数据单元;
第一接收模块405,用于接收恢复或撤销指令;
确定模块406,用于根据当前修改标识确定恢复或撤销指令对应的基础数 据单元为目标基础数据单元;
第一读取模块407,用于根据第一文件块的位置信息从外存储器中读取第一文件块;
第一恢复模块408,用于根据目标修改的信息对第一文件块进行恢复;
第一撤销模块409,用于根据目标修改的信息对第一文件块进行撤销。
本实施例中的文件编辑器各模块间的关系参照图1对应的实施例,此处不再赘述。
需要说明的是,上述实施例中,文件编辑器对待处理文件的文件块进行修改后,可以将修改后的文件块自动保存至外存储器中,也可以在接收到保存指令时才将其保存至外存储器中,下面分别进行说明:
一、文件编辑器在接收到保存指令时才将修改后的文件块保存至外存储器中:
在本实施例中,文件编辑器对待处理文件的文件块进行修改后,只有当文件编辑器接收到保存指令时,才会将修改后的文件块保存至外存储器中,具体请参阅图5,本发明文件编辑器500另一实施例包括:
第二接收模块501,用于接收保存指令;
保存模块502,用于对第一文件块进行保存;
第二指向模块503,用于将保存修改标识指向第二基础数据单元;
本实施例中的模块504与图4所示实施例中的模块401,模块505与模块402,模块506与模块403,模块507与模块404执行的功能分别相同,此处不再赘述。
第二读取模块508,用于从外存储器中读取第二文件块;
删除模块509,用于从内存中删除第一文件块;
显示模块510,用于显示待处理文件的第二文件块;
第一接收模块511,用于接收恢复或撤销指令;
确定模块512,用于根据当前修改标识确定恢复或撤销指令对应的基础数据单元为目标基础数据单元;
本实施例中的模块513与图4所示实施例中的模块407执行的功能相同,此处不再赘述。
第二恢复模块514,用于按照从数据链表的目标基础数据单元段的起点至 终点的顺序对第一文件块进行恢复;
第二撤销模块515,用于按照从数据链表的目标基础数据单元段的起点至终点的顺序对第一文件块进行撤销;
第一恢复模块516,用于根据目标修改的信息对第一文件块进行恢复;
第一撤销模块517,用于根据目标修改的信息对第一文件块进行撤销。
本实施例中的文件编辑器各模块间的关系参照图2对应的实施例,此处不再赘述。
二、文件编辑器将修改后的文件块自动保存至外存储器中:
在本实施例中,文件编辑器对待处理文件的第一文件块进行目标修改后,可以将修改后的第一文件块自动保存至外存储器中,以备份当前修改状态下的第一文件块,具体请参阅图6,本发明文件编辑器600另一实施例包括:
本实施例中的步骤601至步骤604与图1所示实施例中的步骤401至步骤404相同,此处不再赘述。
第二存储模块605,用于将进行了目标修改的第一文件块存储至外存储器中;
本实施例中的模块606与图5所示实施例中的模块508,模块607与模块509,模块608与模块510,模块609与模块511,模块610与模块512,模块611与模块513,模块612与模块516,模块613与模块517所执行的功能相同,此处不再赘述。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的***,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的***,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个***,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元 显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,RandomAccess Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
以上,以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。

Claims (23)

  1. 一种文件编辑方法,其特征在于,包括:
    文件编辑器对待处理文件的第一文件块进行目标修改,并记录所述目标修改的信息和所述第一文件块的位置信息得到目标基础数据单元,所述目标修改的信息包括所述目标修改的内容和所述目标修改的内容在所述第一文件块中的位置信息;
    所述文件编辑器将所述目标基础数据单元存储于数据链表中第一基础数据单元之后,所述第一基础数据单元为当前修改标识所指向的基础数据单元,并将所述当前修改标识指向所述目标基础数据单元;
    所述文件编辑器接收恢复或撤销指令;
    所述文件编辑器根据所述当前修改标识确定所述恢复或撤销指令对应的基础数据单元为所述目标基础数据单元;
    所述文件编辑器根据所述第一文件块的位置信息从外存储器中读取所述第一文件块;
    所述文件编辑器根据所述目标修改的信息对所述第一文件块进行恢复或撤销。
  2. 根据权利要求1所述的文件编辑方法,其特征在于,在所述文件编辑器接收恢复或撤销指令之前,所述方法还包括:
    所述文件编辑器接收保存指令;
    所述文件编辑器对所述第一文件块进行保存,并将保存修改标识指向第二基础数据单元,所述第二基础数据单元为所述当前修改标识所指向的基础数据单元。
  3. 根据权利要求2所述的文件编辑方法,其特征在于,在所述文件编辑器根据所述第一文件块的位置信息从外存储器中读取所述第一文件块之后,所述文件编辑器根据所述目标修改的信息对所述第一文件块进行恢复或撤销之前,所述方法还包括:
    所述文件编辑器按照从所述数据链表的目标基础数据单元段的起点至终点的顺序对所述第一文件块进行恢复或撤销,所述基础数据单元段的起点为所述保存修改标识指向的第二基础数据单元,所述基础数据单元段的终点为所述当前修改标识指向的第三基础数据单元。
  4. 根据权利要求1所述的文件编辑方法,其特征在于,所述第一文件块的位置信息包括所述第一文件块在文件全文中的起始位置、终止位置和所述第一文件块的长度中的至少两个。
  5. 根据权利要求1所述的文件编辑方法,其特征在于,所述第一文件块的位置信息为所述第一文件块在外存储器中的存储位置。
  6. 根据权利要求4所述的文件编辑方法,其特征在于,在所述文件编辑器将所述目标基础数据单元存储于数据链表中之后,在所述文件编辑器接收恢复或撤销指令之前,所述方法还包括:
    所述文件编辑器接收保存指令;
    所述文件编辑器对所述目标基础数据单元中的第一文件块的位置信息进行更新。
  7. 根据权利要求1至6中任一项所述的文件编辑方法,其特征在于,在所述文件编辑器将所述目标基础数据单元存储于数据链表中之后,在所述文件编辑器接收恢复或撤销指令之前,所述方法还包括:
    所述文件编辑器从内存中删除所述第一文件块,并从外存储器中读取、显示所述待处理文件的第二文件块。
  8. 根据权利要求7所述的文件编辑方法,其特征在于,在所述文件编辑器对待处理文件的第一文件块进行目标修改之后,在所述文件编辑器从内存中删除所述第一文件块之前,所述方法还包括:
    所述文件编辑器根据所述第一文件块的位置信息对所述第一文件块进行存储。
  9. 根据权利要求7所述的文件编辑方法,其特征在于,在所述文件编辑器根据所述当前修改标识确定所述恢复或撤销指令对应的基础数据单元为所述目标基础数据单元之后,在所述文件编辑器根据所述第一文件块的位置信息从外存储器中读取所述第一文件块之前,所述方法还包括:
    所述文件编辑器判断所述第二文件块与所述第一文件块是否为同一文件块;
    若是,则触发根据所述目标修改的信息对所述第一文件块进行恢复或撤销的操作;
    若否,则触发根据所述第一文件块的位置信息从外存储器中读取所述第一 文件块的操作。
  10. 根据权利要求1至6中任一项所述的文件编辑方法,其特征在于,若所述文件编辑器接收恢复指令,则在所述文件编辑器根据所述目标修改的信息对所述第一文件块进行恢复之后,所述方法还包括:
    所述文件编辑器将所述当前修改标识指向所述目标基础数据单元。
  11. 根据权利要求1至6中任一项所述的文件编辑方法,其特征在于,若所述文件编辑器接收撤销指令,则在所述文件编辑器根据所述目标修改的信息对所述第一文件块进行撤销之后,所述方法还包括:
    所述文件编辑器将所述当前修改标识指向第一基础数据单元。
  12. 根据权利要求1至6中任一项所述的文件编辑方法,其特征在于,所述目标修改的内容包括删除的文件内容和/或添加的文件内容。
  13. 一种文件编辑器,其特征在于,包括:
    修改模块,用于对待处理文件的第一文件块进行目标修改;
    记录模块,用于记录所述目标修改的信息和所述第一文件块的位置信息得到目标基础数据单元,所述目标修改的信息包括所述目标修改的内容和所述目标修改的内容在所述第一文件块中的位置信息;
    第一存储模块,用于将所述目标基础数据单元存储于数据链表中第一基础数据单元之后,所述第一基础数据单元为当前修改标识所指向的基础数据单元;
    第一指向模块,用于将所述当前修改标识指向所述目标基础数据单元;
    第一接收模块,用于接收恢复或撤销指令;
    确定模块,用于根据所述当前修改标识确定所述恢复或撤销指令对应的基础数据单元为所述目标基础数据单元;
    第一读取模块,用于根据所述第一文件块的位置信息从外存储器中读取所述第一文件块;
    第一恢复模块,用于根据所述目标修改的信息对所述第一文件块进行恢复;
    第一撤销模块,用于根据所述目标修改的信息对所述第一文件块进行撤销。
  14. 根据权利要求13所述的文件编辑器,其特征在于,所述文件编辑器 还包括:
    第二接收模块,用于接收保存指令;
    保存模块,用于对所述第一文件块进行保存;
    第二指向模块,用于将保存修改标识指向第二基础数据单元,所述第二基础数据单元为所述当前修改标识所指向的基础数据单元。
  15. 根据权利要求14所述的文件编辑器,其特征在于,所述文件编辑器还包括:
    第二恢复模块,用于按照从所述数据链表的目标基础数据单元段的起点至终点的顺序对所述第一文件块进行恢复;
    第二撤销模块,用于按照从所述数据链表的目标基础数据单元段的起点至终点的顺序对所述第一文件块进行撤销;
    所述基础数据单元段的起点为所述保存修改标识指向的第二基础数据单元,所述基础数据单元段的终点为所述当前修改标识指向的第三基础数据单元。
  16. 根据权利要求13所述的文件编辑器,其特征在于,所述第一文件块的位置信息包括所述第一文件块在文件全文中的起始位置、终止位置和所述第一文件块的长度中的至少两个。
  17. 根据权利要求13所述的文件编辑器,其特征在于,所述第一文件块的位置信息为所述第一文件块在外存储器中的存储位置。
  18. 根据权利要求16所述的文件编辑器,其特征在于,所述文件编辑器还包括:
    第三接收模块,用于接收保存指令;
    更新模块,用于对所述目标基础数据单元中的第一文件块的位置信息进行更新。
  19. 根据权利要求13至18中任一项所述的文件编辑器,其特征在于,所述文件编辑器还包括:
    删除模块,用于从内存中删除所述第一文件块;
    第二读取模块,用于从外存储器中读取所述待处理文件的第二文件块;
    显示模块,用于显示所述待处理文件的第二文件块。
  20. 根据权利要求19所述的文件编辑器,其特征在于,所述文件编辑器 还包括:
    第二存储模块,用于根据所述第一文件块的位置信息对所述第一文件块进行存储。
  21. 根据权利要求19所述的文件编辑器,其特征在于,所述文件编辑器还包括:
    判断模块,用于判断所述第二文件块与所述第一文件块是否为同一文件块;
    第一触发模块,用于当所述第二文件块与所述第一文件块为同一文件块时,触发根据所述目标修改的信息对所述第一文件块进行恢复或撤销的操作;
    第二触发模块,用于当所述第二文件块与所述第一文件块不为同一文件块时,触发根据所述第一文件块的位置信息从外存储器中读取所述第一文件块的操作。
  22. 根据权利要求13至18中任一项所述的文件编辑器,其特征在于,所述文件编辑器还包括:
    第三指向模块,用于将所述当前修改标识指向所述目标基础数据单元。
  23. 根据权利要求13至18中任一项所述的文件编辑器,其特征在于,所述文件编辑器还包括:
    第四指向模块,用于将所述当前修改标识指向第一基础数据单元。
PCT/CN2015/100168 2015-12-31 2015-12-31 一种文件编辑方法和文件编辑器 WO2017113317A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201580080837.4A CN107924397B (zh) 2015-12-31 2015-12-31 一种文件编辑方法和文件编辑器
PCT/CN2015/100168 WO2017113317A1 (zh) 2015-12-31 2015-12-31 一种文件编辑方法和文件编辑器

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/100168 WO2017113317A1 (zh) 2015-12-31 2015-12-31 一种文件编辑方法和文件编辑器

Publications (1)

Publication Number Publication Date
WO2017113317A1 true WO2017113317A1 (zh) 2017-07-06

Family

ID=59224207

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/100168 WO2017113317A1 (zh) 2015-12-31 2015-12-31 一种文件编辑方法和文件编辑器

Country Status (2)

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

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111352909A (zh) * 2019-05-07 2020-06-30 鸿合科技股份有限公司 一种文件保存及加载方法、设备、电子设备及存储介质
CN112416325A (zh) * 2019-08-22 2021-02-26 福建天泉教育科技有限公司 一种Unity中构建ab包的方法及终端
CN113312212A (zh) * 2021-06-02 2021-08-27 广联达科技股份有限公司 保护模型构件参数的方法、装置、设备和可读存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110389796A (zh) * 2019-07-01 2019-10-29 北京字节跳动网络技术有限公司 编辑操作处理方法、装置及电子设备
CN112363708B (zh) * 2020-12-04 2023-03-10 中信银行股份有限公司 一种支持Eclipse工具下的上下文保护方法及***
CN115130845A (zh) * 2022-06-21 2022-09-30 江苏未来智慧信息科技有限公司 光伏发电智能管理***与管理方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070204126A1 (en) * 2006-02-24 2007-08-30 Bangalore Kiran K Reclaim algorithm for fast edits in a nonvolatile file system
CN101551793A (zh) * 2008-04-03 2009-10-07 鸿富锦精密工业(深圳)有限公司 文件保存及编辑方法
CN103440181A (zh) * 2013-09-06 2013-12-11 珠海金山网络游戏科技有限公司 一种文件修改的方法及***
CN104092780A (zh) * 2014-07-29 2014-10-08 中国联合网络通信集团有限公司 基于文件分块的文件修改方法、单文件同步方法及装置
CN104199856A (zh) * 2014-08-13 2014-12-10 北京配天技术有限公司 呈现文件的方法和文件呈现装置

Family Cites Families (10)

* 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
TWI425375B (zh) * 2010-01-20 2014-02-01 Inventec Corp 伺服器檔案管理之方法
CN101751478A (zh) * 2010-02-20 2010-06-23 浪潮(北京)电子信息产业有限公司 一种文件备份方法及***
CN102737032B (zh) * 2011-04-06 2016-06-08 腾讯科技(深圳)有限公司 文件恢复的方法及装置
US9411687B2 (en) * 2011-06-03 2016-08-09 Apple Inc. Methods and apparatus for interface in multi-phase restore
JP5831235B2 (ja) * 2012-01-06 2015-12-09 ティアック株式会社 ファイル編集装置
CN104254853A (zh) * 2012-04-25 2014-12-31 株式会社日立制作所 文件存储***和文件克隆方法
US9348840B2 (en) * 2012-12-14 2016-05-24 Intel Corporation Adaptive data striping and replication across multiple storage clouds for high availability and performance
CN103294957B (zh) * 2013-05-06 2015-10-28 北京赛思信安技术有限公司 支持重复数据删除文件***中数据更新时的数据保护方法
CN104199967A (zh) * 2014-09-22 2014-12-10 广东欧珀移动通信有限公司 一种手机文件的恢复方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070204126A1 (en) * 2006-02-24 2007-08-30 Bangalore Kiran K Reclaim algorithm for fast edits in a nonvolatile file system
CN101551793A (zh) * 2008-04-03 2009-10-07 鸿富锦精密工业(深圳)有限公司 文件保存及编辑方法
CN103440181A (zh) * 2013-09-06 2013-12-11 珠海金山网络游戏科技有限公司 一种文件修改的方法及***
CN104092780A (zh) * 2014-07-29 2014-10-08 中国联合网络通信集团有限公司 基于文件分块的文件修改方法、单文件同步方法及装置
CN104199856A (zh) * 2014-08-13 2014-12-10 北京配天技术有限公司 呈现文件的方法和文件呈现装置

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111352909A (zh) * 2019-05-07 2020-06-30 鸿合科技股份有限公司 一种文件保存及加载方法、设备、电子设备及存储介质
CN112416325A (zh) * 2019-08-22 2021-02-26 福建天泉教育科技有限公司 一种Unity中构建ab包的方法及终端
CN113312212A (zh) * 2021-06-02 2021-08-27 广联达科技股份有限公司 保护模型构件参数的方法、装置、设备和可读存储介质
CN113312212B (zh) * 2021-06-02 2024-05-07 广联达科技股份有限公司 保护模型构件参数的方法、装置、设备和可读存储介质

Also Published As

Publication number Publication date
CN107924397A (zh) 2018-04-17
CN107924397B (zh) 2021-12-03

Similar Documents

Publication Publication Date Title
WO2017113317A1 (zh) 一种文件编辑方法和文件编辑器
CN103235685B (zh) 一种设置终端操作***桌面内容的方法和装置
EP3564844B1 (en) Data deduplication method and apparatus
KR20190095066A (ko) 정보 처리 방법, 장치, 서버 및 컴퓨터 판독 가능 매체
TWI502384B (zh) 檔案追蹤方法及其所適用之網路通訊裝置
US10860447B2 (en) Database cluster architecture based on dual port solid state disk
CN106951521B (zh) 日志文件的读写方法、装置及***
CN110998537B (zh) 一种过期备份处理方法及备份服务器
JP2008217209A (ja) 差分スナップショット管理方法、計算機システム及びnas計算機
US10394797B2 (en) Method and computing apparatus for managing main memory database
US20160314048A1 (en) Backup and related operations
EP3286665B1 (en) Rich attachment regeneration
US20150012846A1 (en) Method, System and Mobile Terminal for Deleting Chat Record
CN104166605A (zh) 基于增量数据文件的数据备份方法及***
WO2010145269A1 (zh) 一种还原终端操作和数据的方法及装置
CN103942126A (zh) 电子设备及其数据备份方法
CN107770207A (zh) 多终端设备间数据同步的方法
CN104331343A (zh) 文件备份方法和***
US9087093B2 (en) Method for implementing electronic bookmarks and device thereof
CN103713926A (zh) 一种预更新软件客户端的方法及***
US20120185440A1 (en) Method and apparatus for providing address book restoration
CN103037076A (zh) 一种移动终端的状态备份还原方法及装置
CN103995706A (zh) 一种图片缩略图显示方法及装置
WO2017067397A1 (zh) 一种数据恢复方法和装置
US20150347008A1 (en) Method for controlling virtual keyboard and electronic device implementing the same

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15911943

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15911943

Country of ref document: EP

Kind code of ref document: A1