A data reading method, apparatus, device, and storage medium

By storing the first occurrence of a scanned file type in the database in the data reading device and transferring it to the database when a preset number is reached, the problem of slow data reading speed in car entertainment systems is solved, achieving faster data reading and reducing system lag.

CN115658608BActive Publication Date: 2026-05-26CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
Filing Date
2022-09-29
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In existing technologies, car entertainment systems suffer from slow data reading speeds and system lag when reading media data from storage devices such as USB flash drives, especially when there is a large amount of data on the storage device. Restarting the device cannot fundamentally improve this problem.

Method used

After the data reading device is connected to the storage device, the system scans the files in the storage device and detects the file types. The first file to appear is stored in the database, and files that do not appear for the first time are stored in a preset set of files in memory. When a preset number of files are reached, they are transferred to the database. At the same time, a flag is added after the scan is completed to indicate that the scan is over, reducing the use of CPU and memory.

Benefits of technology

It improves data reading speed, reduces system lag, ensures smooth operation of CPU and memory, and enhances the immediacy of user operations and the efficiency of data reading.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115658608B_ABST
    Figure CN115658608B_ABST
Patent Text Reader

Abstract

This application relates to a data reading method, apparatus, device, and storage medium. The data reading method includes: after electrically connecting to a storage device, scanning multiple files in the storage device; detecting whether the file type of a scanned file is appearing for the first time; if so, storing the scanned file in a database; otherwise, storing the scanned file in a preset file set in memory; whenever the number of files in the preset file set reaches a preset number, transferring the files in the preset file set to the database and displaying a message indicating that the file list is pending update; after determining that the scanning of all files in the storage device is complete, adding a flag bit to the storage device, wherein the flag bit is used to indicate that the scan has ended. The data reading method provided in this application can improve the problem of slow data reading speed in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data reading and writing technology, and in particular to a data reading method, apparatus, device and storage medium. Background Technology

[0002] As automotive technology matures, cars are integrating more and more functions. For example, passengers can plug storage devices such as USB flash drives into the car's entertainment system, allowing the system to read media data from the USB drive and play audio.

[0003] However, when the USB drive contains a large amount of data, the car's entertainment system will take a long time to read the media data every time the USB drive is plugged in and unplugged, and may even experience system lag.

[0004] Restarting the car's entertainment system can alleviate the problem to some extent, but it cannot truly solve it. Therefore, existing technology suffers from slow data retrieval speeds. Summary of the Invention

[0005] Based on this, this application provides a data reading method, apparatus, device, and storage medium to improve the problem of slow data reading speed in the prior art.

[0006] In a first aspect, this application provides a data reading method, which includes: after electrically connecting to a storage device, scanning multiple files in the storage device; detecting whether the file type of the scanned file is appearing for the first time, and if so, storing the scanned file in a database; if not, storing the scanned file in a preset file set in memory; whenever the number of files in the preset file set reaches a preset number, transferring the files in the preset file set to the database and displaying a message indicating that the file list is to be updated; and after determining that the scanning of all files in the storage device is complete, adding a flag bit to the storage device, wherein the flag bit is used to indicate that the current scan has ended.

[0007] In conjunction with the first aspect, in the first possible implementation of the first aspect, after electrically connecting to the storage device and before the step of scanning multiple files in the storage device, the method further includes: detecting the historical scanning status of the storage device, and sequentially determining whether the storage device has been scanned, whether the previous scan has been completed, and whether the data has not been updated; if at least one of the detection results is negative, then the data in the database is cleared, and the step of scanning multiple files in the storage device is performed; if any one of the detection results is positive, then the data in the database is retained.

[0008] In conjunction with the first possible implementation of the first aspect, in the second possible implementation of the first aspect, the step of determining whether the storage device has been scanned includes: comparing the device information of the storage device with the device information list in the database, wherein the device information includes at least one of manufacturer identification, product identification, total capacity and used capacity; if the comparison result is consistent, it is determined that the storage device has been scanned; if the comparison result is inconsistent, it is determined that the storage device has not been scanned; after determining that the storage device has not been scanned, the method further includes: recording the device information of the storage device in the storage device information list in the database.

[0009] In conjunction with the first possible implementation of the first aspect, in the third possible implementation of the first aspect, the step of determining whether the storage device has completed the previous scan includes: reading a flag bit in the storage device; if the flag bit is not read, determining that the storage device has not completed the previous scan; if the flag bit is read, determining that the storage device has completed the previous scan.

[0010] In conjunction with the first possible implementation of the first aspect, in the fourth possible implementation of the first aspect, the step of determining whether the storage device has not updated data includes: traversing the file paths in the storage device to determine whether there are file paths in the storage device that are different from the database; if there are no different file paths, then determining that the storage device has not updated data; if there are different file paths, then determining that the storage device has updated data.

[0011] In conjunction with the first aspect, in the fifth possible implementation of the first aspect, during the process of scanning multiple files in the storage device, the method further includes: receiving an authorization instruction, wherein the authorization instruction is used to instruct data synchronization; creating a new thread, and, if a file is scanned, uploading the scanned file to the cloud through the newly created thread, so as to share the data in the storage device with other terminal devices.

[0012] In conjunction with the first aspect, in the sixth possible implementation of the first aspect, the step of scanning multiple files in the storage device includes: scanning data in the root directory of the storage device; if a file is scanned, performing a step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is scanned, adding the data in the folder to a first folder set; scanning the data in the first folder set; if a file is scanned, performing a step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is scanned, adding the data in the folder to a second folder set and clearing the data in the first folder set; scanning the data in the second folder set; if a file is scanned, performing a step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is scanned, adding the data in the folder to the first folder set and clearing the data in the second folder set; repeating the steps of scanning the data in the first folder set and scanning the data in the second folder set until no files or folders are scanned, and determining that the scanning of all files in the storage device is complete.

[0013] Secondly, this application provides a data reading device, comprising: a scanning unit for scanning multiple files in a storage device after being electrically connected to the storage device; a judging unit for detecting whether the file type of the scanned file is appearing for the first time; if so, storing the scanned file in a database; otherwise, storing the scanned file in a preset file set in memory; a transfer unit for transferring the files in the preset file set to the database whenever the number of files in the preset file set reaches a preset number, and displaying a message indicating that the file list is to be updated; and an adding unit for adding a flag bit to the storage device after determining that the scanning of all files in the storage device is complete, wherein the flag bit is used to indicate that the current scan has ended.

[0014] In conjunction with the second aspect, in the first possible implementation of the second aspect, the data reading device further includes a detection unit, which is used to: detect the historical scanning status of the storage device, and sequentially determine whether the storage device has been scanned, whether the previous scan has been completed, and whether the data has not been updated; if at least one of the determination results is negative, then the data in the database is cleared, and the step of scanning multiple files in the storage device is performed; if any one of the determination results is positive, then the data in the database is retained.

[0015] In conjunction with the first possible implementation of the second aspect, in the second possible implementation of the second aspect, the detection unit is specifically used to: compare the device information of the storage device with the device information list in the database, wherein the device information includes at least one of manufacturer identification, product identification, total capacity and used capacity; if the comparison result is consistent, it is determined that the storage device has been scanned; if the comparison result is inconsistent, it is determined that the storage device has not been scanned; after determining that the storage device has not been scanned, the method further includes: recording the device information of the storage device in the storage device information list in the database.

[0016] In conjunction with the first possible implementation of the second aspect, in the third possible implementation of the second aspect, the detection unit is specifically used to: read the flag bit in the storage device; if the flag bit is not read, determine that the storage device has not completed the previous scan; if the flag bit is read, determine that the storage device has completed the previous scan.

[0017] In conjunction with the first possible implementation of the second aspect, in the fourth possible implementation of the second aspect, the detection unit is specifically used to: traverse the file paths in the storage device to determine whether there are file paths in the storage device that are different from the database; if there are no different file paths, it is determined that the storage device has not updated the data; if there are different file paths, it is determined that the storage device has updated the data.

[0018] In conjunction with the second aspect, in the fifth possible implementation of the second aspect, the data reading device further includes a synchronization unit, which is used to: receive an authorization instruction, wherein the authorization instruction is used to instruct the synchronization of data; create a new thread, and, if a file is scanned, upload the scanned file to the cloud through the newly created thread, so as to share the data in the storage device with other terminal devices.

[0019] In conjunction with the second aspect, in the sixth possible implementation of the second aspect, the scanning unit is specifically used for: scanning data in the root directory of the storage device; if a file is scanned, performing a step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is scanned, adding the data in the folder to a first folder set; scanning the data in the first folder set; if a file is scanned, performing a step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is scanned, adding the data in the folder to a second folder set and clearing the data in the first folder set; scanning the data in the second folder set; if a file is scanned, performing a step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is scanned, adding the data in the folder to the first folder set and clearing the data in the second folder set; repeatedly performing the steps of scanning the data in the first folder set and scanning the data in the second folder set until no files or folders are scanned, and determining that the scanning of all files in the storage device is complete.

[0020] Thirdly, this application also provides a data reading device, which includes a processor and a memory connected via a bus; the processor is used to execute multiple instructions; the memory is used to store multiple instructions, which are adapted to be loaded by the processor and executed as a data reading method as described in the first aspect or any embodiment of the first aspect, so as to improve the problem of slow data reading speed in the prior art.

[0021] Fourthly, this application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading and execution by a processor of a data reading method as described in the first aspect or any embodiment of the first aspect, to improve the problem of slow data reading speed in the prior art.

[0022] In summary, this application provides a data reading method, apparatus, device, and storage medium. The data reading device, when scanning multiple files in a storage device, firstly, promptly stores the first file corresponding to each file type to a database, allowing users to operate on the files in the storage device immediately, thereby improving data reading speed. Secondly, by storing a preset number of files into the database after each preset number of files are read, the data reading device reduces the usage of the central processing unit (CPU) and memory during storage device scanning, keeping the CPU running smoothly, thus improving data reading speed. Therefore, the data reading method provided in this application can improve the problem of slow data reading speed in the prior art. Attached Figure Description

[0023] Figure 1 An application scenario diagram of the data reading method provided in one embodiment of this application;

[0024] Figure 2 A flowchart illustrating a data reading method in one embodiment of this application is provided.

[0025] Figure 3 A flowchart illustrating the data reading method in another embodiment provided in this application;

[0026] Figure 4 A schematic block diagram of a data reading device provided in this application;

[0027] Figure 5 A structural block diagram of a data reading device provided in this application. Detailed Implementation

[0028] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0029] Since the embodiments of this application involve a relatively large number of technical terms, for ease of understanding, the relevant terms and concepts that may be involved in the embodiments of this application will be introduced below.

[0030] 1. Storage devices

[0031] Storage devices are used to store information, typically by digitizing the information and then storing it using media such as electricity, magnetism, or optics. In this application, storage devices primarily refer to portable storage devices, such as Universal Serial Bus (USB) interface portable hard drives (USB flash drives), phase-change rewritable optical disk drives (PDs), and mobile hard disks. It should be noted that storage devices can be electrically connected to data reading devices by plugging them into the interface of the data reading device, allowing the data reading device to read files on the storage device, thereby achieving data transfer. Furthermore, for data transfer to occur, the interfaces of the storage device and the data reading device must adhere to the same communication protocol; for example, when the storage device is a USB flash drive, the USB flash drive can be plugged into the USB port of the data reading device.

[0032] 2. Equipment Information

[0033] Device information refers to information used to identify a device. When other devices obtain this device information, they can uniquely identify the corresponding device based on it. In this application, device information mainly refers to the identification information of the storage device, such as the vendor ID, product ID, total capacity, and used capacity. The vendor ID includes manufacturer information, place of origin information, and production date information; the product ID includes distributor information; total capacity refers to the total capacity of the product; and used capacity refers to the capacity already used by the product. It should be noted that after a data reading device is connected to a storage device, the vendor ID and product ID can be found in the storage device's driver's INF file or the registry.

[0034] It should be noted that the data reading devices and apparatuses involved in this application may include, but are not limited to, dedicated data reading devices, terminal devices, computers, processors, etc., and may be a device integrated into a vehicle or a detachable, independent device within a vehicle. The data reading devices and apparatuses can interact with cameras on the vehicle, for example, acquiring images captured by the camera, including those showing obstacles. The processor may include, but is not limited to, a central processing unit (CPU), a general-purpose processor, a coprocessor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The processor can implement the methods described in this application, such as scanning multiple files in a storage device, which will not be elaborated further in this application.

[0035] It should also be noted that the illustrations provided in this embodiment are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show components related to the present invention and are not drawn according to the actual number, shape, and size of the components in implementation. In actual implementation, the form, quantity, and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex. The structures, proportions, sizes, etc., shown in the accompanying drawings of this specification are only used to complement the content disclosed in the specification for those skilled in the art to understand and read, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modification to the structure, change in the proportional relationship, or adjustment of the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention. Furthermore, the orientations or positional relationships indicated by terms such as "upper," "lower," "left," "right," "middle," "longitudinal," "lateral," "horizontal," "inner," "outer," "radial," and "circumferential" used in this specification are based on the orientations or positional relationships shown in the accompanying drawings and are only for the purpose of simplifying the description. They do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Changes or adjustments to their relative relationships, without substantially altering the technical content, should also be considered within the scope of the present invention. Therefore, they should not be construed as limitations on the present invention. In addition, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0036] Currently, after data reading devices are electrically connected to storage devices, they often experience slow read speeds or even system freezes when reading data from the storage device. This problem is exacerbated, especially when there is a large amount of data on the storage device. While restarting the device can alleviate the problem to some extent, it does not truly solve it. Therefore, the existing technology suffers from slow data read speeds.

[0037] Research and analysis revealed that the slow data reading speed is due to the fact that the data reading process severely consumes the CPU and memory of the data reading device, resulting in a slower data reading speed. Therefore, restarting the device does not fundamentally improve the problem. To address this, this application provides a data reading method that improves the slow data reading speed by reducing the CPU and memory usage during the data reading process. Next, this application will combine... Figure 1 The application scenarios are described, and the data reading method proposed in this application is explained using a data reading device as the execution subject. Specifically:

[0038] After being electrically connected to storage device 120, data reading device 110 scans multiple files in storage device 120. During scanning, data reading device 110 first reads the file extension of the scanned files to determine the file type. For example, files with extensions such as mp3, wma, or flac are audio files; files with extensions such as jpeg, tif, or gif are image files; files with extensions such as wmv, mp4, or avi are video files; and files with extensions such as txt, doc, or pdf are text files.

[0039] After determining the file type, the data reading device 110 checks whether the file type is appearing for the first time. If so, it stores the file in the database, allowing the user to manipulate the data immediately. If not, it stores the scanned file in a preset file set in memory. This process continues until the number of files in the preset file set reaches a preset number. Then, the files in the preset file set are transferred to the database, and a message indicating that the file list needs updating is displayed. Transferring the files from the preset file set to the database involves two steps: first, storing the files in the preset file set in the database; and second, clearing the preset file set so that the data reading device 110 can continue to store subsequently read files in it. When the number of files in the preset file set reaches the preset number again, another transfer operation is performed until all files in the storage device 120 are stored in the database of the data reading device 110. At this point, the scanning of all files in the storage device 120 is considered complete. It should be noted that when the files on storage device 120 are scanned, regardless of whether the number of files in the preset file set is exactly the preset number or less, a transfer operation is performed to ensure that all files in storage device 120 are stored in the database without omission. This will not be elaborated further in this application. It should also be noted that "first appearance" refers to the first appearance during this data reading process.

[0040] After confirming the completion of scanning all files in storage device 120, data reading device 110 adds a flag bit to storage device 120. This flag bit indicates the end of the scan and can be a combination of one or more characters. To ensure that data reading device 110 can quickly retrieve this flag bit after the next electrical connection between storage device 120 and data reading device 110, the flag bit can be stored in the inf file of the storage device 120 driver or in the registry.

[0041] It should be noted that the database is stored in a non-memory storage medium, such as a hard drive, within the data reading device 110. The data reading device 110 stores scanned files in the database for two reasons: firstly, to promptly clear data and reduce CPU and memory usage; and secondly, to facilitate the data reading device 110's ability to retrieve data from the database at any time, avoiding the need to repeatedly read data from storage device 120 each time data is required.

[0042] In one embodiment, this application provides a data reading method, such as... Figure 2 As shown. Next, this application will describe the method provided in this embodiment using a data reading device as the execution subject. Specifically:

[0043] 201: After being electrically connected to the storage device, scan multiple files in the storage device.

[0044] The storage device can store multiple files and folders, and the file types include at least one of audio, image, video, and text. During scanning, the data reading device traverses and scans the files in the storage device, ensuring that no file in the root directory and subdirectories of the storage device is missed.

[0045] 202: Detect whether the file type of the scanned file is appearing for the first time. If so, store the scanned file in the database; otherwise, store the scanned file in a preset file set in memory.

[0046] In this process, when the data reading device scans files in the storage device, it first reads the file extension and determines the file type based on the extension. If the file type is encountered for the first time, the file is stored in the database; otherwise, it is stored in a preset file set in memory. Therefore, this application improves file reading speed and reduces lag by promptly storing the first file corresponding to each scanned file type in the database.

[0047] 203: Whenever the number of files in the preset file set reaches the preset number, the files in the preset file set are transferred to the database, and a message is displayed indicating that the file list needs to be updated.

[0048] The preset file set can be, for example, a file set named MediaList stored in memory. During the scanning process, if a file type is not encountered for the first time, it is stored in the database. This process continues until the number of files in the preset file set reaches a preset number. At this point, the preset file set is cleared, and a message indicating that the file list needs updating is displayed on the data reading device's screen. After clearing the preset file set, the scanned files are stored back into it. This process is repeated until all files on the storage device are stored in the database. Therefore, this solution, by performing a file transfer operation every time a preset number of files are scanned, maintains data update efficiency while reducing CPU and memory usage, resulting in a smoother system.

[0049] 204: After confirming that the scan of all files on the storage device is complete, add a flag bit to the storage device.

[0050] The flag bit is used to indicate the end of the current scan. After determining that the scan of all files on the storage device is complete, the data reading device adds a flag bit to the storage device. This allows the storage device to determine whether the scan process is complete the next time it is electrically connected to the data reading device. If it is complete, the next scan process can be simplified or even omitted to improve the data reading speed.

[0051] As mentioned above, to improve data reading speed, the data reading device adds a flag bit to the storage device after completing a scan. Based on this added flag bit, the data reading device can perform a more optimized scanning process the next time it reads a file from the storage device. Next, this application will describe this optimized scanning process in conjunction with several possible implementations. Specifically:

[0052] In one feasible embodiment, before the step of scanning multiple files in the storage device after electrical connection with the storage device, the method further includes: detecting the historical scanning status of the storage device, and sequentially determining whether the storage device has been scanned, whether the previous scan has been completed, and whether the data has not been updated; if at least one of the detection results is negative, then the data in the database is cleared, and the step of scanning multiple files in the storage device is performed; if any one of the detection results is positive, then the data in the database is retained.

[0053] In this implementation, before scanning files on the storage device, the data reading device sequentially determines whether the storage device has been scanned before, whether a previous scan has been completed, and whether data has not been updated. If all three determinations are true, the data in the database is retained, and the step of scanning files on the storage device is not performed. If at least one of the three determinations is false, the data in the database is cleared, and the step of scanning files on the storage device is performed. It is important to note that this implementation, by sequentially executing the determinations of whether the storage device has been scanned, whether a previous scan has been completed, and whether data has not been updated, is more efficient than executing them sequentially or in parallel. This is because, although all three determinations reflect the historical scanning status of the storage device, the degree of reflection differs, and the degree of reflection progresses sequentially. If a previous determination condition is not met, a subsequent determination condition will also not be met. Therefore, this application improves the efficiency of the determination by sequentially executing the above three determinations.

[0054] In one feasible approach, the step of determining whether a storage device has been scanned includes: comparing the device information of the storage device with a list of device information in a database, wherein the device information includes at least one of manufacturer identification, product identification, total capacity, and used capacity; if the comparison result is consistent, the storage device is determined to have been scanned; if the comparison result is inconsistent, the storage device is determined not to have been scanned; after determining that the storage device has not been scanned, the method further includes: recording the device information of the storage device in the list of storage device information in the database.

[0055] To quickly determine whether a storage device has been scanned, the data reading device can retrieve a list of device information from a database or the cloud. It then compares the storage device's information with multiple device information entries in this list. If a matching device is found, the storage device is considered scanned; otherwise, it is not. The device information is recorded in the database's storage device information list, and the device is then scanned again. It's important to note that the device information list stores information on at least one storage device that the data reading device has scanned.

[0056] In one feasible approach, the step of determining whether the storage device has completed the previous scan includes: reading a flag bit in the storage device; if the flag bit is not read, determining that the storage device has not completed the previous scan; if the flag bit is read, determining that the storage device has completed the previous scan.

[0057] In order to quickly determine whether the storage device has completed the previous scan, the data reading device can read the flag bit in the storage device. If the flag bit is not read, it is determined that the storage device has not completed the previous scan; if the flag bit is read, it is determined that the storage device has completed the previous scan.

[0058] In one feasible approach, the step of determining whether the storage device has not updated data includes: traversing the file paths in the storage device to determine whether there are file paths in the storage device that are different from the database; if there are no different file paths, then it is determined that the storage device has not updated data; if there are different file paths, then it is determined that the storage device has updated data.

[0059] In order to quickly determine whether the storage device has not updated the data, the data reading device can first traverse the file paths of each file in the storage device to see if the file paths of each file in the storage device are consistent with the file paths of the corresponding files in the database. If they are consistent, it is determined that the storage device has not updated the data; if they are not completely consistent, it is determined that the storage device has updated the data.

[0060] To further improve data reading efficiency, in one feasible approach, the data reading device uses a recursive traversal to scan the files in the storage device. Specifically, the steps for scanning multiple files in the storage device include: scanning the data in the root directory of the storage device; if a file is detected, performing a step to check whether the file type of the detected file is appearing for the first time; if a folder is detected, adding the data in the folder to a first folder set; scanning the data in the first folder set; if a file is detected, performing a step to check whether the file type of the detected file is appearing for the first time; if a folder is detected, adding the data in the folder to a second folder set and clearing the data in the first folder set; scanning the data in the second folder set; if a file is detected, performing a step to check whether the file type of the detected file is appearing for the first time; if a folder is detected, adding the data in the folder to the first folder set and clearing the data in the second folder set; repeating the steps of scanning the data in the first folder set and scanning the data in the second folder set until no more files or folders are detected, at which point the scanning of all files in the storage device is considered complete.

[0061] The first folder set can be named Folder01List, and the second folder set can be named Folder02List. The data reading device first scans the data in the root directory of the storage device. If a file is found, it determines whether to store the file in the database or a preset file set based on the file extension. If a folder is found, the data in the folder is stored in the first folder set, which means storing the data in the next level subdirectory of the root directory of the storage device in the first folder set. After scanning all files in the root directory of the storage device, the data in the first folder set is scanned. If a file is found, it determines whether to store the file in the database or a preset file set based on the file extension. If a folder is found, the data in the folder is stored in the second folder set, which means storing the data in the next level subdirectory of the root directory of the storage device in the second folder set. Then, the data in the second folder set is scanned, and the aforementioned scanning process is performed until all files in all levels of the storage device's directories have been scanned. Therefore, this application utilizes the first and second folder sets to sequentially store data in all levels of the storage device's directories, ensuring that all files in the storage device are scanned without omission.

[0062] It should be noted that this embodiment, in addition to ensuring no files are missed during scanning of the storage device, can further improve scanning efficiency. Practical application has shown that the recursive traversal method of this embodiment is more efficient than hierarchical traversal. Hierarchical traversal refers to scanning each item in the root directory of the storage device one by one. For example, if a folder is found in the root directory, after scanning all files in that folder, the next item in the root directory following that folder is scanned, and so on, until all items in the root directory have been scanned, thus completing the scan of all files on the storage device.

[0063] Furthermore, this application also provides an implementable method that can reduce repeated data readings and improve data security. Specifically, in the process of scanning multiple files in the storage device, the method further includes: receiving an authorization instruction, wherein the authorization instruction is used to instruct data synchronization; creating a new thread, and, if a file is scanned, uploading the scanned file to the cloud through the newly created thread, so as to share the data in the storage device with other terminal devices.

[0064] In this process, when the data reading device scans files in the storage device, if it receives an authorization instruction from the user, it establishes a new thread to upload the scanned files to the cloud. This new thread is independent of the scanning thread. Whenever a file is scanned, it is uploaded to the cloud via this new thread, allowing users to download the file using mobile devices or other terminal devices, thus enabling data sharing between the vehicle and the system.

[0065] In summary, this application provides a data reading method, apparatus, device, and storage medium. The data reading device, when scanning multiple files in a storage device, firstly, promptly stores the first file corresponding to each file type to a database, allowing users to immediately access the files in the storage device, thereby improving data reading speed. Secondly, by storing a preset number of files read into the database after each preset number of files are read, the data reading device reduces the CPU and memory usage during storage device scanning, ensuring smooth CPU operation and preventing lag, thus further improving data reading speed. Therefore, the data reading method provided in this application can improve the problem of slow data reading speed in existing technologies.

[0066] In another embodiment, to provide a detailed and complete description of the solution in this application, another data reading method is also provided, such as... Figure 3 As shown. Next, this application will describe the method provided in this embodiment using a data reading device as the execution subject, a USB flash drive as the storage device, a MediaList collection as the preset file collection, and 50 files as the preset number. Specifically:

[0067] 301: Electrically connected to a USB flash drive.

[0068] 302: How to determine if a USB drive has been scanned?

[0069] If yes, proceed to step 303; otherwise, proceed to step 306.

[0070] 303: Determine if the USB drive has completed the previous scan?

[0071] If yes, proceed to step 304; otherwise, proceed to step 306.

[0072] 304: How to determine if the USB drive has not been updated with data?

[0073] If yes, proceed to step 305; otherwise, proceed to step 306.

[0074] 305: Retain data from the database.

[0075] 306: Clear the data in the database.

[0076] 307: Recursively traverse multiple files in the USB drive and synchronize the scanned files to the cloud.

[0077] The recursive traversal method can be referred to in the previous embodiment, and will not be repeated here.

[0078] 308: Is the file type of the scanned file appearing for the first time?

[0079] If yes, proceed to step 309; otherwise, proceed to step 310.

[0080] 309: Store the scanned files in the database.

[0081] 310: Store the scanned files in a MediaList collection in memory.

[0082] 311: Whenever the number of files in the MediaList collection reaches 50, transfer the files in the MediaList collection to the database and display a message indicating that the file list needs to be updated.

[0083] 312: After completing the scan of all files on the USB drive, add a flag bit to the USB drive.

[0084] In summary, after electrically connecting to the USB flash drive, this embodiment determines whether a scan is needed by sequentially checking whether the USB flash drive has been scanned before, whether a previous scan has been completed, and whether data has not been updated. If the USB flash drive has been scanned before, a previous scan has been completed, and data has not been updated, then no further scanning is needed, as the database already stores the data for the USB flash drive. Otherwise, the data in the database is cleared, and the USB flash drive is scanned recursively, while simultaneously synchronizing the scanned files to the cloud, until all files on the USB flash drive have been scanned. Therefore, this embodiment provides a more detailed implementation method based on the previous embodiment, further improving the data reading speed.

[0085] In another embodiment, the present invention also provides a data reading device, see [link to previous embodiment]. Figure 4 The embodiments of the present invention can divide the device into functional units according to the above method examples. For example, each function can be divided into separate functional units, or two or more functions can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. It should be noted that the unit division in the embodiments of the present invention is illustrative and only represents one logical functional division; other division methods may be used in actual implementation. Figure 4As shown, the data reading device includes a scanning unit 410, a judging unit 420, a transfer unit 430, and an adding unit 440. Specifically: the scanning unit 410 is used to scan multiple files in the storage device after being electrically connected to the storage device; the judging unit 420 is used to detect whether the file type of the scanned file is appearing for the first time. If so, the scanned file is stored in the database; otherwise, the scanned file is stored in a preset file set in memory; the transfer unit 430 is used to transfer the files in the preset file set to the database whenever the number of files in the preset file set reaches a preset number, and prompts a message that the file list is to be updated; the adding unit 440 is used to add a flag bit in the storage device after determining that the scanning of all files in the storage device is complete, wherein the flag bit is used to indicate that the current scan is over.

[0086] In one possible implementation, the data reading device further includes a detection unit 450, which is used to: detect the historical scanning status of the storage device, and sequentially determine whether the storage device has been scanned, whether the previous scan has been completed, and whether the data has not been updated; if at least one of the determination results is negative, then the data in the database is cleared, and the step of scanning multiple files in the storage device is performed; if any one of the determination results is positive, then the data in the database is retained.

[0087] In one possible implementation, the detection unit 450 is specifically used to: compare the device information of the storage device with the device information list in the database, wherein the device information includes at least one of manufacturer identification, product identification, total capacity and used capacity; if the comparison result is consistent, it is determined that the storage device has been scanned; if the comparison result is inconsistent, it is determined that the storage device has not been scanned; after determining that the storage device has not been scanned, the method further includes: recording the device information of the storage device in the storage device information list in the database.

[0088] In one possible implementation, the detection unit 450 is specifically used to: read a flag bit in the storage device; if the flag bit is not read, determine that the storage device has not completed the previous scan; if the flag bit is read, determine that the storage device has completed the previous scan.

[0089] In one possible implementation, the detection unit 450 is specifically used to: traverse the file paths in the storage device to determine whether there are file paths in the storage device that are different from the database; if there are no different file paths, it is determined that the storage device has not updated the data; if there are different file paths, it is determined that the storage device has updated the data.

[0090] In one possible implementation, the data reading device further includes a synchronization unit 460, which is configured to: receive an authorization instruction, wherein the authorization instruction is used to indicate data synchronization; create a new thread, and, if a file is scanned, upload the scanned file to the cloud through the newly created thread, so as to share the data in the storage device with other terminal devices.

[0091] In one possible implementation, the scanning unit 410 is specifically used for: scanning data in the root directory of the storage device; if a file is scanned, performing a step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is scanned, adding the data in the folder to a first folder set; scanning the data in the first folder set; if a file is scanned, performing a step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is scanned, adding the data in the folder to a second folder set and clearing the data in the first folder set; scanning the data in the second folder set; if a file is scanned, performing a step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is scanned, adding the data in the folder to the first folder set and clearing the data in the second folder set; repeatedly performing the steps of scanning the data in the first folder set and scanning the data in the second folder set until no files or folders are scanned, and then determining that the scanning of all files in the storage device is complete.

[0092] In another embodiment, this application also provides a data reading device, see [link to relevant documentation]. Figure 5 The data reading device can be, but is not limited to, various personal computers, laptops, smartphones, tablets, portable wearable devices, and servers. The server can be a standalone server or a server cluster consisting of multiple servers. As shown in the figure, the data reading device in this embodiment may include a processor 510 and a memory 520. The processor 510 and the memory 520 are connected via a link 530. The processor 510 is used to execute multiple instructions; the memory 520 is used to store multiple instructions adapted to be loaded by the processor 510 and executed as described in the above embodiment.

[0093] The processor 510 can be an Electronic Control Unit (ECU), a Central Processing Unit (CPU), a general-purpose processor, a coprocessor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The processor 510 can also be a combination that implements computational functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc. In this embodiment, the processor 510 can be a microcontroller. By programming the microcontroller, various control functions can be implemented, such as scanning multiple files in the storage device in this embodiment. The processor has the advantages of powerful computing capabilities and fast processing speed. Specifically: the processor 510 is used to execute the function of the scanning unit 410, which is used to scan multiple files in the storage device after being electrically connected to the storage device; it is also used to execute the function of the judgment unit 420, which is used to detect whether the file type of the scanned file is appearing for the first time. If so, the scanned file is stored in the database; if not, the scanned file is stored in a preset file set in memory; it is also used to execute the function of the transfer unit 430, which is used to transfer the files in the preset file set to the database whenever the number of files in the preset file set reaches a preset number, and prompts a message that the file list is to be updated; it is also used to execute the function of the adding unit 440, which is used to add a flag bit in the storage device after determining that the scanning of all files in the storage device is completed, wherein the flag bit is used to indicate that the current scan is over.

[0094] In one possible implementation, the processor 510 is further configured to perform the function of the detection unit 450, which is configured to: detect the historical scanning status of the storage device, and sequentially determine whether the storage device has been scanned, whether the previous scan has been completed, and whether the data has not been updated; if at least one of the determination results is negative, then clear the data in the database and perform the step of scanning multiple files in the storage device; if any one of the determination results is positive, then retain the data in the database.

[0095] In one possible implementation, the processor 510 is specifically used to: compare the device information of the storage device with a list of device information in a database, wherein the device information includes at least one of manufacturer identification, product identification, total capacity, and used capacity; if the comparison result is consistent, it is determined that the storage device has been scanned; if the comparison result is inconsistent, it is determined that the storage device has not been scanned; after determining that the storage device has not been scanned, the method further includes: recording the device information of the storage device in the list of storage device information in the database.

[0096] In one possible implementation, the processor 510 is specifically configured to: read a flag bit in the storage device; if the flag bit is not read, determine that the storage device has not completed the previous scan; if the flag bit is read, determine that the storage device has completed the previous scan.

[0097] In one possible implementation, the processor 510 is specifically used to: traverse the file paths in the storage device to determine whether there are file paths in the storage device that are different from the database; if there are no different file paths, it is determined that the storage device has not updated the data; if there are different file paths, it is determined that the storage device has updated the data.

[0098] In one possible implementation, the processor 510 is further configured to perform the functions of the synchronization unit 460, including: receiving an authorization instruction, wherein the authorization instruction is used to indicate synchronization data; creating a new thread, and, if a file is scanned, uploading the scanned file to the cloud through the newly created thread to share the data in the storage device with other terminal devices.

[0099] In one possible implementation, the processor 510 is specifically configured to: scan data in the root directory of the storage device; if a file is detected, perform a step of detecting whether the file type of the detected file is appearing for the first time; if a folder is detected, add the data in the folder to a first folder set; scan the data in the first folder set; if a file is detected, perform a step of detecting whether the file type of the detected file is appearing for the first time; if a folder is detected, add the data in the folder to a second folder set and clear the data in the first folder set; scan the data in the second folder set; if a file is detected, perform a step of detecting whether the file type of the detected file is appearing for the first time; if a folder is detected, add the data in the folder to the first folder set and clear the data in the second folder set; repeat the steps of scanning the data in the first folder set and scanning the data in the second folder set until no files or folders are detected, and then determine that the scanning of all files in the storage device is complete.

[0100] In one possible implementation, this application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor and executing the methods in any of the foregoing embodiments. A processor 510 is configured to execute the plurality of instructions; a memory 520 is configured to store the plurality of instructions adapted for loading by the processor 510 and executing the data reading method as described in the above embodiments.

[0101] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0102] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A data reading method, characterized in that, include: After being electrically connected to the storage device, multiple files in the storage device are scanned; The system checks whether the file type of the scanned file is appearing for the first time. If so, the scanned file is stored in the database. If not, the scanned files are stored in a preset file set in memory; Whenever the number of files in the preset file set reaches a preset number, the files in the preset file set are transferred to the database, and the preset file set and the message indicating that the file list is pending update are cleared; After confirming that the scan of all files in the storage device is complete, a flag bit is added to the storage device to indicate that the scan is finished.

2. The method according to claim 1, characterized in that, After electrically connecting to the storage device and before the step of scanning multiple files in the storage device, the method further includes: The historical scanning status of the storage device is detected, and it is determined in turn whether the storage device has been scanned, whether the previous scan has been completed, and whether the data has not been updated. If at least one of the detection results is negative, then the data in the database is cleared, and the step of scanning multiple files in the storage device is performed. If any of the judgment results in the detection are yes, then the data in the database is retained.

3. The method according to claim 2, characterized in that, The step of determining whether the storage device has been scanned includes: The device information of the storage device is compared with the device information list in the database, wherein the device information includes at least one of the following: manufacturer identifier, product identifier, total capacity, and used capacity; If the comparison results are consistent, it is determined that the storage device has been scanned; If the comparison results are inconsistent, it is determined that the storage device has not been scanned; After determining that the storage device has not been scanned, the method further includes: recording the device information of the storage device in the storage device information list of the database.

4. The method according to claim 2, characterized in that, The step of determining whether the storage device has completed the previous scan includes: Read the flag bits from the storage device; If the flag bit is not read, it is determined that the storage device has not completed the previous scan; If the flag bit is read, it is determined that the storage device has completed the previous scan.

5. The method according to claim 2, characterized in that, The step of determining whether the storage device has not updated the data includes: The file paths in the storage device are traversed to determine whether there are any file paths in the storage device that are different from the database. If no different file paths exist, it is determined that the storage device has not updated the data; If different file paths exist, it is determined that the storage device has updated the data.

6. The method according to claim 1, characterized in that, During the process of scanning multiple files in the storage device, the method further includes: An authorization instruction is received, wherein the authorization instruction is used to instruct the synchronization of data; A new thread is created, and if a file is detected, the detected file is uploaded to the cloud through the newly created thread to share the data in the storage device with other terminal devices.

7. The method according to claim 1, characterized in that, The step of scanning multiple files in the storage device includes: Scan the data in the root directory of the storage device; if a file is found, perform the step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is found, add the data in the folder to the first folder set. Scan the data in the first folder set; if a file is found, perform the step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is found, add the data in the folder to the second folder set and clear the data in the first folder set. Scan the data in the second folder set; if a file is found, perform the step of detecting whether the file type of the scanned file is appearing for the first time; if a folder is found, add the data in the folder to the first folder set and clear the data in the second folder set. Repeat the steps of scanning the data in the first folder set and scanning the data in the second folder set until no files or folders are found, then determine that the scanning of all files in the storage device is complete.

8. A data reading device, characterized in that, include: A scanning unit is used to scan multiple files in the storage device after being electrically connected to the storage device; The judgment unit is used to detect whether the file type of the scanned file is appearing for the first time. If so, the scanned file is stored in the database. If not, the scanned files are stored in a preset file set in memory; The transfer unit is used to transfer the files in the preset file set to the database whenever the number of files in the preset file set reaches a preset number, and to clear the preset file set and the message indicating that the file list is pending update; An adding unit is configured to add a flag bit to the storage device after determining that the scanning of all files in the storage device is complete, wherein the flag bit is used to indicate that the current scan has ended.

9. A data reading device, characterized in that, The device includes a processor and a memory connected via a bus; the processor is used to execute multiple instructions; the memory is used to store the multiple instructions, which are adapted to be loaded by the processor and executed using the data reading method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor and executing the data reading method as described in any one of claims 1-7.