File name processing method and device, equipment and storage medium
By processing long file names in small memory devices and overwriting delimiter characters to store file extensions first, the problem of long file names in small memory devices being unable to be parsed and displayed is solved, ensuring the integrity and correctness of file name information.
Patent Information
- Application Number
- CN202410776278.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-10-15
AI Technical Summary
In small-memory embedded devices, due to memory space limitations, upper-layer applications cannot effectively obtain and display long file names, especially when the total file name length exceeds the byte space limit opened by the upper-layer application, resulting in long file names in the file system. Unable to parse and display correctly.
By reading the target file name from the first storage space of the file system and processing it in the second storage space of the upper-layer application, if it is full, the delimiter character will be overwritten to ensure the storage of file extension information, ensuring that the file main name and extension The integrity of the name information avoids the generation of short file names caused by insufficient memory.
Without expanding the memory size occupied by the upper-layer application for storing file name information, it is ensured that the upper-layer application can correctly identify the format of long file name files and obtain the original content of the file's main name to achieve effective acquisition and display of long file names.
Smart Images

Figure CN118779290A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of file information processing, and in particular, relates to a method, device, equipment and storage medium for processing file names. Background Art
[0002] The file system can support long file names, and a certain length of bytes needs to be allocated in the relevant structure in the device to store long file name information. For example, the existing FAT32 file system allocates up to 512 bytes and supports a maximum length of 255 characters for long file names.
[0003] At the same time, a larger byte space needs to be allocated for the upper-layer application in the device to store the long file name information, so that the long file name in the file system can be correctly read, parsed and displayed. However, in some small-memory embedded devices, due to the limitation of the device's own memory size, there is not enough memory space for the upper-layer application to allocate a larger byte space to store the long file name information.
[0004] In this way, if the file copied and stored by the user to a small memory embedded device is a long file name and the total length of the file name exceeds the byte space limit opened up by the upper-level application, the storage of the long file name is restricted, and the upper-level application will not be able to effectively obtain, parse and display the long file name in the file system. Summary of the invention
[0005] The embodiments of the present application provide a method, apparatus, device and storage medium for processing a file name to solve the problem in the prior art that when the total length of a file name exceeds the limit of the byte space opened up by an upper-layer application, the upper-layer application will be unable to effectively obtain, parse and display the long file name in the file system.
[0006] A first aspect of an embodiment of the present application provides a method for processing a file name, including:
[0007] Reading the target file name from the first storage space corresponding to the file system to obtain the current character to be determined; the target file name is used to store in the second storage space corresponding to the upper layer application;
[0008] In the case where the second storage space is full, if the current character to be determined is a separator character, the current character to be determined is stored in the target position in the second storage space overwritten;
[0009] The remaining characters to be identified and corresponding to the target file name subsequently read from the first storage space are sequentially stored in the storage position after the target position in the second storage space.
[0010] A second aspect of an embodiment of the present application provides a file name processing device, including:
[0011] A reading module is used to read the target file name from the first storage space corresponding to the file system to obtain the current character to be judged; the target file name is used to store in the second storage space corresponding to the upper layer application;
[0012] A storage module is used to, when the second storage space is full, overwrite and store the current character to be determined in the target position in the second storage space if the current character to be determined is a separator character; and overwrite and store the remaining characters to be determined corresponding to the target file name subsequently read from the first storage space in the storage position after the target position in the second storage space.
[0013] A third aspect of an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the computer program.
[0014] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0015] The fifth aspect of the present application provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code. When the computer-readable code is executed in an electronic device, the processor in the electronic device executes the steps in the method described in the first aspect above.
[0016] In the above scheme in the embodiment of the present application, when the name information byte data of the actual long file name is larger than the storage space used by the upper-layer application to store the long file name information, the memory size occupied by the upper-layer application for storing the file name information is not expanded. First, it is ensured that the file extension information is all written into the storage space corresponding to the upper-layer file, ensuring that the upper-layer application can correctly identify the file format of the long file name file and can obtain the original content of the file main name. The upper-layer application can still obtain the main information of the file name and can display the long file name related information to the user, ensuring that the upper-layer application can effectively obtain, parse and display the long file name in the file system, and meet the file name processing requirements under specific circumstances. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Moreover, the same reference numerals are used throughout the drawings to represent the same components. In the drawings:
[0018] Figure 1 This is the process of the file name processing method of some embodiments of the present application Figure 1 ;
[0019] Figure 2 This is the process of the file name processing method of some embodiments of the present application Figure 2 ;
[0020] Figure 3 is an example diagram of a long file name before processing in some embodiments of the present application;
[0021] Figure 4 is an example diagram of a file name directory entry in some embodiments of the present application;
[0022] Figure 5 is an example diagram of the final long file name after processing in some embodiments of the present application;
[0023] Figure 6 is a structural diagram of a file name processing device in some embodiments of the present application;
[0024] Figure 7 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The following embodiments of the technical solution of the present application are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application, and are therefore only used as examples, and cannot be used to limit the scope of protection of the present application.
[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned figure descriptions and any variations thereof are intended to cover non-exclusive inclusions.
[0027] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.
[0028] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0029] In the description of the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0030] Take the FAT32 file system as an example. In the FAT32 file system, the short file name naming rule is 8.3, where 8 refers to the file name and 3 refers to the extension. When the file name exceeds 8 bytes and the extension exceeds 3 bytes, the file name may become a long file name. The name characters of the long file name are encoded in unicode, and each character occupies 2 bytes, whether it is English, Chinese, numbers, or common characters that may appear in the name information (such as the extension separator ".").
[0031] The FAT32 file system source code supports long file names, and a maximum of 512 bytes are allocated in the relevant structure to store long file name information. Since unicode encoding is used and the final file name end information also occupies 2 bytes, the sum of the file name and extension of a long file name in the FAT32 file system is at most (512-2) / 2=255 characters, and the upper-level applications in the devices that run the file system by default also support long file names of 255 characters.
[0032] However, in some small memory embedded devices, due to the limitation of the device's own memory size, there is not enough memory space for the upper-level application to allocate 512 bytes to store the long file name extension information. Usually, only 256 bytes are allocated for the upper-level application to store the long file name information data.
[0033] In this case, if the file copied and stored in the embedded device storage medium is a long file name and the total length of the file name and extension exceeds the 256-byte limit of the upper-layer application, the upper-layer application will not be able to properly parse and display the file information.
[0034] In some methods, during the operation of reading the file name, once it is detected that the storage space provided to the upper-level application for storing the file name information is smaller than the actual required size, the reading of the long file name is immediately stopped, and the short file name information of the file is read and returned to the upper-level application instead.
[0035] In this case, since the short file name information is generated from the long file name information according to a certain algorithm, it cannot display the original file name information of the file. Moreover, some short file name information generated from the long file name is unicode encoded data that cannot be displayed. Therefore, the file name information read by the upper-level application under this processing mechanism may be invalid data information, and thus the relevant information of the file cannot be displayed to the user, and even file recognition may fail. The upper-level application will also be unable to parse and display the file information normally.
[0036] In the embodiment of the present application, the storage processing method of long file name data in the limited storage space corresponding to the upper-level application in the small memory device is changed, and the valid information of the long file name is stored in the limited storage space corresponding to the upper-level application in the form of the file name itself. This avoids the problem that when the upper-level application reads the long file name information, the file system returns a short file name to the application file due to insufficient memory used by the upper-level application to store the file name, and the short file name itself is sometimes non-displayable characters, resulting in the inability to display the file name information to the user. This ensures that the upper-level application can normally and effectively obtain, parse and display the long file name in the file system.
[0037] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.
[0038] Combination Figure 1 As shown, in some embodiments, a method for processing a file name is proposed, comprising:
[0039] Step 101, read the target file name from the first storage space corresponding to the file system to obtain the current character to be determined.
[0040] The target file name is used to store in the second storage space corresponding to the upper layer application.
[0041] The file system is, for example, the FAT32 file system. The file name includes the file name and the extension.
[0042] The target file name is a file name specified by the user. In some cases, the target file name is a long file name, and the length of the UTF-8 encoded data bytes formed after the long file name encoding conversion is greater than 256.
[0043] When reading the target file name from the first storage space corresponding to the file system, each time a character is read, the read character is used as the current character to be determined to perform information determination processing in subsequent steps to determine what kind of data processing is performed on the current character to be determined.
[0044] The file name processing method in the embodiment of the present application can be applied to small memory devices.
[0045] Small memory devices are, for example, small embedded devices, especially embedded devices that have insufficient memory but need to process files with longer file names, such as MP3.
[0046] The upper layer application in the small embedded device needs to read and parse the name information of some files with long file names from the FAT32 file system so as to normally identify, display and process the files with long file names on the device.
[0047] In one embodiment, step 101 reads the target file name from the first storage space corresponding to the file system, and before obtaining the current character to be determined, it also includes:
[0048] Based on the directory entry description information, determine multiple file name directory entries of the target file from the file directory structure of the file system;
[0049] The segment data of the target file name corresponding to the target file is read from the file name directory entry, and the segment data is sequentially stored in the first storage space.
[0050] In a specific implementation, the file system corresponds to a file directory structure, and based on the directory entry description information, the file name directory entry corresponding to the target file can be determined from the file directory structure, and then the target file name related data of the target file can be obtained.
[0051] Specifically, the FAT32 file system can utilize the function intpick_lfn to extract or select a long file name from a given directory structure and store it in a lfnbuf buffer, which is the first storage space corresponding to the file system.
[0052] In an example, the function structure is as follows:
[0053] intpick_lfn(WCHAR*lfnbuf,BYTE*dir);
[0054] Among them, the function of pick_lfn is to extract or select a long file name from the given dir directory structure and store it in the lfnbuf buffer. This function is a built-in function of the file system source code. It parses and reads the long file name related information of the target file from the file directory entry, and stores the long file name related information in the memory pointed to by lfnbuf. In the FAT32 file system, WCHAR*lfnbuf points to the 512-byte space opened up by the file system to store long file names. The long file name information is recorded in the directory entry. A long file name may occupy multiple directory entries. After all the file name directory entries corresponding to the target file are parsed, all the information of the long file name of the target file is stored in WCHAR*lfnbuf.
[0055] Step 102: When the second storage space is full, if the current character to be determined is a separator character, the current character to be determined is stored in a target position in the second storage space overwritten.
[0056] For files with file extensions, the file extensions usually follow the main file name and are separated by a separator "." In an optional implementation, when the current character to be determined is 0x002E, the current character to be determined is determined to be a separator character.
[0057] If the file has an extension, the information returned to the upper-layer application must include all the file extension information and cannot be deleted or omitted. Otherwise, the upper-layer application may directly filter out the entire file due to incorrect extension information when obtaining the long file information.
[0058] Since the actual long file name information size exceeds the memory size used by the upper-layer application to store the file name information, in this embodiment, the file name information stored in the storage space corresponding to the upper-layer application must be a deletion of the full file name, specifically the file main name in the file name needs to be deleted.
[0059] When the second storage space is full, it indicates that the storage space corresponding to the upper-layer application is insufficient. Whether the character to be judged is a separator character is judged, and the position of the separator character is determined. The data after the separator character appears may be the file extension information.
[0060] The separator character is stored in the second storage space in an overwritten manner, and data is stored in an overwritten manner starting from the separator, giving the file extension a higher storage priority to ensure that the file extension is effectively written when the storage space is full.
[0061] Specifically, when the separator character is stored in the second storage space in an overwritten manner, the overwritten content is the main name of the file stored in the second storage space before the separator.
[0062] In this way, the file main name in the long file name is partially overwritten, freeing up storage space for storing the file extension necessary for file identification, to ensure that when the file name is too long, the extension information in the long file name can be retained first, and the file main name information of the long file name is also partially retained in an appropriate manner, to ensure that the long file name is stored in the storage space corresponding to the upper-level application in an appropriate manner.
[0063] In one embodiment, when the characters to be identified are stored in the second storage space, they need to be converted into encoding before being stored. For example, the characters to be identified in the target file name are encoded in Unicode before conversion and become UTF-8 encoded data after conversion.
[0064] The character to be identified is currently stored in a target position in the second storage space, wherein the target position may be a starting position of a fixed-length storage space reserved in advance.
[0065] For example, a file extension generally does not exceed 4 characters, which is 8 bytes when converted into a 2-byte unicode code. Therefore, the file extension plus the separator "." takes up a maximum of 8+2=10 bytes. In this case, a storage space of 10 bytes can be reserved, and the starting position of the storage space is used as the target position to store the separator character.
[0066] Alternatively, a storage space of appropriate length may be determined based on the actual extension length of the file, and its starting position may be used as the target position to ensure processing flexibility.
[0067] Correspondingly, in a specific implementation process, the following steps are also included before step 102 to determine the target location:
[0068] Obtain the file format of the file to which the target file name belongs; determine the extension length of the target file name based on the file format; determine the target position starting from the last stored position of the characters in the second storage space and using the storage space length required for the extension length as an offset.
[0069] For example, the file format can be docx, avi, etc. The file format corresponds to the file extension. After determining the file format, the file extension length can be obtained, and the required storage space length can be determined. Therefore, when the second storage space is full, starting from the last stored position of the characters in the second storage space, the storage space position is pushed forward according to the storage space length required by the extension length to determine the target position.
[0070] Step 103: The remaining characters to be identified and corresponding to the target file name subsequently read from the first storage space are sequentially stored in the storage position after the target position in the second storage space.
[0071] Here, when it is determined in step 102 that the character to be determined read from the first storage space is a separator character, the remaining characters to be determined corresponding to the target file name subsequently read can be determined to be file extension characters, and these characters can be stored in the corresponding storage location in sequence.
[0072] In the implementation of the above steps, relevant processing logic can be added and modified in the processing function in the FAT32 file system source code, and the FAT32 file system returns the long file name information to the upper-level application through the interface in the source code. This can effectively avoid the situation where small embedded devices cannot normally read and parse the name information of some files with long file names due to insufficient memory, and then the device cannot normally identify and display the long file name information stored by the user.
[0073] In the processing process of the above method, when the name information byte data of the actual long file name is larger than the storage space used by the upper-level application to store the long file name information, the memory size occupied by the upper-level application for storing the file name information is not expanded. First, it is ensured that the file extension information is all written to the storage space corresponding to the upper-level file, and the upper-level application is ensured to correctly identify the file format of the long file name file and obtain the original content of the file main name. The upper-level application can still obtain the main information of the file name and can display the long file name related information to the user, ensuring that the upper-level application can effectively obtain, parse and display the long file name in the file system to meet the file name processing requirements under specific circumstances.
[0074] In some optional embodiments, in combination Figure 2 As shown, after the target file name is read from the first storage space corresponding to the file system in step 101 and the current character to be determined is obtained, the following steps are also included:
[0075] Step 201: when the second storage space is full, if the current character to be determined is not a separator character, the current character to be determined is discarded.
[0076] This step specifically occurs when the second storage space is full but the separator character has not been read from the first storage space corresponding to the file system. In this case, if the character to be determined currently read is not a separator character, it means that the character to be determined currently is not the main name character of the file, but the storage space is full, and the character to be determined currently needs to be discarded.
[0077] In this processing strategy, part of the content in the file's main name is discarded, so that most of the original content in the file's main name is retained, and the file's main name information of the long file name is partially retained in an appropriate manner without being compressed into a short file name, ensuring that the long file name is stored in the storage space corresponding to the upper-level application in an appropriate manner, ensuring that the upper-level application can effectively obtain, parse and display the long file name in the file system normally.
[0078] Optionally, after the target file name is read from the first storage space corresponding to the file system in step 101 to obtain the current character to be determined, the method further includes:
[0079] Step 202: When the second storage space is not full, store the character to be identified in the second storage space.
[0080] When the second storage space is not full, the current characters to be identified in the read target file name are directly stored in the second storage space to ensure the storage and processing of the normal file name.
[0081] Optionally, in step 202, after storing the character to be identified in the second storage space when the second storage space is not full, the method further includes:
[0082] Step 203, determining whether the data stored in the second storage space has reached a maximum value;
[0083] Step 204: If yes, then set the full flag of the second storage space.
[0084] Here, a method is provided for indicating that the second storage space is full. Specifically, a flag is set for the second storage space, and the flag is used to indicate whether the space is full. When the full flag is set, for example, its value is set to 1, it indicates that the second storage space is full, so as to realize the status marking of the storage space.
[0085] In an application, whether the second storage space is full can be determined by judging whether the full flag is set.
[0086] Optionally, after the target file name is read from the first storage space corresponding to the file system in step 101 to obtain the current character to be determined, the method further includes:
[0087] Step 205: If the current character value to be determined is 0, stop reading the target file name from the first storage space.
[0088] When the value of the current character to be determined read from the second storage space is 0, it is considered that the end information of the file name has been read, and the file name reading operation can be terminated at this time.
[0089] In one embodiment, the target file name data is read from the first storage space corresponding to the file system and returned to the upper layer application. The first storage space is the aforementioned WCHAR*lfnbuf. The specific implementation logic is as follows:
[0090] Execute the code statements and loop through them to determine whether the characters in the fs->lfnbuf[j] memory are 0. If not, it means that there are still unread characters in the file name. If it is 0, it means that the file name data has been read. At this time, set fno->fname[i] = 0 and the function ends.
[0091] The processed long file name is stored in fno->fname for use by upper-layer applications. This fname is the second storage space corresponding to the upper-layer application.
[0092] During the reading of the file name data, determine whether the full flag flag of the upper application's memory fno->fname[i] has been set. If it has been set, it means that the available memory in fno->fname is full. At this time, it is necessary to determine whether the value of fs->lfnbuf[j] is 0x002E. If fs->lfnbuf[j] == 0x002E, it means that fs->lfnbuf[j] at this time may be the file extension separator ".". This data and subsequent data need to be read and parsed and stored in fno->fname[i].
[0093] Among them, after the flag is set, the value can be set to 1, and the corresponding character processing operation needs to be performed according to whether fname has been filled and whether the current character to be judged fs->lfnbuf[j]! is a separator character.
[0094] Specifically, if flag == 1 and fs->lfnbuf[j]!= 0x002E, fs->lfnbuf[j] needs to be discarded, j++, and the next fs->lfnbuf[j] needs to be checked; if flag == 0, or flag == 1 && fs->lfnbuf[j] == 0x002E, the unicode characters in the memory of fs->lfnbuf[j] need to be converted to UTF-8 characters, and the converted UTF-8 characters are stored in fno->fname[i]. For each UTF-8 character stored, the value of count i is increased by 1 (i.e., i=i+1) and checked. Test whether the value of i after adding 1 is equal to the maximum available value _MAX_LFN of the fno->fname memory, that is, determine whether the second storage space is full. If the two are equal, it means that the fno->fname memory has been used up and the second storage space is full. You can set flag == 1 and set the value of i to i = i-10-1 (where 10 is the position offset of the storage space. On the basis of the variable i = i-1, add 10 storage positions to the offset. Here, 10 is subtracted because in one embodiment, the file extension plus the separator '.' is a maximum of 5 characters and occupies a total of 10 bytes).
[0095] The above-mentioned handling methods for each situation ensure the effectiveness and rationality of character reading and character processing of the file name. Even in a small memory device, the long file name can still be stored in the storage space corresponding to the upper-level application in an appropriate manner, ultimately ensuring that the upper-level application can effectively obtain, parse and display the long file name in the file system.
[0096] The implementation process and processing effect of the above file name processing method are described below with reference to a specific example.
[0097] First, format the FAT32 file system in the storage medium of the small memory embedded device.
[0098] Then, a song with a long file name is stored in the storage medium of the small memory embedded device as a test song, for example, in combination with Figure 3 As shown, the long file name of the test song is "1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test 1234567890 song name test.flac".
[0099] The song name has 150 Chinese characters, each character is encoded in 2 bytes, a total of 150*2=300 bytes, the song extension + separator is .flac, a total of 5 characters, 5*2=10 bytes, the entire song name information takes up 310 bytes. This length exceeds the maximum storage length of 256 bytes of long file names that can be supported on small embedded devices.
[0100] Corresponding to the FAT32 file system, the cluster where the root directory on the storage medium of the small memory embedded device is located stores directory item description information related to the test song, and the directory item description information includes addresses of different information directory items.
[0101] In one example, combining Figure 4 As shown, different information directory items include the long file name directory item and short file name directory item of the test song. The address 00072C8C0----00072CA30 describes the long file name directory item of the test song. The data in 00072C8C0----00072CA30 completely records the song's main name information + extension information; and 00072CA40----00072CA50 describes the short file name directory item of the song. The data in 00072CA40--00072CA50 mainly records the cluster address information of the song. Here, the short file information of the song is non-displayable characters (in most cases, characters generated by the long file name according to certain rules). According to the FAT32 long file name recording rules, the address items 00072C8C0----00072CA30 record a total of 12 file name directory items, each of which has a total of 10+12+4=26 bytes, a total of 12*26=312 bytes used to describe the song main name information + extension name information.
[0102] Before the file name processing method in the embodiment of the present application is implemented, the file system function reads and parses the long song name information in each file name directory item based on address 00072C8C0----00072CA30 (each file name directory item occupies 16 bytes), and converts the song name information into UTF-8 format data and returns it to the upper-level application interface. However, since the storage space opened up for the upper-level application can only store a maximum of 256 bytes of data, the long song name data here is larger than 256 bytes. The song name reading function of the file system directly abandons the reading of the long file name directory item, and instead reads the song information in the short file name directory item after the long file name directory item (address 00072CA40--00072CA50) and returns it to the upper-level application.
[0103] Since the song information in the short file name directory item here is non-displayable characters, the song name information obtained by the upper-level application will be non-displayable, and may even cause the application to be unable to recognize the file directly.
[0104] The file name processing method in the embodiment of the present application modifies the file name reading function processing logic in the file system, starts to read and parse the song name information in each long file name directory item based on the address item 00072C8C0----00072CA30 (each directory item occupies 16 bytes), and returns the song name information to the upper-level application interface after converting it into UTF-8 format data. After discovering that the 256-byte data used by the upper-level application to store the file name information has been filled, it will continue to read the long file name data information in the directory item, but the data information read at this time is no longer directly written into the memory of the upper-level application. Instead, it is determined whether the read data is the separator "." (0x002E) between the file name and the extension. If it is 0x002E, it means that the data currently read may be the separator data, and the data and the data read after this data are stored in the memory area of the upper-level application starting from the 10th byte from the end until the information of the long file name directory item is read.
[0105] In this way, the main information of the long file name finally stored in the memory area corresponding to the upper-level application includes the file main name information with some contents discarded and all the file extension information.
[0106] Combination Figure 5 As shown, the processed song name information is as follows:
[0107] "One two three four five six seven eight ninety song name test one two three four five six seven eight ninety song name test one two three four five six seven eight ninety song name test one two three four five six seven eight ninety song name test one two three four five six seven eight ninety song name test one two three four five six seven eight ninety song name test one two three.flac".
[0108] Here, the main song name + extension name + separator totals 128 characters and occupies 128*2=256 bytes. The processed data content contains the main information of the long file name, and can adapt to the 256-byte storage space opened up for the upper-level application. Finally, the song name information returned to the upper-level application can be successfully identified and displayed.
[0109] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0110] Based on the same inventive concept, the embodiment of the present application also provides a device for processing a file name. The device for processing a file name provided in the embodiment of the present application can implement each process of the embodiment of the method for processing a file name, and can achieve the same technical effect. Therefore, the specific limitations in the embodiments of one or more device for processing a file name provided below can refer to the limitations of the method for processing a file name above, and will not be repeated here to avoid repetition.
[0111] In this embodiment, the computing side can be divided into functional modules according to the above method. For example, each function can be divided into functional modules, or two or more functions can be integrated into one processing module.
[0112] See also Figure 6 , Figure 6 This is a structural diagram of a file name processing device provided in an embodiment of the present application. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0113] The file name processing device 600 includes:
[0114] The reading module 601 is used to read the target file name from the first storage space corresponding to the file system to obtain the current character to be determined; the target file name is used to store in the second storage space corresponding to the upper layer application;
[0115] Storage module 602 is used to, when the second storage space is full, overwrite and store the current character to be determined in the target position in the second storage space if the current character to be determined is a separator character; and overwrite and store the remaining characters to be determined corresponding to the target file name subsequently read from the first storage space in the storage position after the target position in the second storage space.
[0116] Optionally, the storage module 602 is further configured to:
[0117] Obtain the file format of the file to which the target file name belongs; determine the extension length of the target file name based on the file format; determine the target position starting from the last stored position of the characters in the second storage space and using the storage space length required for the extension length as an offset.
[0118] Optionally, the storage module 602 is further configured to:
[0119] Based on the directory entry description information, multiple file name directory entries of the target file are determined from the file directory structure of the file system; segment data of the target file name corresponding to the target file is read from the file name directory entry, and the segment data is stored in the first storage space in sequence.
[0120] Optionally, the storage module 602 is further configured to:
[0121] In the case where the second storage space is full, if the current character to be determined is not a separator character, the current character to be determined is discarded.
[0122] Optionally, the storage module 602 is further configured to:
[0123] When the second storage space is not full, the character to be identified is stored in the second storage space.
[0124] Optionally, the storage module 602 is further configured to:
[0125] Determine whether the data stored in the second storage space has reached a maximum value; if so, set a full flag of the second storage space.
[0126] Optionally, the storage module 602 is further configured to:
[0127] If the current character value to be determined is 0, then the reading of the target file name from the first storage space is stopped.
[0128] The above integrated modules can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0129] It should be noted that the relevant contents of each step involved in the above method embodiment can all be referred to the functional description of the corresponding functional module, which will not be repeated here.
[0130] Each module in the above-mentioned file name processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0131] In one embodiment, Figure 7 As shown, a computer device is provided. The computer device 7 of this embodiment includes: at least one processor 700 ( Figure 7 Only one is shown in the figure), a memory 701, and a computer program 702 stored in the memory 701 and executable on the at least one processor 700, wherein the processor 700 implements the steps of any of the above-mentioned method embodiments when executing the computer program 702.
[0132] The computer device 7 may be a computing device such as a desktop computer, a notebook, a palm computer, etc. The computer device 7 may include, but is not limited to, a processor 700 and a memory 701. Those skilled in the art will understand that Figure 7 It is only an example of computer device 7 and does not constitute a limitation of computer device 7. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the computer device may also include input and output devices, network access devices, buses, etc.
[0133] The processor 700 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0134] The memory 701 may be an internal storage unit of the computer device 7, such as a hard disk or memory of the computer device 7. The memory 701 may also be an external storage device of the computer device 7, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 7. Further, the memory 701 may also include both an internal storage unit and an external storage device of the computer device 7. The memory 701 is used to store the computer program and other programs and data required by the computer device. The memory 701 may also be used to temporarily store data that has been output or is to be output.
[0135] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0136] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0137] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0138] In the embodiments provided in the present application, it should be understood that the disclosed apparatus / computer equipment and methods can be implemented in other ways. For example, the apparatus / computer equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of the apparatus or unit, which can be electrical, mechanical or other forms.
[0139] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0140] In addition, each functional unit in each embodiment of the present application 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-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0141] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0142] The present application implements all or part of the processes in the above-mentioned embodiment methods, and may also be implemented through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0143] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for processing a file name, characterized in that: include: Read the target file name from the first storage space corresponding to the file system to obtain the current character to be judged; The target file name is used to store in the second storage space corresponding to the upper layer application; In the case where the second storage space is full, if the current character to be determined is a separator character, the current character to be determined is stored in the target position in the second storage space overwritten; The remaining characters to be identified and corresponding to the target file name subsequently read from the first storage space are sequentially stored in the storage position after the target position in the second storage space.
2. The method according to claim 1, characterized in that In the case that the second storage space is full, if the current character to be determined is a separator character, before the current character to be determined is stored in the target position in the second storage space, the method further includes: Get the file format of the file to which the target file name belongs; Determining the extension length of the target file name based on the file format; The target position is determined by taking the last stored position of the characters in the second storage space as the starting point and the storage space length required by the extension length as the offset.
3. The method according to claim 1, characterized in that Before the target file name is read from the first storage space corresponding to the file system to obtain the current character to be determined, the method further includes: Based on the directory entry description information, determining multiple file name directory entries of the target file from the file directory structure of the file system; The segment data of the target file name corresponding to the target file is read from the file name directory entry, and the segment data is sequentially stored in the first storage space.
4. The method according to any one of claims 1 to 3, characterized in that After reading the target file name from the first storage space corresponding to the file system and obtaining the current character to be identified, the method further includes: In the case that the second storage space is full, if the current character to be determined is not a separator character, the current character to be determined is discarded.
5. The method according to any one of claims 1 to 3, characterized in that After reading the target file name from the first storage space corresponding to the file system and obtaining the current character to be identified, the method further includes: When the second storage space is not full, the character to be identified is stored in the second storage space.
6. The method according to claim 5, characterized in that After storing the character to be identified in the second storage space when the second storage space is not full, the method further includes: determining whether the data stored in the second storage space has reached a maximum value; If so, the full flag of the second storage space is set.
7. The method according to any one of claims 1 to 3, characterized in that After reading the target file name from the first storage space corresponding to the file system and obtaining the current character to be identified, the method further includes: If the current character value to be determined is 0, then the reading of the target file name from the first storage space is stopped.
8. A file name processing device, characterized in that: include: A reading module is used to read the target file name from the first storage space corresponding to the file system to obtain the current character to be judged; The target file name is used to store in the second storage space corresponding to the upper layer application; A storage module is used to, when the second storage space is full, overwrite and store the current character to be determined in the target position in the second storage space if the current character to be determined is a separator character; and overwrite and store the remaining characters to be determined corresponding to the target file name subsequently read from the first storage space in the storage position after the target position in the second storage space.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
File appending write operation method and device based on FLASH memory
CN114089915A
Unit and method for acquiring file name, and program
JP2008250668A
