CN102567325B - Method for analyzing file name of FAT(file allocation table)file system - Google Patents

Method for analyzing file name of FAT(file allocation table)file system Download PDF

Info

Publication number
CN102567325B
CN102567325B CN2010105875232A CN201010587523A CN102567325B CN 102567325 B CN102567325 B CN 102567325B CN 2010105875232 A CN2010105875232 A CN 2010105875232A CN 201010587523 A CN201010587523 A CN 201010587523A CN 102567325 B CN102567325 B CN 102567325B
Authority
CN
China
Prior art keywords
directory entry
filename
current
directory
short
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN2010105875232A
Other languages
Chinese (zh)
Other versions
CN102567325A (en
Inventor
蒋虎
张立新
褚剑波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CRM ICBG Wuxi Co Ltd
Original Assignee
Wuxi China Resources Semico Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuxi China Resources Semico Co Ltd filed Critical Wuxi China Resources Semico Co Ltd
Priority to CN2010105875232A priority Critical patent/CN102567325B/en
Publication of CN102567325A publication Critical patent/CN102567325A/en
Application granted granted Critical
Publication of CN102567325B publication Critical patent/CN102567325B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method for analyzing a file name of an FAT (file allocation table) file system. The method comprises the steps of: reading and storing a long file name of a file with the long file name in the FAT file system but not storing the variant name of the file with the long file name; reading and storing a short file name of a file with the short file name; intercepting a part of the long file name as the analyzed file name; and converting the code of the short file name into UNICODE code. The method for analyzing the file name of the FAT file system greatly reduces system resources, particularly the cost of storage space, therefore, the method is specifically applied to the system with limited resource, in particular the system with small storage space.

Description

A kind of method of resolving the filename of FAT file system
Technical field
The present invention relates to FAT (File Allocation Table, file allocation table) system, be specifically related to the analytic method of file allocation table system File name.
Background technology
At present, the FAT file system just is being widely used in the hyperdisk data space.For meeting the space management of different memory space ranges, Microsoft has defined FAT12, FAT16 and tri-kinds of file system of FAT32.The difference of these three kinds of file system is that in the FAT table, base unit is respectively 12bit, 16bit and 32bit.FAT file system use directory area (directory region) carrys out the fileinfo below storage directory.Size is that the directory entry (entry) of 32 bytes is in directory area, to be used for the base unit of organising data,
For the short filename file, the storage basic structure of its filename as shown in Figure 1.Each short filename file has a directory entry corresponding with it, in these directory entries, is storing the information such as data field starting cluster corresponding to filename, file extension, attribute, creation-time, date created, file or catalogue.From the structure of the directory entry of directory area, can find, the filename length of a directory entry storage is conditional, and name is the longest is 8 bytes, and extension name mostly is 3 bytes most.The filename of short filename file is stored with short directory entry shown in Figure 1, and it only has a short filename.
For the filename of long filenames file, a directory entry can't hold wherein all characters.Microsoft has defined the long directory entry (long directory entry) that is all 32 byte-sized, and concrete structure as shown in Figure 2.The storage of the filename of long filenames file, comprise storing one or more long directory entry (structure of each long directory entry as shown in Figure 2) and a directory entry that is used for storing the short filename (claiming again another name) generated by long filenames of long filenames.Therefore, the filename of long filenames file consists of a long filenames and a corresponding another name when storage.Long directory entry can not break away from short directory entry and individualism, otherwise invalid.Fig. 3 is the storage mode of the filename of a long filenames file.In Fig. 3, a short directory entry and several continuous long directory entry have formed the directory chain of this document name, and long directory entry always is close to short directory entry and is stored in the front of this short directory entry.If the length of long filenames (comprising extension name) is less than 13 characters, only needs a long directory entry, otherwise need a plurality of long directory entries.These long directory entries, from 1 open numbering, can know from Fig. 3, and the sequence number of long directory entry is less, from the short filename directory entry more close to, otherwise far away.In actual disk, be the long directory entry of first depositing last numbering, finally deposit sequence number and be 1 long directory entry, and then deposit corresponding short directory entry.By long directory entry, filename is the longest reaches 255 characters.It is pointed out that for the file by Chinese character configuration file name, even in filename, only have 1 Chinese character, this document name also needs with structure storage shown in Figure 3 when storage so.
Realize that embedded system is to the reading of FAT file system memory device File, the problem of at first facing is exactly will realize to the parsing of the filename of above-mentioned long filenames file with to the parsing of the filename of short filename file.The analytic method of tool representative surely belongs to the analytic method in the identifying code that Cypress company provides for the SL811H chip.The method is that the filename of long filenames file and the filename name of short essay spare file have been distributed respectively 256 bytes and 32 bytes of storage space, the directory area data are carried out to sequence analysis, when reading an effective long directory entry, calculate the serial number range of character in whole filename of the filename of storing in this long directory entry, and the filename of storing in will long directory entry stores in corresponding long filenames array variable into; When reading a short filename, this short filename is stored in corresponding short filename array, and the file sequence number counter is increased to 1; Continue to analyze next directory entry, until read last directory entry.
From top resolving, to be not difficult to find out, there is following some deficiency in the method:
1. said method has not only been preserved long filenames, and also short filename that this long filenames is corresponding is also preserved simultaneously.And when actual embedded system file reading, for the file of long filenames, people often are indifferent to its short filename information.Said method has increased the expense of system resource greatly in addition.
2. said method intactly reads out long filenames, if filename is long, can not show fully at the limited embedded device of some indication range (as LCD TV).
3.FAT the filename of storing in the long directory entry of long filenames in system adopts the UNICODE coding, the another name of storing in short directory entry adopts local coder; Short filename without long directory entry adopts the ASCII coding.Read simultaneously long filenames and short filename and need use three cover codings.
Summary of the invention
The technical problem to be solved in the present invention is prior art when resolving the filename of FAT file system, large to the expense of system resource, meets difficulty while being applied to the limited system of the system resource such as embedded system.
For solving the problems of the technologies described above, the invention provides a kind of method of filename of the FAT of parsing file system, read and preserve the long filenames of the long filenames file in described FAT file system, do not preserve the another name of long filenames file; Read and preserve the short filename of short filename file.
Further in order to reduce system resource overhead, before the ASCII coding that the short filename of described short filename file adopts, add 0x00 and be converted into the UNICODE coding.
Further in order to reduce system resource overhead, intercept the part of long filenames of described long filenames file as the title of described long filenames file.
The method of the long filenames of the described long filenames file of described intercepting comprises the steps:
Step 1, order read the directory entry of directory area;
Step 2, judge whether the current directory item is last directory entry, if it is finish, otherwise enter step 3;
Step 3, skip invalid directory entry;
Step 4, judgement current directory item are long directory entry or short directory entry, if current directory Xiang Weichang directory entry enters step 5, enter step 6 if the current directory item is short directory entry;
Step 5, provide a threshold value N, the sequence number M of the current long directory entry of judgement and the relation between threshold value N;
If M>N, do not preserve the filename character of storing in current long directory entry, go to step 1 and read next directory entry; If M≤N, preserve the filename character of storing in current long directory entry, and directory entry is set is masked as long directory entry, go to step 1 and read next directory entry; Wherein M, N are positive integer;
Step 6, comprise the steps:
A, judgement directory entry sign are long directory entry or short directory entry, if be masked as short directory entry, preserve the filename character of storing in current short directory entry; If be masked as long directory entry, do not preserve the filename character of storing in current short directory entry;
B, the directory entry sign is updated to short directory entry, and goes to step 1 and read next directory entry.
Wherein, the method that step 3 is skipped invalid directory entry employing is to judge whether the current directory item is invalid directory entry, if go to step 1 and read next directory entry; Otherwise, enter step 4.Judge that whether the current directory item is that the method for invalid directory entry comprises: whether first byte that judges the current directory item is 0xE5; If the current directory item is to be invalid directory entry; Otherwise the current directory item is not invalid directory entry.
As a kind of preferred mode, step 3 also comprises the directory entry of the filename of skipping the storage hidden file.The described directory entry of skipping the filename of storage hidden file comprises: judge whether the current directory item is the directory entry of the filename of storage hidden file, if go to step 1 and read next directory entry; Otherwise, enter step 4.Judge that whether the current directory item is that the method for directory entry of the filename of storage hidden file comprises: whether the 2nd (bit) judging the 12nd byte of current directory item is 1; If the storage of current directory item is the filename of hidden file; Otherwise what the current directory item was stored is not the filename of hidden file.
As a kind of preferred mode, step 3 also comprises skips storage volume target directory entry.The described storage volume target directory entry of skipping comprises: judge whether the current directory item is storage volume target directory entry, if go to step 1 and read next directory entry; Otherwise, enter step 4.Judge that whether the current directory item is that the method for storage volume target directory entry comprises: whether the 4th (bit) judging the 12nd byte of current directory item is 1; If the storage of current directory item is label; Otherwise what the current directory item was stored is not label.
Optionally, in step 4, judge that whether the current directory item is that the method for long directory entry comprises the 12nd byte of current directory item and 0x3F are carried out and operation; If result is 0x0F, current directory Xiang Weichang directory entry: otherwise the current directory item is not long directory entry.In step 4, judge that whether the current directory item is that the method for short directory entry is: the 12nd byte of current directory item and 0x1A are carried out and operation, if result is 0x10 or 0x00, the current directory item is short directory entry: otherwise the current directory item is not short directory entry.
Further, if in step 4, to carry out with the result of operation be 0x10 for the 12nd of the current directory item the byte and 0x1A, read so the suffix name of the file of storing in the current directory item, after being changed into to lowercase or capitalization, described suffix name compares with the extension name of appointment, if unequal, forward step 1 to and read next directory entry, otherwise enter step 6; If in step 4, the 12nd of the current directory item the byte and 0x1A carry out to be 0x00, to enter so step 6 with the result of operation.
As a kind of preferred mode, step 5 can replace with step 5 ': a threshold value P is provided, the judgement sequence number M of current long directory entry and the relation between threshold value P, P, M are positive integer; If M>[P/13]+1, do not preserve the filename character of storing in current long directory entry; If following steps are carried out in M≤[P/13]+1:
5.1 ', order reads the filename character of storing in the current directory item
5.2 ', judge whether current file name character is the ending of filename; If so, finish reading of current directory item, go to step 1 and read next directory entry; If not, carry out following steps: if K+13 (M-1)≤P preserves current file name character; If K+13 (M-1)>P, do not preserve current file name character, and finish reading of current directory item, go to step 1 and read next directory entry; K is the sequence number of current file name character in directory entry.
Optionally, the directory entry of long directory entry is masked as 1, and the directory entry of short directory entry is masked as 0.
Optionally, step 2 also comprises whether the quantity of documents that judgement is read exceeds specified quantity; If exceed finish, otherwise enter step 3.Further, a file sequence number parameter is set, the file read is numbered; Step 2 can read current file sequence number so, if current file sequence number is greater than designated value, finishes; If current file sequence number is less than or equal to designated value, enter step 3.Before in step 6, going to step 1, the current file sequence number read is increased to 1.
Optionally, in step 6, go to step 1 and preserve the attribute field except the filename character in current short directory entry before.
Technique effect of the present invention is only to preserve long filenames and short filename while resolving FAT file system File name, and does not preserve another name, has reduced the expense of system resource.The present invention further is converted to short filename the UNICODE coding that long filenames adopts, and has further reduced the expense of system resource.In addition, the part of parsing time intercepting long filenames is as the title of this document name.Can further reduce the expense of system resource (especially storage space) like this.
The accompanying drawing explanation
Fig. 1 is the structural representation of the short-and-medium directory entry of FAT file system;
Fig. 2 is the structural representation of long directory entry in the FAT file system;
Fig. 3 is the filename storage organization schematic diagram of long filenames file in the FAT file system;
Fig. 4 is the process flow diagram of filename analytic method embodiment provided by the invention.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, the present invention is described in further detail below in conjunction with accompanying drawing.
Limited for system resource, especially the idle less system of storage needs the utilization of special concern to system resource when design, reduces the expense to system resource as far as possible.For example embedded device (as LCDTV) reads the file in the memory devices (as USB Mass Storage) with the FAT file system.In the file reading process, while resolving long filenames and short filename, to reduce system resource, particularly the expense of storage space as far as possible.
As can be known by preamble, the filename of long filenames file consists of a long filenames and a corresponding short filename (claiming again another name) when storage.In the present invention, the short filename of long filenames file is called to another name, and is not referred to as short filename; By the file name of short filename file, be only short filename, in order to avoid the two is obscured.No matter be that the long directory entry of storage long filenames, the short directory entry of storage another name and the short directory entry of storage short filename are all the storage spaces of 32 bytes.Wherein the structure of the short directory entry of the short directory entry of storage another name and storage short filename is all structure shown in Figure 1, therefore all is referred to as short directory entry.
The method of the long and short filename of parsing provided by the invention, the long filenames that reads and preserve all long filenames files in the FAT file system, do not preserve the another name of all long filenames files.But preserve the short filename of short filename file.
Generally, people not quite are absorbed in the another name of long filenames file.Even use another name wherein, its range of application also is restricted.Because this another name is no more than 8 characters.In addition, long filenames adopts different codings in the FAT file system with another name.The former adopts the UNICODE coding; The latter adopts current system coding (or being called local coder), encodes as GB2312-80.Short filename adopts the ASCII coding.In some prior art, will call with short filename and all adopt the GB2312-80 coding.But because GB2312-80 coding is a kind of Variable Length Code, and a Chinese character means by two expansion ASCII character, when short filename adopts the GB2312-80 coding, its essence is and adopts ASCII to encode.After giving up another name, can reduce a set of system coding, and then reduce the resource overhead of system.
What simultaneously, short filename adopted is the ASCII coding.Before the ASCII coding, add 0x00 and just be easy to be converted into the UNICODE coding of 16.Therefore, after another name, then the ASCII coding that short filename adopts is converted into to the UNICODE coding, the filename finally obtained all adopts the UNICODE coding, has greatly reduced the expense of system resource.
For some long filenames, during parsing, can intercept the title of the part of this document name as this document name.Can further reduce the expense of system resource (especially storage space) like this.
As shown in Figure 4, the method comprises the steps: the method flow of the filename of parsing FAT file system provided by the invention
In step 1, embedded system, reading long filenames and short filename is that order reads directory entry in directory area, carries out following operation for the current directory item.
Step 2, judge whether the current directory item is last directory entry, if it is finish, otherwise enter step 3.
If first byte of current directory item is 0, this directory entry is last directory entry, now directly finishes to resolve.
If first byte of current directory item is not 0, this directory entry is not last directory entry, now just jumps to step 3.
Step 3, skip invalid directory entry.Judge whether the current directory item is invalid directory entry, if go to step 1 and read next directory entry; Otherwise, enter step 4.
Concrete grammar is: whether first byte that judges the current directory item is 0xE5; If first byte of current directory item is 0xE5, this directory entry is invalid directory entry.If the current directory item is invalid directory entry, enter step 1, do not read this directory entry, directly read next directory entry; Otherwise enter step 4.
For some unexpected directory entries, also can first skip in 3 o'clock in execution step.Unexpected directory entry comprises directory entry, the storage volume target directory entry of the filename of storing hidden file.
Filename for hidden file does not generally need to read out, and therefore can also skip the directory entry of the filename of storage hidden file.Judge whether the current directory item is the directory entry of the filename of storage hidden file, if go to step 1 and read next directory entry; Otherwise, enter step 4.
Concrete grammar is: whether the 2nd (bit) judging the 12nd byte of current directory item is 1; If the 2nd (bit) of the 12nd byte of current directory item is 1, this directory entry storage is the filename of hidden file.If the storage of current directory item is the filename of hidden file, do not read this directory entry, directly read next directory entry.To next directory entry execution step 1.
For label, generally do not need to read out yet, therefore can also skip storage volume target directory entry.Judge whether the current directory item is storage volume target directory entry, if go to step 1 and read next directory entry; Otherwise, enter step 4.
Concrete grammar is: whether the 4th (bit) judging the 12nd byte of current directory item is 1; If the 4th (bit) of the 12nd byte of current directory item is 1, this directory entry storage is label.If the storage of current directory item is label, do not read this directory entry, directly read next directory entry.To next directory entry execution step 1.
Step 4, judgement current directory item are long directory entry or short directory entry, if current directory Xiang Weichang directory entry enters step 5, enter step 6 if the current directory item is short directory entry.
Judge that whether the current directory item is that the method for long directory entry is:
The 12nd byte of current directory item and 0x3F are carried out and operation, if result is 0x0F, current directory Xiang Weichang directory entry.
Judge that whether the current directory item is that the method for short directory entry is:
The 12nd byte of current directory item and 0x1A are carried out and operation, if result is 0x10 or 0x00, the current directory item is short directory entry.If result is 0x10, the filename of current directory item storage is the filename of a file; If result is 0x00, the filename of current directory item storage is the filename of a file.
Step 5, provide a threshold value N (N is positive integer), the sequence number M (M is positive integer) of the current long directory entry of judgement and the relation between threshold value N.If M>N, do not preserve the filename character of storing in current long directory entry, directly read next directory entry.To next directory entry execution step 1.If M≤N, preserve the filename character of storing in current long directory entry, and directory entry is set is masked as long directory entry.Continue to read next directory entry, and to next directory entry execution step 1.As a kind of optimal way, the setting directory entry is masked as 1 and means that this directory entry is long directory entry; Directory entry is masked as 0, means that this directory entry is short directory entry.
With said method, intercept long filenames, because M is positive integer, the filename of preserving can only consist of the filename character be stored in the middle of integer long directory entry.Filename length after intercepting can not be numerical value arbitrarily, when practical application, is restricted.For example certain long filenames has 5 long directory entries, and N is made as 3 or 2 or 1.So, the filename length after intercepting is 39 or 26 or 13 characters, and can not intercepted length at the filename between 13 and 26, between 26 and 39.
For the filename length after the Set arbitrarily intercepting, enlarge the scope of practical application, the method for above-mentioned intercepting long filenames is improved.Step 5 replace with step 5 ': provide a threshold value P (P is positive integer), the judgement sequence number M (M is positive integer) of current long directory entry and the relation between threshold value P.If M>[P/13]+1, do not preserve the filename character of storing in current long directory entry; If following steps are carried out in M≤[P/13]+1:
5.1 ', order reads the filename character of storing in the current directory item;
5.2 ', judge whether current file name character is the ending (filename ends up with 0X00) of filename.If the ending of filename finishes reading of current directory item filename, continue to read next directory entry, and to next directory entry execution step 1; If not the ending of filename, if K+13 (M-1)≤P (K is the sequence number of current file name character in directory entry, any integer in the desirable 1-13 of K) preserves current file name character; If K+13 (M-1)>P, do not preserve current file name character, and finish reading of current directory item, continue to read next directory entry, and to next directory entry execution step 1.
Said method not only can read and preserve predetermined P the filename character needed owing to having obtained, the common filename formed after intercepting.Simultaneously, owing to having obtained the sequence number of last character of filename in whole filename, so can know the length of the filename that final intercepting obtains.
Step 6 comprises the steps:
A, judgement directory entry sign are long directory entry or short directory entry, if be masked as short directory entry, preserve the filename character of storing in current short directory entry; If be masked as long directory entry, do not preserve the filename character of storing in current short directory entry; After in this step, can first filename being converted to the UNICODE coding, preserve again.
As mentioned before, directory entry is masked as 1 and means that this directory entry is long directory entry; Directory entry is masked as 0, means that this directory entry is short directory entry.If the judgement directory entry is masked as 0, mean that the previous directory entry of this short directory entry of next-door neighbour is not long directory entry, preserve so the short filename in this short directory entry, and the directory entry that this document is set is masked as short directory entry, be 0.If the judgement directory entry is masked as 1, mean that the previous directory entry of this short directory entry of next-door neighbour is a long directory entry, do not preserve so the short filename of this short directory entry, simultaneously by directory entry sign clear 0.
After B, steps A have read current short directory entry, no matter whether preserve, all the directory entry sign will be updated to short directory entry, and go to step 1 and read next directory entry.No matter be long filenames file or short filename file, the storage of its filename has and only has a short directory entry, as long as read a short directory entry, just means to have resolved a filename.
As preferred embodiment a kind of, the present invention arranges a file sequence number parameter, and the file read is numbered.Step 6 increases 1 by the sequence number of the current file read after having read current short directory entry, and then forwards the analysis that step 1 continues next directory entry to.Now, step 2 can also judge whether the quantity of documents read exceeds specified quantity.If exceed finish, otherwise enter step 3.Specifically, step 2 first reads current file sequence number, if current file sequence number is greater than designated value, finishes; If current file sequence number is less than or equal to designated value, enter step 3.
Before in step 6, going to step 1, can also preserve the attribute field except filename character (short filename or another name) in short directory entry.
As preferred embodiment a kind of, the present invention can also only read the file (if only read the file of .mp3 or .jpg) of the extension name of several appointment.Between step 4 and step 6, add following steps: if the 12nd byte of current directory item and 0x1A carry out with the result of operation, be 0x10, the filename of current directory item storage is the filename of a file; Read so the suffix name (the 9th to the 11st byte data of directory entry) of the file of storing in the current directory item, after being changed into to lowercase or capitalization, this suffix name compares with the extension name of appointment, if unequal, forward step 1 to and continue reading of next directory entry, otherwise continue step 6.If in step 4, the 12nd of the current directory item the byte and 0x1A carry out to be 0x00, to enter so step 6 with the result of operation.
For example, if original 30 characters of filename, this document name is by 3 long directory entries and the directory chain storage that short directory entry forms so.According to the sequencing of storage, be followed successively by sequence number and be 3,2,1 long directory entry and the short directory entry adjacent with long directory entry 1.Wherein, long directory entry 3 has been stored 4 filename characters, and long directory entry 2 and 1 has all been stored 13 characters.During the system analysis filename, read successively long directory entry 3,2,1 and short directory entry.
If the filename of setting after intercepting is stored by 2 long directory entries, i.e. N=2.
For long directory entry 3, step 3 is judged as long directory entry so, and execution step 4 is not preserved the filename character of storage in long directory entry 3.For long directory entry 2, step 3 is judged as long directory entry, and execution step 4 is preserved the filename character of storage in long directory entry 2.For long directory entry 1, filename is wherein resolved identical with long directory entry 2.After often reading a long directory entry, the directory entry sign is set to 1.For short directory entry, step 3 is judged as short directory entry, then carry out step 5, preserves the attribute field except short filename or another name in short directory entry.Because directory entry is masked as 1, thus the short filename of this short directory entry do not preserved, then by directory entry sign clear 0.
Therefore, the file of final intercepting 26 characters by name.
If the filename of setting after intercepting is comprised of 20 characters, i.e. P=20, [P/13]+1=2.
For long directory entry 3, step 3 is judged as long directory entry so, execution step 4 ' and, do not preserve the filename character of storage in long directory entry 3.For long directory entry 2, step 3 is judged as long directory entry, execution step 4 ' and, preserve 1-7 filename character of storage in long directory entry 2.Last character is 20 in the sequence number of whole filename, so the length of the filename that final intercepting obtains is 20 characters.For long directory entry 1, wherein the filename character of storage all is saved.After often reading a long directory entry, the directory entry sign is set to 1.For short directory entry, step 3 is judged as short directory entry, then carry out step 5, preserves the attribute field except short filename or another name in short directory entry.Because directory entry is masked as 1, thus the short filename of this short directory entry do not preserved, then by directory entry sign clear 0.
Therefore, the file of final intercepting 20 characters by name.
Again for example, if original 17 characters of filename, this document name is by 2 long directory entries and the directory chain storage that short directory entry forms so.According to the sequencing of storage, be followed successively by sequence number and be 2,1 long directory entry and the short directory entry adjacent with long directory entry 1.Wherein, long directory entry 2 has been stored 4 filename characters, and long directory entry 1 has been stored 13 characters.During the system analysis filename, read successively long directory entry 2,1 and short directory entry.
If the filename of setting after intercepting is stored by 2 long directory entries, i.e. N=2.
For long directory entry 2, step 3 is judged as long directory entry, and execution step 4 is preserved the filename character of storage in long directory entry 2.For long directory entry 1, filename is wherein resolved identical with long directory entry 2.After often reading a long directory entry, the directory entry sign is set to 1.For short directory entry, step 3 is judged as short directory entry, then carry out step 5, preserves the attribute field except short filename or another name in short directory entry.Because directory entry is masked as 1, thus the short filename of this short directory entry do not preserved, then by directory entry sign clear 0.
Therefore, the file of final intercepting 17 characters by name, but system can not provide the filename length after parameter is pointed out this intercepting.
If the filename of setting after intercepting is comprised of 15 characters, i.e. P=15, [P/13]+1=2.
For long directory entry 2, step 3 is judged as long directory entry, execution step 4 ' and, preserve 1-2 filename character of storage in long directory entry 2.Last character is 15 in the sequence number of whole filename, so the length of the filename that final intercepting obtains is 15 characters.For long directory entry 1, wherein the filename character of storage all is saved.After often reading a long directory entry, the directory entry sign is set to 1.For short directory entry, step 3 is judged as short directory entry, then carry out step 5, preserves the attribute field except short filename or another name in short directory entry.Because directory entry is masked as 1, thus the short filename of this short directory entry do not preserved, then by directory entry sign clear 0.
Therefore, the file of final intercepting 15 characters by name, and system can provide parameter " 15 ", to point out the filename length after this intercepting.
In the situation that can also form without departing from the spirit and scope of the present invention many embodiment that very big difference is arranged.Should be appreciated that except as defined by the appended claims, the invention is not restricted at the specific embodiment described in instructions.

Claims (19)

1. a method of resolving the filename of FAT file system, is characterized in that, reads and preserve the long filenames of the long filenames file in described FAT file system, do not preserve the another name of long filenames file; Read and preserve the short filename of short filename file;
Intercept the part of long filenames of described long filenames file as the title of described long filenames file, comprise the steps:
Step 1, order read the directory entry of directory area;
Step 2, judge whether the current directory item is last directory entry, if it is finish, otherwise enter step 3;
Step 3, skip invalid directory entry;
Step 4, judgement current directory item are long directory entry or short directory entry, if current directory Xiang Weichang directory entry enters step 5, enter step 6 if the current directory item is short directory entry;
Step 5, provide a threshold value N, the sequence number M of the current long directory entry of judgement and the relation between threshold value N; If M > N, do not preserve the filename character of storing in current long directory entry, go to step 1 and read next directory entry; If M≤N, preserve the filename character of storing in current long directory entry, and directory entry is set is masked as long directory entry, go to step 1 and read next directory entry; Wherein M, N are positive integer;
Step 6, comprise the steps:
A, judgement directory entry sign are long directory entry or short directory entry, if be masked as short directory entry, preserve the filename character of storing in current short directory entry; If be masked as long directory entry, do not preserve the filename character of storing in current short directory entry;
B, the directory entry sign is updated to short directory entry, and goes to step 1 and read next directory entry.
2. the method for the filename of parsing according to claim 1 FAT file system, is characterized in that, before the ASCII coding that the short filename of described short filename file adopts, adds 0x00 and be converted into the UNICODE coding.
3. the method for the filename of parsing FAT file system according to claim 1, is characterized in that, step 3 comprises judging whether the current directory item is invalid directory entry, if go to step 1 and read next directory entry; Otherwise, enter step 4.
4. the method for the filename of parsing according to claim 3 FAT file system, is characterized in that, judge that whether the current directory item is that the method for invalid directory entry comprises: whether first byte that judges the current directory item is 0xE5; If the current directory item is to be invalid directory entry; Otherwise the current directory item is not invalid directory entry.
5. the method for the filename of parsing FAT file system according to claim 1, is characterized in that, step 3 also comprises the directory entry of the filename of skipping the storage hidden file.
6. the method for the filename of parsing according to claim 5 FAT file system, it is characterized in that, the described directory entry of skipping the filename of storage hidden file comprises: judge whether the current directory item is the directory entry of the filename of storage hidden file, if go to step 1 and read next directory entry; Otherwise, enter step 4.
7. the method for the filename of parsing according to claim 6 FAT file system, it is characterized in that, judge that whether the current directory item is that the method for directory entry of the filename of storage hidden file comprises: whether the 2nd (bit) judging the 12nd byte of current directory item is 1; If the storage of current directory item is the filename of hidden file; Otherwise what the current directory item was stored is not the filename of hidden file.
8. the method for the filename of parsing FAT file system according to claim 1, is characterized in that, step 3 also comprises skips storage volume target directory entry.
9. the method for the filename of parsing according to claim 8 FAT file system, it is characterized in that, the described storage volume target directory entry of skipping comprises: judge whether the current directory item is storage volume target directory entry, if go to step 1 and read next directory entry; Otherwise, enter step 4.
10. the method for the filename of parsing according to claim 9 FAT file system, it is characterized in that, judge that whether the current directory item is that the method for storage volume target directory entry comprises: whether the 4th (bit) judging the 12nd byte of current directory item is 1; If the storage of current directory item is label; Otherwise what the current directory item was stored is not label.
11. the method for the filename of parsing according to claim 1 FAT file system, is characterized in that, in step 4, judges that whether the current directory item is that the method for long directory entry comprises the 12nd byte of current directory item and 0x3F are carried out and operation; If result is 0x0F, current directory Xiang Weichang directory entry: otherwise the current directory item is not long directory entry.
12. the method for the filename of parsing FAT file system according to claim 1, it is characterized in that, in step 4, judge that whether the current directory item is that the method for short directory entry is: the 12nd byte of current directory item and 0x1A are carried out and operation, if result is 0x10 or 0x00, the current directory item is short directory entry; Otherwise the current directory item is not short directory entry.
13. the method for the filename of parsing according to claim 1 FAT file system, is characterized in that, in step 4, judges that whether the current directory item is that the method for short directory entry is: the 12nd byte of current directory item and 0x1A are carried out and operation,
If in step 4, to carry out with the result of operation be 0x10 for the 12nd of the current directory item the byte and 0x1A, read so the suffix name of the file of storing in the current directory item, after being changed into to lowercase or capitalization, described suffix name compares with the extension name of appointment, if unequal, forward step 1 to and read next directory entry, otherwise the current directory item is short directory entry, enters step 6;
If in step 4, to carry out with the result of operation be 0x00 for the 12nd of the current directory item the byte and 0x1A, the current directory item is short directory entry so, enters step 6;
If in step 4, to carry out with the result of operation be other numerical value for the 12nd of the current directory item the byte and 0x1A, the current directory item is not short directory entry.
14. the method for the filename of parsing FAT file system according to claim 1, is characterized in that, step 5 replaces with step 5': a threshold value P is provided, and the sequence number M of the current long directory entry of judgement and the relation between threshold value P, P, M are positive integer; If M > [P/13]+1, do not preserve the filename character of storing in current long directory entry; If following steps are carried out in M≤[P/13]+1:
5.1', order reads the filename character of storing in the current directory item;
5.2', judge whether current file name character is the ending of filename; If so, finish reading of current directory item, go to step 1 and read next directory entry; If not, carry out following steps: if K+13(M-1)≤P, preserve current file name character; If K+13(M-1) > P, do not preserve current file name character, and finish reading of current directory item, go to step 1 and read next directory entry; K is the sequence number of current file name character in directory entry.
15. the method for the filename of parsing FAT file system according to claim 1 is characterized in that the directory entry of long directory entry is masked as 1, the directory entry of short directory entry is masked as 0.
16. the method for the filename of parsing FAT file system according to claim 1 is characterized in that step 2 also comprises whether the quantity of documents that judgement is read exceeds specified quantity; If exceed finish, otherwise enter step 3.
17., according to the described method of resolving the filename of FAT file system of claim 1 or 16, it is characterized in that, a file sequence number parameter is set, the file read is numbered; Before in step 6, going to step 1, the current file sequence number read is increased to 1.
18. the method for the filename of parsing according to claim 17 FAT file system, is characterized in that, step 2 also comprises and reads current file sequence number, if current file sequence number is greater than designated value, finishes; If current file sequence number is less than or equal to designated value, enter step 3.
19. the method for the filename of parsing FAT file system according to claim 1, is characterized in that, in step 6, goes to step 1 and preserve the attribute field except the filename character in current short directory entry before.
CN2010105875232A 2010-12-14 2010-12-14 Method for analyzing file name of FAT(file allocation table)file system Active CN102567325B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2010105875232A CN102567325B (en) 2010-12-14 2010-12-14 Method for analyzing file name of FAT(file allocation table)file system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2010105875232A CN102567325B (en) 2010-12-14 2010-12-14 Method for analyzing file name of FAT(file allocation table)file system

Publications (2)

Publication Number Publication Date
CN102567325A CN102567325A (en) 2012-07-11
CN102567325B true CN102567325B (en) 2013-11-27

Family

ID=46412766

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2010105875232A Active CN102567325B (en) 2010-12-14 2010-12-14 Method for analyzing file name of FAT(file allocation table)file system

Country Status (1)

Country Link
CN (1) CN102567325B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108108376B (en) * 2016-11-25 2021-07-09 中标软件有限公司 Linear self-adaptive file name length scheduling system and method
CN107784119A (en) * 2017-11-16 2018-03-09 郑州云海信息技术有限公司 A kind of method that feature name number of words limits in solution SAP system
CN110750388B (en) * 2019-10-30 2022-06-17 苏州龙信信息科技有限公司 Backup analysis method, device, equipment and medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1477518A (en) * 2002-06-28 2004-02-25 System for handling file name of file system filter driver and its method
CN1928869A (en) * 2006-09-19 2007-03-14 珠海金山软件股份有限公司 Method for deleting files in FAT roll
CN101051319A (en) * 2007-05-11 2007-10-10 北京中星微电子有限公司 File name generating method and device in file distribution system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1477518A (en) * 2002-06-28 2004-02-25 System for handling file name of file system filter driver and its method
CN1928869A (en) * 2006-09-19 2007-03-14 珠海金山软件股份有限公司 Method for deleting files in FAT roll
CN101051319A (en) * 2007-05-11 2007-10-10 北京中星微电子有限公司 File name generating method and device in file distribution system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
解析FAT文件系统对长文件名的支持;陈代军;《成都信息工程学院学报》;20031230;第18卷(第04期);全文 *
陈代军.解析FAT文件系统对长文件名的支持.《成都信息工程学院学报》.2003,第18卷(第04期),

Also Published As

Publication number Publication date
CN102567325A (en) 2012-07-11

Similar Documents

Publication Publication Date Title
US7523140B2 (en) File system that manages files according to content
CN108052643B (en) Data storage method and device based on LSM Tree structure and storage engine
Wyss et al. Application of phylogenetic taxonomy to poorly resolved crown clades: a stem-modified node-based definition of Rodentia
CN110795499B (en) Cluster data synchronization method, device, equipment and storage medium based on big data
US20130276126A1 (en) Website scanning device and method
CN105677742A (en) Method and apparatus for storing files
WO2014159390A1 (en) Data storage volume having tiers of different storage traits
CN104462141A (en) Data storage and query method and system and storage engine device
US20180300250A1 (en) Method and apparatus for storing data
CN102567325B (en) Method for analyzing file name of FAT(file allocation table)file system
CN101571850A (en) Display packing and device of text document in support of page turn function
US20100251227A1 (en) Binary resource format and compiler
CN100472526C (en) Method for storing, fetching and indexing data
CN103581229A (en) Distributed file system, file access method and client terminal
CN104657513A (en) File operation and rapid retrieval method in embedded system
CN110347673A (en) Data file loading method, device, computer equipment and storage medium
CN105302660A (en) Distributed storage system-oriented erasure coding write buffer method with stream detection technology
CN103793468A (en) Data storage method and device and data reading method and device
CN106776617B (en) Log file saving method and device
CN103970605A (en) Low-performance terminal based data analysis method and device
CN103699699A (en) Method for browsing decoded ticket file
CN100397399C (en) Method and device for supporting multi-languages in FAT file system
CN111382120B (en) Small file management method, system and computer equipment
CN109189345B (en) Online data sorting method, device, equipment and storage medium
WO2015058628A1 (en) File access method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP03 Change of name, title or address

Address after: 214135 -6, Linghu Avenue, Wuxi Taihu international science and Technology Park, Wuxi, Jiangsu, China, 180

Patentee after: China Resources micro integrated circuit (Wuxi) Co., Ltd

Address before: 214061 Jiangsu city of Wuxi province Liangxi Road No. 14

Patentee before: WUXI CHINA RESOURCES SEMICO Co.,Ltd.

CP03 Change of name, title or address