Disclosure of Invention
In view of the above, the present invention has been made to provide a method of accessing an external storage device that overcomes or at least partially solves the above-mentioned problems.
According to an aspect of the present invention, there is provided a method of accessing an external storage device, including:
acquiring parameter information of a node corresponding to an interface connected with external storage equipment;
matching a preset channel path corresponding to the node according to the parameter information, and mounting the external storage device on the channel path, wherein the channel path is communicated with the node and the terminal;
scanning files belonging to a preset category on the external storage device through the channel path, and determining file information and a file storage path of each file belonging to the preset category;
judging whether the mapping relation between the file information of each file belonging to the preset type and the file storage path is recorded in a database of the terminal;
if not, storing the mapping relation between the file information and the file storage path of the file into a corresponding mapping relation table in the database for the file of which the mapping relation between the file information and the file storage path is not recorded in the database;
and informing an application layer of the terminal that data updating exists in the database, and reading each file information of the preset type from the mapping relation table by an upper layer application and displaying the file information on an application interface of the upper layer application.
Optionally, the method further comprises:
and receiving the operation of the user on the files belonging to the preset type in the external storage equipment, and saving the operation record corresponding to the operation as data in file information in the mapping relation table between the file information corresponding to the file and the storage path.
Optionally, the operation record comprises at least one of: collecting and classifying;
the preset category includes at least one of: music, video, pictures, maps;
the file information includes at least one of: file type, file name, file size.
Optionally, when a storage path of a file belonging to a preset category in the external storage device is changed, a new storage path is updated into a mapping relationship between file information corresponding to the file and a file storage path in the mapping relationship table.
Optionally, the node is located on a HUB chip connected to the terminal, and the parameter information of any node on the HUB chip is generated according to the device model of the HUB chip and the number of nodes on the HUB chip.
According to another aspect of the present invention, there is also provided an electronic device, characterized by comprising a processor and a memory, wherein at least one instruction, at least one program, a set of codes, or a set of instructions is stored in the memory, and the at least one instruction, the at least one program, the set of codes, or the set of instructions is loaded and executed by the processor to implement the method according to any one of the above.
According to yet another aspect of the invention, there is also provided a computer storage medium having stored therein at least one instruction, at least one program, set of code or set of instructions to be loaded by a processor and to carry out a method according to any preceding claim.
In the scheme provided by the invention, after parameter information of a node corresponding to an interface connected with an external storage device is acquired, a preset channel path corresponding to the node is matched according to the parameter information and the external storage device is mounted on the channel path, so that files belonging to a preset type on the external storage device are scanned through the channel path, file information and a file storage path of each file belonging to the preset type are determined, whether the file information and the file storage path of each file belonging to the preset type are recorded in a database of a terminal is judged, if not, for files of which the file information and the file storage path are not recorded in the database, the mapping relation between the file information and the file storage path is stored in a corresponding mapping relation table in the database, and the application layer of the terminal is informed that data updating exists in the mapping relation table, and reading each file information of a preset category by the upper layer application and displaying the file information on an application interface of the upper layer application. Based on the scheme provided by the invention, the storage path is fixed, and the file information and the file storage path of the preset type of files in the external storage device are recorded in the mapping relation table of the database of the terminal, so that a user can perform various interactive operations, such as collection and classification, on the files in the external storage device, and more improvement is brought to the use of the user.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments thereof, taken in conjunction with the accompanying drawings.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
It should be noted that the technical features of the embodiments and alternative embodiments of the present invention may be combined with each other without conflict.
Fig. 1 is a flowchart illustrating a method of accessing an external storage device according to an embodiment of the present invention. As shown in fig. 1, the method for accessing an external storage device according to the present invention may include at least the following steps:
step S102: acquiring parameter information of a node corresponding to an interface connected with external storage equipment;
step S104: matching a preset channel path corresponding to the node according to the parameter information, and mounting an external storage device on the channel path, wherein the channel path is communicated with the node and the terminal;
step S106: scanning files belonging to a preset category on the external storage device through a channel path, and determining file information and a file storage path of each file belonging to the preset category;
step S108: judging whether the mapping relation between the file information of each file belonging to the preset type and the file storage path is recorded in a database of the terminal;
step S110: if not, storing the mapping relation between the file information and the file storage path of each file in a corresponding mapping relation table in the database for the files of which the mapping relation between the file information and the file storage path is not recorded in the database;
step S112: and informing the application layer database of the terminal of the existence of data updating, and reading each file information of a preset type from the mapping relation table by the upper layer application and displaying the file information on an application interface of the upper layer application.
The node in the above step S102 and step S104 is a node corresponding to an interface where the terminal is connected to the external storage device, the terminal may be directly connected to the external storage device through a USB interface thereon, or the terminal may be connected to an interface where the external storage device is connected through an interface on an external USB HUB, and the parameter information of the node may be determined according to information of the interface, such as an interface type and a protocol related to the interface.
After the external storage device is inserted into an interface on the HUB chip, a kernel (system bottom kernel) of the terminal recognizes and then throws a uevent (event) onto a hall (Hardware Abstraction Layer), obtains devpath (parameter information of a node) according to the uevent, matches a preset channel path corresponding to the node according to the parameter information of the node corresponding to the interface, the channel path communicates the node and the terminal, and files in the external storage device connected to the interface corresponding to the node can be scanned through the channel path.
Based on the scheme provided by the invention, the storage path is fixed, and the file information of the preset type of files in the external storage equipment and the mapping relation of the file storage path are recorded in the mapping relation table of the database of the terminal, so that a user can perform various interactive operations on the files in the external storage equipment, such as collection and classification, more improvement is brought to the use of the user, and the user experience is improved.
After the external storage device is mounted on the corresponding channel path in step S104, in step S106, the files belonging to the preset category on the external storage device are scanned through the channel path, and the file information and the file storage path of each file belonging to the preset category are determined.
In some embodiments of the invention, the predetermined category includes at least one of: music, video, pictures, maps. The file information includes at least one of: file type, file name, file size.
After determining the file information and the file storage path of each file belonging to the preset category, in step S108, it is determined whether the mapping relationship between the file information and the file storage path of each file belonging to the preset category is recorded in the database of the terminal.
If not, in step S110, for the files whose mapping relationship between the file information and the file storage path is not recorded in the database, the mapping relationship between the file information and the file storage path of each file is stored in the corresponding mapping relationship table in the database.
For example, the external storage device includes music "Jiangnan" whose storage path is "D: \ M: \ music", and after judging that the file information and the file storage path of the music "Jiangnan" are not stored in the database of the terminal, the mapping relationship between the file information and the file storage path of the music "Jiangnan" is stored in the corresponding mapping relationship table in the database of the terminal.
After the database is updated, in step S112, the application layer database of the terminal is notified that there is data update, and then the upper layer application reads information of each file in the preset category from the mapping relationship table and displays the information on the application interface.
The upper layer application may include at least one of a music player, a video player, a navigation application, and a picture browser. After the terminal database is updated, at least one application of the music player, the video player, the navigation application and the picture browser can read corresponding data from the mapping relation table and display the data on an application interface of the application. Such as music players reading music, video players reading video.
Fig. 2 is a flowchart illustrating a method of accessing an external storage device according to a preferred embodiment of the present invention. As shown in fig. 2, in a preferred embodiment of the present invention, after step S112, the method further includes:
step S114: receiving an operation of a user on a file belonging to a preset type in the external storage device, and storing an operation record corresponding to the operation as data in file information in a mapping relation table between the file information corresponding to the file and a file storage path.
Wherein, the operation record can comprise at least one of collection and classification. For example, when a user performs a collection operation on music "south of the river" in the external storage device, the corresponding collected operation record is stored as data of file information in the mapping relationship between the file information corresponding to the music "south of the river" and the file storage path in the mapping relationship table, so that when the user opens the music "south of the river" again from the external storage device, the application interface of the music player displays the operation record of "collection". The effect of recording the portable operation of the user is achieved.
In addition, when the storage path of the file belonging to the preset type in the external storage device is changed, the new storage path can be updated to the mapping relation between the file information corresponding to the file and the file storage path in the mapping relation table, so that the influence on the database reading performance due to more and more data in the database can be avoided.
According to another aspect of the present invention, there is also provided an electronic device comprising a processor and a memory, the memory having stored therein at least one instruction, at least one program, set of codes, or set of instructions, which is loaded and executed by the processor to implement the method according to any of the embodiments described above.
According to yet another aspect of the present invention, there is also provided a computer readable storage medium having stored therein at least one instruction, at least one program, set of code or set of instructions, which is loaded by a processor and which performs a method as described in any one of the above embodiments.
The invention provides a method for accessing an external storage device applied to a terminal, which is based on the scheme provided by the invention, the mapping relation between the file information of a preset type of files in the external storage device and the file storage path is recorded in the mapping relation table of a database of the terminal by fixing the storage path, so that a user can perform various interactive operations, such as collection and classification, on the files in the external storage device, and more improvement is brought to the use of the user; in addition, when the storage path of the file belonging to the preset type in the external storage device is changed, the new storage path can be updated to the mapping relation between the file information corresponding to the file and the file storage path in the mapping relation table, so that the influence on the database reading performance due to more and more data in the database can be avoided.
It is clear to those skilled in the art that the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and for the sake of brevity, further description is omitted here.
In addition, the functional units in the embodiments of the present invention may be physically independent of each other, two or more functional units may be integrated together, or all the functional units may be integrated in one processing unit. The integrated functional units may be implemented in the form of hardware, or in the form of software or firmware.
Those of ordinary skill in the art will understand that: the integrated functional units, if implemented in software and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computing device (e.g., a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention when the instructions are executed. And the aforementioned storage medium includes: u disk, removable hard disk, Read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disk, and other various media capable of storing program code.
Alternatively, all or part of the steps of implementing the foregoing method embodiments may be implemented by hardware (such as a computing device, e.g., a personal computer, a server, or a network device) associated with program instructions, which may be stored in a computer-readable storage medium, and when the program instructions are executed by a processor of the computing device, the computing device executes all or part of the steps of the method according to the embodiments of the present invention.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments can be modified or some or all of the technical features can be equivalently replaced within the spirit and principle of the present invention; such modifications or substitutions do not depart from the scope of the present invention.