Summary of the invention
The invention provides a kind of Ile repair method and device, it is possible to illegally extracted at movable storage device, and
In the case of file therein is destroyed, destroyed file is repaired.
The invention provides following scheme:
A kind of Ile repair method, including:
After detecting that movable storage device inserts, monitoring is stored in the operation of file to described movable storage device;
When being stored in file in described movable storage device, source path and the described mobile storage of record this document set
Standby identification information;
If be detected that illegally extract the message of described movable storage device, then described record is preserved;
When detect described movable storage device again insertable into time, it is judged that the file in described movable storage device is the most
Damage;
If it is, utilize the document source path in the record of described preservation that the described file damaged is repaiied
Multiple.
Wherein, the described file damaged is repaired by the document source path in the described record utilizing described preservation
Including:
Document source path in the record of described preservation is supplied to user, in order to user is from described document source path
Reacquire described file, in order to the file damaged described in replacing.
Wherein, the described file damaged is repaired by the document source path in the described record utilizing described preservation
Including:
Document source path from the record of described preservation obtains described file;
With the file damaged described in the replacement of the described file got.
Preferably, if be detected that illegally extract the message of described movable storage device, described method also includes:
The file being stored in described movable storage device backs up;
The file damaged is repaired unsuccessful, then if, with the document source path in the record of described preservation
The described file damaged is repaired by the file utilizing described backup.
Wherein, the described file judged in described movable storage device has the most damaged and has included:
Identify whether the file in described movable storage device has end mark;If do not had, it is determined that described shifting
File in dynamic storage device damages;
If it has, then read the data of source file according to described document source path, by described movable storage device
The data of file compare with the data of described source file, if unanimously, it is determined that the literary composition in described movable storage device
Part damages the most, if it is inconsistent, the file determined in described movable storage device damages.
Preferably, also include:
If be detected that normally extract the message of described movable storage device, then described record is destroyed.
A kind of file prosthetic device, including:
Monitoring unit, after being used for detecting that movable storage device inserts, monitoring is stored in file to described movable storage device
Operation;
Record unit, for when described movable storage device is stored in file, the source path of record this document and
The identification information of described movable storage device;
Storage unit, for if be detected that illegally extract the message of described movable storage device, then by described record into
Row preserves;
Judging unit, for when detect described movable storage device again insertable into time, it is judged that described movable storage device
In file the most damage;
Repair unit, for if it is, utilize the document source path in the record of described preservation to damage described
File repair.
Wherein, described reparation unit includes:
Path provides subelement, for the document source path in the record of described preservation is supplied to user, in order to use
Family reacquires described file from described document source path, in order to the file damaged described in replacing.
Wherein, described reparation unit includes:
File acquisition subelement, obtains described file for the document source path from the record of described preservation;
Replace subelement, for described in the file that gets replace described in the file that damaged.
Preferably, also include:
File backup unit, for if be detected that illegally extract the message of described movable storage device, is stored into institute
The file stated in movable storage device backs up;
Supplement and repair unit, for if, with the file to having damaged of the document source path in the record of described preservation
Carry out repairing unsuccessful, then utilize the file of described backup that the described file damaged is repaired.
Wherein, described judging unit includes:
Identify subelement, for identifying whether the file in described movable storage device has end mark;If do not had
Have, it is determined that the file in described movable storage device damages;
Comparer unit, for if it has, then read the data of source file, by described according to described document source path
The data of the data of the file in movable storage device and described source file are compared, if unanimously, it is determined that described movement
File in storage device damages the most, if it is inconsistent, the file determined in described movable storage device damages.
Preferably, also include:
Destroy unit, for if be detected that normally extract the message of described movable storage device, then by described record into
Marketing is ruined.
The specific embodiment provided according to the present invention, the invention discloses techniques below effect:
By the invention it is possible to when the operation being stored in file to movable storage device being detected, the file that this is stored in
Source path and the mark of movable storage device carry out record, once detect that movable storage device is illegally extracted,
Just this record can be preserved;So, when detecting that this movable storage device is re-inserted into, can be first determined whether it
In file whether be destroyed, if it is, destroyed file can be repaired by the source path of this document.Also
That is, by means of the invention it is possible to illegally extracted at movable storage device, and in the case of file therein is destroyed, to quilt
The file destroyed is repaired.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Describe, it is clear that described embodiment is only a part of embodiment of the present invention rather than whole embodiments wholely.Based on
Embodiment in the present invention, the every other embodiment that those of ordinary skill in the art are obtained, broadly fall into present invention protection
Scope.
Seeing Fig. 1, the Ile repair method that the embodiment of the present invention provides comprises the following steps:
S101: after detecting that movable storage device inserts, monitoring is stored in the operation of file to described movable storage device;
Firstly the need of explanation, during owing to writing a file in movable storage device, it is not to be saved in shifting at once
In dynamic storage device, but first it is stored in relief area, waits accumulation to be saved in the most together in movable storage device.As
Fruit the most successfully unloads and the most illegally extracts movable storage device, and system is ignorant, and the function such as fopen, fwrite is the most still
Return correct, the when of until operating system to be deposited into the data in relief area in movable storage device, just can point out I/O
Mistake, therefore, a lot of data all can be lost because of this error reporting not in time.
From the above, in actual applications, if performing the operation being stored in file in movable storage device,
The most once movable storage device is illegally extracted, and will there is the risk that file has damaged, and the file damaged is exactly this
The file being stored into, and other the original files in movable storage device, the most typically will not damage.Therefore, real in the present invention
Execute in example, can only operation to being stored in file in movable storage device be monitored.
Wherein, owing to being inserted by USB interface at movable storage device, or when USB port is extracted, USB device driver
Will modify CONFIG.SYS, such as USB device driver can be when inserting or pull out toward "/proc/scsi/usb-
Storage-0/0 " the inside note upper " Attached: Yes or No ", therefore, by checking that this file just can detect shifting
Whether dynamic storage device inserts or pull out.
S102: when being stored in file in described movable storage device, the source path of record this document and described movement
The identification information of storage device;
Wherein, when being stored in file in movable storage device, it is common that after certain local for computer file is replicated, viscous
It is attached in movable storage device, or certain file that computer is local " is sent to " in movable storage device, etc..Therefore,
" source path of file " described in the embodiment of the present invention refers to, and is stored in the file of movable storage device in computer this locality
Path.Such as, certain file path in computer this locality is " F: work relevant XX.txt ", then be deposited into by this document
Time in movable storage device, the source path of this document is exactly " F: work relevant XX.txt ".
The identification information of movable storage device refers to uniquely to identify the information of a movable storage device, a movement
Storage device is in the Shi Douhui mark with uniqueness, such as, serial number of USB flash disk etc. of dispatching from the factory.Therefore, when implementing, just
The identification information of movable storage device can be obtained by obtaining the serial number of movable storage device, such as, pass through
This function of DriveGetSerial, can get the serial number of movable storage device, then record.
Certainly, after being inserted on computer by a movable storage device, multiple file may be stored in wherein, this
Time, the source path of each file can be recorded in the way of form, the corresponding same movement of the source path of these files
Storage device identification.
S103: if be detected that illegally extract the message of described movable storage device, then described record is preserved;
When movable storage device is wiped from USB port, if using normal Uninstaller successfully to unload, then system
One can be produced and represent the message normally extracted, such as " IRP_MN_REMOVE_DEVICE ";And if illegally extracting a shifting
Dynamic storage device, then, after system discovery, can produce one and represent the message illegally extracted, such as " IRP_MN_SURPRISE_
REMOVAL”.Therefore, by obtaining the message that system produces, can judge that movable storage device is normally to extract, or quilt
Illegally extract.If illegally extracted, then the information recorded before can be preserved, for follow-up use.Certainly, if
It is normally to extract, does not the most generally have the phenomenon that file has damaged, therefore, in order to avoid memory space is caused wave
Take, the record obtained before can be destroyed.
S104: when detect described movable storage device again insertable into time, it is judged that the file in described movable storage device
The most damage;
If again having detected that movable storage device is inserted into USB port, can first obtain this movable storage device
Identification information (equally uses DriveGetSerial function to obtain the mode of serial number of movable storage device, certainly
Can also adopt and realize in other ways, not be defined), then look at and whether the record of preservation exists this mark letter
The record that breath is corresponding, if it has, then prove, when this movable storage device was inserted on this computer last time, once illegally to be extracted
Cross, and then, it is possible to determine whether that file therein damages the most.
Wherein, as it was noted above, if owing to movable storage device is illegally extracted and file is caused damage, the most generally
Being to cause owing to the data of file are also not completely written to movable storage device, therefore, this file damaged is counting
According to upper the most incomplete.And a complete file would generally have end mark, therefore, judging movable storage device
In file when the most damaging, it is possible to first identify whether the file in described movable storage device has end mark,
If not having end mark, then prove that the data of this document are incomplete, hence, it can be determined that this document damages the most
Bad.If the data of a file have end mark, then can read the data of source file according to the source path of this document,
The data of the current file in movable storage device are compared with the data of source file, if consistent (such as, file size
Equal, MD5 value is identical etc.), it is determined that the file in this movable storage device damages the most, if it is inconsistent, determine this
File in movable storage device damages.
Or, in actual applications, it is also possible to directly by the number of the data of the file in movable storage device Yu source file
According to comparing, if both are consistent, then documentary evidence is not destroyed, if it is inconsistent, documentary evidence has been destroyed.
It should be noted that the file described in the embodiment of the present invention damages, the situation that file all damages can be included,
Can also include partial destruction situation (such as, the partial document in a file bag damages, it is possible to be referred to as part damage
Bad).
S105: if it is, utilize the document source path in the record of described preservation that the described file damaged is entered
Row is repaired.
When movable storage device is re-inserted into, if it find that this movable storage device is when inserting last time, by illegally
Extract, and file therein damages, it is possible to the source path about file preserved before utilization, to the literary composition damaged
Part is repaired.
Specifically when the file damaged is repaired by the source path utilizing file, can take automatically to replace or
The multiple implementation such as semi-automatic replacement.Wherein, so-called automatically replacement refers to, directly the document source path from record obtains
Damage the source file of file, the most directly replace the file damaged with this source file.So-called semi-automatic replacement refers to,
First the document source path of record can be supplied to user, then manually be reacquired literary composition according to this source path by user
Part, and replace the file damaged, etc..Certainly can also there is other implementation, will not enumerate here.
In a word, in embodiments of the present invention, owing to recognizing the file being deposited in movable storage device, it is common that from meter
In calculation machine, in the copy past, therefore, the most generally remain with source file, so, when the file in movable storage device
When damaging, it is possible to utilize the source file retained in computer, it is repaired.
Certainly, in actual applications, it is also possible to situations below occurs: when movable storage device is re-inserted into computer
Time upper, computer may be deleted about certain source file having damaged file or move under other path, this
Time, just according to the source path of file, the file damaged cannot be repaired.In order to tackle the generation of this situation,
In the embodiment of the present invention, it is also possible to when the message illegally extracting movable storage device being detected, set being deposited into mobile storage
Standby file backs up, and so, can not repair, if, with the document source path in record, the file damaged
Merit, then can utilize the file of backup to repair the file damaged.It is of course also possible to be not to find that mobile storage sets
Just source file is backed up for when illegally extracting, for example, it is also possible to source file is tracked, finding that source file is deleted
When removing or moved, then source file is backed up.Or, when finding that source file is moved, it is also possible to will preserve before
The source path about this document be revised as mobile after path, so, equally realize repairing the file damaged
Multiple.
Corresponding with the Ile repair method that the embodiment of the present invention provides, the embodiment of the present invention additionally provides a kind of file and repaiies
Apparatus for coating, sees Fig. 2, and this device may include that
Monitoring unit 201, after being used for detecting that movable storage device inserts, monitoring is stored in literary composition to described movable storage device
The operation of part;
Record unit 202, for when described movable storage device is stored in file, the source path of record this document with
And the identification information of described movable storage device;
Storage unit 203, for if be detected that illegally extract the message of described movable storage device, then by described record
Preserve;
Judging unit 204, for when detect described movable storage device again insertable into time, it is judged that described mobile storage sets
File in Bei damages the most;
Repair unit 205, for if it is, utilize the document source path in the record of described preservation to damage described
Bad file is repaired.
Wherein, specifically when utilizing the document source path preserved that the file damaged is repaired, can have multiple
Implementation, such as, wherein under a kind of implementation, repair unit 205 and specifically can include following subelement:
Path provides subelement, for the document source path in the record of described preservation is supplied to user, in order to use
Family reacquires described file from described document source path, in order to the file damaged described in replacing.
Or, under another kind of implementation, repair unit 205 and specifically can also include following subelement:
File acquisition subelement, obtains described file for the document source path from the record of described preservation;
Replace subelement, for described in the file that gets replace described in the file that damaged.
In order to avoid the source file under source path is deleted or is moved under other paths, this device can also wrap
Include:
File backup unit, for if be detected that illegally extract the message of described movable storage device, is stored into institute
The file stated in movable storage device backs up;
Supplement and repair unit, for if, with the file to having damaged of the document source path in the record of described preservation
Carry out repairing unsuccessful, then utilize the file of described backup that the described file damaged is repaired.
Certainly, specifically when movable termination equipment is re-inserted into, it is judged that the file in movable storage device is the most
The method damaged, it is possibility to have multiple, such as, wherein under a kind of implementation, it is judged that unit 204 can include that following son is single
Unit:
Identify subelement, for identifying whether the file in described movable storage device has end mark;If do not had
Have, it is determined that the file in described movable storage device damages;
Comparer unit, for if it has, then read the data of source file, by described according to described document source path
The data of the data of the file in movable storage device and described source file are compared, if unanimously, it is determined that described movement
File in storage device damages the most, if it is inconsistent, the file determined in described movable storage device damages.
If it find that movable storage device is normally extracted, then it is stored in file therein and typically will not damage, therefore, also
Just there is no need again the information such as source path to be stored.Now, this device can also include:
Destroy unit, for if be detected that normally extract the message of described movable storage device, then by described record into
Marketing is ruined.
In a word, the file prosthetic device provided by the embodiment of the present invention, can deposit to movable storage device detecting
When entering the operation of file, the source path of the file that this is stored in and the mark of movable storage device are carried out record, once examines
Measure movable storage device when illegally being extracted, it is possible to preserved by this record;So, when detecting that this moves storage and sets
For when being re-inserted into, can first determine whether whether file therein is destroyed, if it is, can be by the source of this document
Destroyed file is repaired by path.That is, by means of the invention it is possible to illegally extracted at movable storage device, and
In the case of file therein is destroyed, destroyed file is repaired.
As seen through the above description of the embodiments, those skilled in the art it can be understood that to the present invention can
The mode adding required general hardware platform by software realizes.Based on such understanding, technical scheme essence
On the part that in other words prior art contributed can embody with the form of software product, this computer software product
Can be stored in storage medium, such as ROM/RAM, magnetic disc, CD etc., including some instructions with so that a computer equipment
(can be personal computer, server, or the network equipment etc.) performs some of each embodiment of the present invention or embodiment
Method described in part.
Each embodiment in this specification all uses the mode gone forward one by one to describe, identical similar portion between each embodiment
Dividing and see mutually, what each embodiment stressed is the difference with other embodiments.Especially for device or
For system embodiment, owing to it is substantially similar to embodiment of the method, so describing fairly simple, relevant part sees method
The part of embodiment illustrates.Apparatus and system embodiment described above is only schematically, wherein said conduct
The unit of separating component explanation can be or may not be physically separate, the parts shown as unit can be or
Person may not be physical location, i.e. may be located at a place, or can also be distributed on multiple NE.Can root
Factually border need select some or all of module therein to realize the purpose of the present embodiment scheme.Ordinary skill
Personnel, in the case of not paying creative work, are i.e. appreciated that and implement.
Above to Ile repair method provided by the present invention and device, it is described in detail, tool used herein
Principle and the embodiment of the present invention are set forth by body example, and the explanation of above example is only intended to help and understands this
Bright method and core concept thereof;Simultaneously for one of ordinary skill in the art, according to the thought of the present invention, concrete real
Execute and all will change in mode and range of application.In sum, this specification content should not be construed as the limit to the present invention
System.