Method and system from the deleted JPG file of disk recovery
Technical field
The present invention relates to field of computer technology, specifically refer to from the method and system of the deleted JPG file of disk recovery.
Background technology
Data are recovered the field, and software rejuvenation can be divided into dual mode: 1, based on the recovery of file system structure; 2, based on the recovery of file content.First kind of way is the characteristics according to file system, such as NTFS(New Technology File System, the file system of Windows NT operating environment and Windows NT advanced server network operating system environment) file system can make marks the file of deletion, but the key messages such as storage positions of files still exist.The second way is the condition code of utilizing some file known, normally the content of file several bytes of beginning to locate.The first reset mode Quality of recovery is better, and usually can obtain filename, and shortcoming is at deleted file, and uses this subregion to be not easy after a period of time to find; Rear a kind of long ago file of deletion that often can find, shortcoming is there is no filename, the probability of file corruption is also higher.
In prior art, recover JPG(Joint Photographic Experts Group, JPEG (joint photographic experts group),) mode, for example Easy Recovery(file recovers software) software, first seeking the file header sign " FF D8 FF E0 " of JPG file, until find the file header of next file or reach maximal value (2G), is a JPG file with this interval content recognition.The restoration methods shortcoming that above-mentioned prior art provides is that the file that recovers is often larger, and some picture checks that software can not show correctly that this end-of-file has the picture of a lot of junk datas.
Summary of the invention
Fundamental purpose of the present invention is to provide a kind of method and system from the deleted JPG file of disk recovery, and the file content after recovery is identical with the authentic document content size, and highly versatile.
The technical solution adopted for the present invention to solve the technical problems is:
The invention provides a kind of method from the deleted JPG file of disk recovery, it comprises:
A kind of method from the deleted JPG file of disk recovery, it comprises:
S110, seek the file header condition code of JPG file, seek in disk and have the sector of file header condition code, and the skew of recording this sector is the starting position;
S120, seek backward the mark of JPG intermediate file compressed package, find the mark of described JPG intermediate file compressed package in described sector, the position of remembering the mark of this JPG intermediate file compressed package is current location, if the mark of this intermediate file compressed package is 0xfff9, and execution in step S140; Otherwise, read 16 integers after the mark of this intermediate file compressed package, recording this round values is L;
S130, from the position of current location+L, the operation of repeated execution of steps S120;
S140, determine that the data between described starting position and current location are the content of a complete JPG file, read and preserve the content of this JPG file to recover this JPG file.
Preferably, the described sector with file header condition code of seeking in disk specifically comprises: search for " ff d8 ff e0 " " ff d8 ff e1 ", " ff d8 ff ed ", the sector of " ff d8 ff ff fe " beginning in disk.
Preferably, the mark of described JPG intermediate file compressed package is at (0xffc0 ~ 0xffcf) and (16 integers in the scope of 0xffda ~ 0xfffe).
In step S110, when the file header condition code of seeking the JPG file, when searching out the sector that starts with " ff d8 ffe0 " in disk, also comprise:
Judge that described disk is whether with the sector of " ff d8 ff e0 00 10 41 56 49 31 " beginning; When being judged as YES, continue execution in step S110; When being judged as NO, execution in step S120.
A kind of system from the deleted JPG file of disk recovery, it comprises:
Condition code is sought the unit, is used for seeking the file header condition code of JPG file, seek to have the sector of file header condition code in disk, and the skew of recording this sector is the starting position;
Mark is sought the unit, is used for seeking backward the mark of JPG intermediate file compressed package; Find the mark of described JPG intermediate file compressed package in described sector, the position of remembering the mark of this JPG intermediate file compressed package is current location, if the mark of this intermediate file compressed package is 0xfff9, and startup file recovery unit; Otherwise, read 16 integers after the mark of this intermediate file compressed package, recording this round values is L, starts the mark repetitive;
The mark repetitive is used for from the position of current location+L, and triggered mark is sought the unit and repeated the searching process;
The file recovery unit is used for determining that the data between described starting position and current location are the content of a complete JPG file, reads and preserve the content of this JPG file to recover this JPG file.
Preferably, described condition code is sought the unit, is used in the sector of disk search with " ff d8 ff e0 ", " ff d8 ffe1 ", " ff d8 ff ed " or " ff d8 ff ff fe " beginning.
Preferably, the mark of described JPG intermediate file compressed package is at (0xffc0 ~ 0xffcf) and (16 integers in the scope of 0xffda ~ 0xfffe).
Preferably, described system also comprises the condition code judging unit, be used for seeking the unit when disk searches sector with " ff d8 ff e0 " beginning when described condition code, judge the sector whether described disk starts with " ff d8 ff e0 00 1,041 56 49 31 "; When being judged as YES, triggering described condition code and seek unit execution searching process; When being judged as NO, triggering described mark and seek unit execution searching process.
Implement technical scheme of the present invention, has following beneficial effect: the file that method provided by the invention undeletes according to file content, file content after recovery is identical with the authentic document content size, and highly versatile, can use and check this JPG file in various file system.
Description of drawings
The method flow diagram that Fig. 1 provides for the embodiment of the present invention;
The structural representation of the system that Fig. 2 provides for the embodiment of the present invention;
Another structural representation of the system that Fig. 3 provides for the embodiment of the present invention.
The realization of the object of the invention, functional characteristics and advantage are described further with reference to accompanying drawing in connection with embodiment.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, is not intended to limit the present invention.
The embodiment of the present invention provides a kind of method from the deleted JPG file of disk recovery, and as shown in Figure 1, the method comprising the steps of:
S110, seek the file header condition code of JPG file, seek in disk and have the sector of file header condition code, and the skew of recording this sector is the starting position; In concrete this step S110: search is with the sector of " ff d8 ff e0 ", " ff d8 ff e1 ", " ff d8 ff ed " or " ff d8 ff ff fe " beginning in disk.Except " ff d8 ff e000 10 41 56 49 31 ", this condition code is avi(Audio Video Interleaved, the Audio Video Interleaved form) key frame in file, rather than JPG file independently.
S120, seek backward the mark of JPG intermediate file compressed package, find the mark of described JPG intermediate file compressed package in described sector, the position of remembering the mark of this JPG intermediate file compressed package is current location, if the mark of this JPG intermediate file compressed package is 0xfff9, execution in step S140; Otherwise, read 16 integers (large end alignment) after the mark of this intermediate file compressed package, recording this round values is L; In the present embodiment, more specifically, the mark of described JPG intermediate file compressed package is at (0xffc0 ~ 0xffcf) and (16 integers (large end aligns) in the scope of 0xffda ~ 0xfffe).
S130, from the position of current location+L, the operation of repeated execution of steps S120;
The position of the current location of determining like this has a plurality of, namely repeats step S120 one time, and a new current location is just arranged again.
S140, determine that the data between described starting position and current location are the content of a complete JPG file, read and preserve the content of this JPG file to recover this JPG file.
In other embodiment, further, in above-mentioned steps S110, when the file header condition code of seeking the JPG file, when searching out the sector with " ff d8 ff e0 " beginning in disk, also comprise: judge the sector whether described disk starts with " ff d8 ff e0 00 10 41 56 49 31 "; When being judged as YES, continue execution in step S110; When being judged as NO, execution in step S120.
In the present embodiment, because it is a plurality of that the position of current location has, so the data between a plurality of described starting positions and current location are arranged, it is described JPG file that data between a described starting position and current location are wherein arranged, and can verify and determine that the data between which described starting position and current location are described JPG file according to the size of JPG file content.
The file that the method that the present embodiment provides undeletes according to the JPG file content, the JPG file content after recovery is identical with true JPG file content size, and highly versatile, can use and check this JPG file in various file system.
The present invention also provides a kind of system, is used for realizing the method that above-described embodiment provides, and as shown in Figure 2, this system comprises:
Condition code is sought unit 210, is used for seeking the file header condition code of JPG file, seek to have the sector of file header condition code in disk, and the skew of recording this sector is the starting position; More specifically, described condition code is sought the unit, is used in the sector of disk search with " ff d8 ff e0 ", " ff d8 ff e1 ", " ff d8 ff ed " or " ff d8 ff ff fe " beginning.
Mark is sought unit 220, is used for seeking backward the mark of JPG intermediate file compressed package; Find the mark of described JPG intermediate file compressed package in described sector, the position of remembering the mark of this JPG intermediate file compressed package is current location, if this mark is 0xfff9, the startup file recovery unit 240; Otherwise, read 16 integers (large end alignment) after the mark of this intermediate file compressed package, recording this round values is L; Wherein, more specifically, the mark of described JPG intermediate file compressed package is at (0xffc0 ~ 0xffcf) and (16 integers in the scope of 0xffda ~ 0xfffe)
Mark repetitive 230 is used for from the position of current location+L, starts mark and seeks unit 220;
File recovery unit 240 is used for determining that the data between described starting position and current location are the content of a complete JPG file, reads and preserve the content of this JPG file to recover this JPG file.
In other embodiment, further, as shown in Figure 3, described system also comprises condition code judging unit 250, be used for seeking the unit when disk searches sector with " ff d8 ff e0 " beginning when described condition code, judge the sector whether described disk starts with " ff d8 ff e0 00 10 41 56 49 31 "; When being judged as YES, triggering described condition code and seek unit 210 execution searching processes; When being judged as NO, triggering described mark and seek unit 220 execution searching processes.
The file that the method that the present embodiment provides undeletes according to the JPG file content, the JPG file content after recovery is identical with true JPG file content size, and highly versatile, can use and check this JPG file in various file system.
The above is only preferred embodiment of the present invention, not in order to limiting the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., within all should being included in protection scope of the present invention.