File management method and device and storage medium
By updating MTP management information to move files or folders, the problem of low movement efficiency in the prior art is solved, efficient file movement is achieved, and the flexibility of movement is improved.
Patent Information
- Application Number
- CN202510186605.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-19
- Publication Date
- 2025-06-06
Smart Images

Figure CN120104575A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a file management method, device and storage medium. Background Art
[0002] The host computer and the electronic device are connected through a Universal Serial Bus (USB) interface, and both the host computer and the electronic device support the Media Transfer Protocol (MTP). Based on the MTP protocol, the host computer can access files stored in the electronic device.
[0003] In some scenarios, it involves moving files or folders in an electronic device through a host computer. Specifically, the host computer can send a file move command to the electronic device according to the MTP protocol. The electronic device reads the file or folder according to the file move command, writes the read file or folder to the target folder, and finally deletes the file or folder in the source folder. Through the above process, files or folders can be moved from the source folder to the target folder.
[0004] However, in the process of moving files or folders using the above method, read, write, and delete operations need to be performed on the files or folders, resulting in low efficiency in moving the files or folders. Summary of the invention
[0005] The present application provides a file management method, device and storage medium, which are used to solve the problem of low efficiency in moving files or folders in an electronic device through a host computer.
[0006] In a first aspect, the present application provides a file management method, which is applied to an electronic device, wherein the electronic device stores MTP management information, and the MTP management information is used to indicate a storage path of each file object in the electronic device, and the method includes:
[0007] receiving a file move command for a first file object, the first file object being initially located in a source folder, the file move command being used to instruct to move the first file object from the source folder to a target folder;
[0008] Based on the file move command, determine a first storage path of the file object in the source folder in the electronic device and a second storage path of the file object in the target folder in the electronic device;
[0009] Based on the first storage path and the second storage path, the MTP management information is updated, wherein for the first file object, the updated MTP management information indicates that the storage path of the first file object in the electronic device is the second storage path.
[0010] In a possible implementation, determining a first storage path of a file object in a source folder in an electronic device and a second storage path of a file object in a target folder in an electronic device based on a file move command includes:
[0011] Acquire identification information of the first file object and path identification information of the target folder based on the file move command;
[0012] Determine a first storage path based on the identification information of the first file object;
[0013] Based on the path identification information of the target folder, a second storage path is determined.
[0014] In a possible implementation, updating the MTP management information based on the first storage path and the second storage path includes:
[0015] Updating the storage path of the first file object in the electronic device from the first storage path to the second storage path, wherein the first file object after the updated storage path is located in the target folder;
[0016] In a case where the first file object is located in the target folder, the MTP management information is updated based on the first storage path and the second storage path.
[0017] In a possible implementation, updating the storage path of the first file object in the electronic device from the first storage path to the second storage path includes:
[0018] Based on the first storage path and the second storage path, generate a command parameter of the rename function;
[0019] Based on the command parameters, a rename function is called to update the storage path of the first file object in the electronic device from the first storage path to the second storage path.
[0020] In a possible implementation, the method further includes:
[0021] A file move response is sent, where the file move response is used to indicate that the first file object has been moved from the source folder to the target folder.
[0022] In a second aspect, an embodiment of the present application provides a file management method, which is applied to a host computer, and the method includes:
[0023] Displaying a file management interface, the file management interface includes a first file object, and the first file object is initially located in a source folder;
[0024] In response to a move instruction for moving a first file object from a source folder to a target folder, determining a second storage path of the file object in the target folder in the electronic device;
[0025] Based on the first file object and the second storage path, a file move command is sent, where the file move command is used to instruct to move the first file object from the source folder to the target folder.
[0026] In a possible implementation, the file move command includes identification information of the first file object and path identification information of the target folder, wherein:
[0027] The identification information of the first file object is used to identify the first file object, and the first file object is used to determine the first storage path of the file object in the source folder in the electronic device; the path identification information of the target folder is used to identify the second storage path, and the first storage path and the second storage path are used to move the first file object from the source folder to the target folder.
[0028] In a possible implementation, the method further includes:
[0029] receiving a file move response, the file move response being used to indicate that the first file object has been moved from the source folder to the target folder;
[0030] Based on the file movement response, the file management interface is updated, the updated file management interface includes a target folder, and the target folder includes the first file object.
[0031] In a third aspect, an embodiment of the present application provides a file management device, which is applied to an electronic device, wherein the electronic device stores MTP management information, and the MTP management information is used to indicate the storage path of each file object in the electronic device, and the device includes a first receiving module, a first determining module, and a first updating module, wherein:
[0032] A first receiving module is used to receive a file moving command for a first file object, the first file object is initially located in a source folder, and the file moving command is used to instruct to move the first file object from the source folder to a target folder;
[0033] A first determination module, configured to determine, based on the file move command, a first storage path of the file object in the source folder in the electronic device and a second storage path of the file object in the target folder in the electronic device;
[0034] The first updating module is used to update the MTP management information based on the first storage path and the second storage path, wherein for the first file object, the updated MTP management information indicates that the storage path of the first file object in the electronic device is the second storage path.
[0035] In a possible implementation manner, the first determining module is specifically configured to:
[0036] Acquire identification information of the first file object and path identification information of the target folder based on the file move command;
[0037] Determine a first storage path based on the identification information of the first file object;
[0038] Based on the path identification information of the target folder, a second storage path is determined.
[0039] In a possible implementation manner, the first update module is specifically used to:
[0040] Updating the storage path of the first file object in the electronic device from the first storage path to the second storage path, wherein the first file object after the updated storage path is located in the target folder;
[0041] In a case where the first file object is located in the target folder, the MTP management information is updated based on the first storage path and the second storage path.
[0042] In a possible implementation manner, the first update module is specifically used to:
[0043] Based on the first storage path and the second storage path, generate a command parameter of the rename function;
[0044] Based on the command parameters, a rename function is called to update the storage path of the first file object in the electronic device from the first storage path to the second storage path.
[0045] In a possible implementation, the device further includes a first sending module, wherein:
[0046] The first sending module is used to send a file move response, where the file move response is used to indicate that the first file object has been moved from a source folder to a target folder.
[0047] In a fourth aspect, an embodiment of the present application provides a file management device, which is applied to a host computer. The device includes a display module, a second determination module, and a second sending module, wherein:
[0048] A display module, used for displaying a file management interface, wherein the file management interface includes a first file object, and the first file object is initially located in a source folder;
[0049] A second determining module, configured to determine a second storage path of the file object in the target folder in the electronic device in response to a move instruction for moving the first file object from the source folder to the target folder;
[0050] The second sending module is used to send a file move command based on the first file object and the second storage path, where the file move command is used to instruct to move the first file object from the source folder to the target folder.
[0051] In a possible implementation, the file move command includes identification information of the first file object and path identification information of the target folder, wherein:
[0052] The identification information of the first file object is used to identify the first file object, and the first file object is used to determine the first storage path of the file object in the source folder in the electronic device; the path identification information of the target folder is used to identify the second storage path, and the first storage path and the second storage path are used to move the first file object from the source folder to the target folder.
[0053] In a possible implementation, the device further includes a second receiving module and a second updating module, wherein:
[0054] A second receiving module is used to receive a file move response, where the file move response is used to indicate that the first file object has been moved from the source folder to the target folder;
[0055] The second updating module is used to update the file management interface based on the file movement response, wherein the updated file management interface includes a target folder, and the target folder includes the first file object.
[0056] In a fifth aspect, an embodiment of the present application provides a file management device, including: a memory and a processor;
[0057] Memory stores computer-executable instructions;
[0058] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the file management method involved in the first aspect and any possible implementation manner.
[0059] In a sixth aspect, an embodiment of the present application provides a file management device, including: a memory and a processor;
[0060] Memory stores computer-executable instructions;
[0061] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the file management method involved in the second aspect and any possible implementation manner.
[0062] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer execution instructions. When the computer execution instructions are executed by a processor, they are used to implement the file management method involved in the first aspect or the second aspect and any possible implementation method.
[0063] In an eighth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the file management method involved in the first aspect or the second aspect and any possible implementation manner.
[0064] The present application provides a file management method, device and storage medium. An electronic device first receives a file move command for a first file object, and the file move command is used to instruct to move the first file object from a source folder to a target folder. The electronic device determines the first storage path of the file object in the source folder in the electronic device and the second storage path of the file object in the target folder in the electronic device according to the file move command, and updates MTP management information based on the first storage path and the second storage path, wherein for the first file object, the updated MTP management information indicates that the storage path of the first file object in the electronic device is the second storage path, thereby moving the first file object from the source folder to the target folder. The above method is used to complete the movement of the first file object, and there is no need to perform read, write, or delete operations on the first file object, thereby improving the efficiency of moving the first file object. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0066] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application;
[0067] Figure 2 A schematic diagram of a file management process provided by an embodiment of the present application;
[0068] Figure 3 A schematic diagram of a process for determining a first storage path and a second storage path provided in an embodiment of the present application;
[0069] Figure 4 A schematic diagram of a process for updating MTP management information provided in an embodiment of the present application;
[0070] Figure 5 A flowchart of another file management method provided in an embodiment of the present application;
[0071] Figure 6 A schematic diagram of the structure of a file management device provided in an embodiment of the present application;
[0072] Figure 7 A schematic diagram of the structure of a file management device provided in an embodiment of the present application;
[0073] Figure 8 A schematic diagram of the structure of a file management device provided in an embodiment of the present application.
[0074] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0075] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0076] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0077] For ease of understanding, the following Figure 1 , briefly describe the application scenarios to which the embodiments of the present application are applicable.
[0078] Figure 1 This is a schematic diagram of an application scenario provided by the embodiment of this application. Figure 1 , including a host computer 11 and an electronic device 12 , the host computer 11 and the electronic device 12 are connected via a USB interface 13 , and information exchange can be performed between the host computer 11 and the electronic device 12 based on the USB interface 13 .
[0079] The host computer 11 may be a mobile phone, computer or other device supporting the MTP protocol; the electronic device 12 may be a mobile phone, computer, USB memory, mobile hard disk or other device connected to the host computer 11 via a USB interface 13 .
[0080] At least one folder is stored in the electronic device 12. For any folder, the folder may include files or subfolders. After the electronic device 12 is connected to the host computer 11 via the USB interface 13, the files and folders stored in the electronic device 12 can be displayed through the file management interface of the host computer 11.
[0081] When it is necessary to move the first file object in the electronic device 12, the host computer 11 can send a file move command to the electronic device 12 according to the MTP protocol. After receiving the file move command sent by the host computer 11, the electronic device 12 moves the first file object from the source folder to the target folder and sends a file move response to the host computer 11, thereby realizing the movement of the first file object. The first file object can be a file in the source folder or a subfolder in the source folder.
[0082] by Figure 1 For example, the electronic device 12 stores folder A and folder B, wherein folder A includes files 1 and 2, and folder B includes files 3 and 4. If file 2 is to be moved from folder A to folder B, the host computer can send a file move command to the electronic device according to the MTP protocol, and the electronic device moves file 2 from folder A to folder B after receiving the file move command.
[0083] It should be noted that Figure 1 This is just an example to illustrate an application scenario, and is not intended to limit the application scenario.
[0084] In the related technology, when it is necessary to move the first file object (which can be a file or folder) in an electronic device from a source folder to a target folder, the host computer sends a file move command to the electronic device according to the MTP protocol. After receiving the file move command, the electronic device reads the first file object in the source folder according to the file move command, writes the read first file object into the target folder, and deletes the first file object in the source folder, thereby completing the movement of the first file object and sending a file move response to the host computer.
[0085] However, in the above method, after receiving the file move command, the electronic device needs to perform a series of operations such as reading, writing, and deleting on the first file object, resulting in low efficiency in moving the first file object. Secondly, due to the read and write speed of the hardware device, in order to avoid the host computer receiving the move response timeout, the size of the first file object will also be limited during the process of moving the first file object through this method.
[0086] Based on this, an embodiment of the present application provides a file management method. After receiving a file move command, the electronic device can move the file or folder without performing read, write, or delete operations in the electronic device, thereby improving the efficiency of moving the file or folder.
[0087] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0088] Figure 2 A flowchart of a file management process provided by an embodiment of the present application. Figure 2 , the method is applied to an electronic device, comprising:
[0089] S201. Receive a file move command for a first file object, where the first file object is initially located in a source folder, and the file move command is used to instruct to move the first file object from the source folder to a target folder.
[0090] The first file object can be any file or folder stored in the electronic device, the source folder is the folder where the first file object is currently located, and the target folder is the folder where the first file object is located after the first file object is moved, that is, when the electronic device completes the movement of the first file object, the first file object is located in the target folder.
[0091] The file move command is sent from the host computer to the electronic device, and the file move command may include identification information of the first file object and path identification information of the target folder. The identification information of the first file object is used to uniquely identify the first file object in the host computer, and the path identification information of the target folder is used to uniquely identify the storage path of the target folder in the electronic device in the host computer.
[0092] S202: Based on the file move command, determine a first storage path of the file object in the source folder in the electronic device and a second storage path of the file object in the target folder in the electronic device.
[0093] The first storage path is used to represent the file directory corresponding to the file object in the source folder in the electronic device. For example, assuming that the source folder is located in folder 1, and folder 1 is located in folder 2, the file directory corresponding to the file object in the source folder in the electronic device is source folder-folder 1-folder 2, and the first storage path is determined to be source folder-folder 1-folder 2.
[0094] Since the first file object is located in the source folder, the source folder where the first file object is located can be determined according to the identification information of the first file object in the file move command, and then the first storage path can be determined.
[0095] Similarly, the second storage path is used to represent the file directory corresponding to the file object in the target folder in the electronic device. The electronic device can determine the second storage path of the first file object in the electronic device according to the identification information of the target folder in the file move command.
[0096] S203: Update the MTP management information based on the first storage path and the second storage path, wherein, for the first file object, the updated MTP management information indicates that the storage path of the first file object in the electronic device is the second storage path.
[0097] The electronic device stores MTP management information, and the MTP management information is used to indicate the storage path of each file object in the electronic device. The MTP management information may include the storage path of at least one file object in the electronic device, and when the file object in the MTP management information is a file, the file object is represented by the file tag information of the file, and when the file object in the MTP management information is a folder, the file object is represented by the path tag information of the folder.
[0098] For any file in an electronic device, the electronic device stores the tag information of the file, which is used to uniquely identify the file; the host computer also stores the identification information of the file, which is used to uniquely identify the file, and the tag information and identification information of the file may be inconsistent. For any folder in an electronic device, the electronic device stores the path tag information of the file, which is used to uniquely identify the storage path of the folder in the electronic device; the host computer also stores the path identification information of the folder, which is used to uniquely identify the storage path of the folder in the electronic device, and the path tag information and path identification information of the folder may be inconsistent.
[0099] For example, assuming that the electronic device stores file 1, file 2, and file 3, wherein the tag information of file 1 is X, the tag information of file 2 is Y, and the path tag information of folder 3 is Z; the storage path of file 1 is folder A-folder B, the storage path of file 2 is folder A-folder C, and the storage path of folder 3 is folder D-folder E, the MTP management information may be as shown in Table 1:
[0100] Table 1
[0101] Label information / path label information The storage path of the file X Folder A - Folder B Y Folder A - Folder C Z Folder D - Folder E
[0102] The host computer can determine the storage path of the file object in the electronic device according to the storage path corresponding to the file object indicated by the MTP management information. For example, for the first file object, the MTP management information indicates that the storage path of the first file object in the electronic device is folder A-folder B, and the host computer determines that the storage path of the first file object in the electronic device is folder A-folder B according to the MTP management information.
[0103] Therefore, the file object can be moved by updating the MTP management information. Specifically, the electronic device updates the MTP management information according to the first storage path and the second storage path, and the updated MTP management information indicates that the storage path of the first file object is the second storage path, thereby moving the first file object to the target folder.
[0104] In the file management method provided by the embodiment of the present application, an electronic device receives a file move command for a first file object, determines a first storage path of a file object in a source folder in the electronic device and a second storage path of a file object in a target folder in the electronic device according to the file move command, and changes the storage path of the first file object in the MTP management information from the first storage path to the second storage path according to the first storage path and the second storage path, thereby moving the first file object from the source folder to the target folder. The movement of the first file object is completed by the above method, and there is no need to perform read, write, and delete operations on the first file object, which improves the efficiency of moving the first file object. Furthermore, since there is no need to perform read and write operations on the first file object in the above process, in the process of moving the first file object from the source folder to the target folder, it is not affected by the read and write speed of the hardware device, and there is no limit on the file size of the first file object, which improves the flexibility of moving the first file object.
[0105] exist Figure 2 Based on the embodiment shown, the following Figure 3 The process of determining the first storage path and the second storage path is described in detail.
[0106] Figure 3 A schematic diagram of a process for determining a first storage path and a second storage path provided in an embodiment of the present application. Figure 3 , the method may include the following steps:
[0107] S301: Acquire identification information of a first file object and path identification information of a target folder based on a file move command.
[0108] The file move command may include identification information of the first file object and path identification information of the target folder. The identification information of the first file object is used to uniquely identify the first file object in the host computer. The path identification information of the target folder is used to uniquely identify the storage path of the target folder in the electronic device in the host computer.
[0109] After receiving the file move command, the electronic device may obtain identification information of the first file object and path identification information of the target folder contained in the file move command based on the file move command.
[0110] Optionally, if the electronic device includes two or more memories, and the source folder and the target folder are stored in two different memories, the file move command may also include the memory identification information of the target memory. The target memory is the memory where the target folder is located. The memory identification information of the target memory is used to uniquely identify the target memory in the host computer.
[0111] Optionally, if the file move command also includes storage identification information of the target storage, the electronic device may further obtain the storage identification information in the file move command after receiving the file move command.
[0112] S302: Determine a first storage path based on identification information of the first file object.
[0113] After acquiring the identification information of the first file object, the electronic device parses the identification information of the first file object to obtain tag information of the first file object, where the tag information of the first file object is used to uniquely identify the first file object in the electronic device.
[0114] The electronic device determines the first storage path in the MTP management information according to the tag information of the first file object.
[0115] For example, assuming that the first file object is a file, and the tag information of the file is Z, the MTP management information is as shown in Table 2
[0116] Table 2
[0117] Label information / path label information The storage path of the file X Folder A - Folder B Y Folder A - Folder C Z Folder D - Folder E
[0118] According to the tag information Z of the first file object, it is determined in the MTP management information that the storage path corresponding to the first file object in the electronic device is folder D-folder E, and the storage path folder D-folder E is determined as the first storage path.
[0119] S303: Determine a second storage path based on the path identification information of the target folder.
[0120] After the electronic device obtains the path identification information of the target folder, it parses the path identification information of the target folder to obtain the path tag information of the target folder, where the path tag information is used to uniquely identify the storage path of the target folder in the electronic device.
[0121] According to the path tag information of the target folder, the second storage path is determined in the MTP management information.
[0122] For example, assuming that the path label information of the target folder is X, the MTP management information is shown in Table 3:
[0123] Table 3
[0124] Label information / path label information The storage path of the file X Folder A - Folder B Y Folder A - Folder C Z Folder D - Folder E
[0125] According to the path label information X of the target folder, the storage path corresponding to the target file in the electronic device is determined in the MTP management information as folder A-folder B; combined with the storage path folder A-folder B and the target folder, the second storage path is determined as target folder-folder A-folder B.
[0126] exist Figure 3 In the illustrated embodiment, based on the identification information of the first file object and the path identification information of the target folder in the file move command, the label information of the first file object and the path label information of the target folder are determined respectively, and the first storage path and the second storage path are determined in combination with the MTP management information. This method does not require the first file object to be read, written, or deleted, thereby improving the efficiency of file movement for the first file object.
[0127] Based on the above embodiments, Figure 4 The process of updating MTP management information is described in detail.
[0128] Figure 4 A schematic diagram of a process for updating MTP management information provided in an embodiment of the present application. Figure 4 , the method may include:
[0129] S401: Update the storage path of a first file object in an electronic device from a first storage path to a second storage path, wherein the first file object after the updated storage path is located in a target folder.
[0130] The electronic device may also include a file management system, which is used to manage the storage paths of all file objects stored in the electronic device. The file management system may provide an external interface function, through which the content in the file management system may be modified or updated.
[0131] The method of updating the storage path of the first file object in the electronic device from the first storage path to the second storage path is as follows:
[0132] Based on the first storage path and the second storage path, a command parameter of a rename function is generated; based on the command parameter, the rename function is called to update the storage path of the first file object in the electronic device from the first storage path to the second storage path.
[0133] The renaming function may be an interface function provided by the file management system to change the file name or the file storage path name, that is, to change the name of the file or the file storage path from the source name to the target name. The renaming function may contain parameters (source name, target name). For example, the renaming function may be the rename function.
[0134] The command parameter is used to indicate the parameters included in the rename function. For example, if the parameters included in the rename function are (source name, target name), the command parameter of the rename function is (source name, target name).
[0135] For the first file object, it is necessary to call a rename function to change the storage path of the first file object in the electronic device from the first storage path to the second storage path. Therefore, it can be determined that the command parameter of the rename function can be (first storage path, second storage path) according to the first storage path and the second storage path. Based on the command parameter, after calling the rename function, the rename function changes the storage path of the first file object in the electronic device from the first storage path to the second storage path.
[0136] S402: When the first file object is located in the target folder, update the MTP management information based on the first storage path and the second storage path.
[0137] The MTP management information is obtained based on the mapping of the file management system. After the storage path of the first file object in the electronic device is updated in the file management system, the electronic device changes the storage path of the first file object in the MTP management information according to the first storage path and the second storage path, that is, the storage path of the first file object in the MTP management information is changed from the first storage path to the second storage path.
[0138] For example, assuming that the first file object is a file, the tag information of the file is Y, and the MTP management information is as shown in Table 4:
[0139] Table 4
[0140] Label information / path label information The storage path of the file Y Source folder-Folder A-Folder B
[0141] The first storage path is source folder-folder A-folder B, and the second storage path is target folder-folder C-folder D. After the storage path of the first file object in the MTP management information is changed according to the first storage path and the second storage path, the MTP management information is shown in Table 5:
[0142] Table 5
[0143] Label information / path label information The path where the file is stored Y Target folder - Folder C - Folder D
[0144] Thereby, the storage path of the first file object is updated in the MTP management information.
[0145] S403: Send a file move response, where the file move response is used to indicate that the first file object has been moved from the source folder to the target folder.
[0146] Figure 4 In the embodiment shown, the storage path of the first file object in the electronic device is first updated from the first storage path to the second storage path based on the renaming function, thereby completing the update of the file management system in the electronic device, based on which, the storage path of the first file object in the MTP management information is changed from the first storage path to the second storage path according to the first storage path, the update of the MTP management information is completed and a file move response is sent to the upper computer, thereby completing the movement of the first file object, and moving the first file object from the source folder to the target folder. The method realizes the movement of the first file object by changing the storage path of the first file object, and does not need to perform operations such as reading, writing, and deleting on the first file object, thereby improving the efficiency of moving the first file object. Secondly, when the movement of the first file object is realized by changing the storage path of the first file object, the file size of the first file object will not have any effect on the movement, so the method will not limit the file size of the first file object, thereby making the flexibility of moving the first file object higher.
[0147] Based on the above embodiments, Figure 5 The file management method provided in the embodiment of the present application is further explained.
[0148] Figure 5 This is a flow chart of another file management method provided in the embodiment of the present application. The method is applied to the host computer. Figure 5 , the method may include:
[0149] S501: Display a file management interface, where the file management interface includes a first file object, and the first file object is initially located in a source folder.
[0150] The host computer includes a display component, and the file management interface can be displayed through the display component. The file management interface can include file objects stored in the electronic device. Optionally, the file management interface can also include a folder where the file object is located. For example, for a first file object, the file management interface can include the first file object and can also include a source folder. The first file object in the file management interface is located in the source folder.
[0151] S502: In response to a move instruction for moving a first file object from a source folder to a target folder, determine a second storage path of the file object in the target folder in the electronic device.
[0152] The move instruction may be generated by operating in the file management interface. For example, when a first file object is selected in the file management interface and the first file object is dragged from a source folder to a target folder, a move instruction is generated.
[0153] The host computer determines a second storage path of the file object in the target folder in the electronic device in response to the move instruction.
[0154] S503: Send a file move command based on the first file object and the second storage path, where the file move command is used to instruct to move the first file object from the source folder to the target folder.
[0155] The file move command includes identification information of the first file object and path identification information of the target folder. The identification information of the first file object is used to identify the first file object, and the first file object is used to determine the first storage path of the file object in the source folder in the electronic device; the path identification information of the target folder is used to identify the second storage path, and the first storage path and the second storage path are used to move the first file object from the source folder to the target folder.
[0156] The host computer determines the second storage path of the file object in the target folder in the electronic device based on the move instruction, and determines the identification information of the first file object and the path identification information of the target folder based on the first file object and the second storage path, and generates a file move command according to the MTP protocol, and finally sends the file move command to the electronic device.
[0157] S504: Receive a file move response, where the file move response is used to indicate that the first file object has been moved from the source folder to the target folder.
[0158] After receiving the file move response sent by the electronic device, the host computer can determine that the electronic device has moved the first file object to the target folder. Then, based on the file move response, the host computer updates the file management interface, and the updated file management interface includes the first file object, and the first file object is located in the target folder.
[0159] exist Figure 5 In the illustrated embodiment, when the first file object needs to be moved, operations can be performed in the file management interface to generate a move instruction. Based on the move instruction, the host computer generates a file move command according to the MTP protocol, and sends the file move command to the electronic device. After the electronic device completes the move of the first file object, it receives a file move response sent by the electronic device, and updates the file management interface based on the file move response, so that the first file object in the updated file management interface is located in the target folder. In this method, the host computer generates a file move command and sends the file move command to the electronic device. After receiving the file move response sent by the electronic device, the file management interface is updated, thereby completing the move of the first file object and improving the efficiency of moving the first file object.
[0160] Figure 6 A schematic diagram of the structure of a file management device provided in an embodiment of the present application. Applied in an electronic device, the electronic device stores MTP management information, and the MTP management information is used to indicate the storage path of each file object in the electronic device. Figure 6 The file management device 60 may include a first receiving module 61, a first determining module 62, and a first updating module 63, wherein:
[0161] A first receiving module 61 is used to receive a file move command for a first file object, the first file object is initially located in a source folder, and the move command is used to instruct to move the first file object from the source folder to a target folder;
[0162] A first determining module 62, configured to determine, based on the file move command, a first storage path of the file object in the source folder in the electronic device and a second storage path of the file object in the target folder in the electronic device;
[0163] The first updating module 63 is used to update the MTP management information based on the first storage path and the second storage path, wherein for the first file object, the updated MTP management information indicates that the storage path of the first file object in the electronic device is the second storage path.
[0164] In a possible implementation manner, the first determining module 62 is specifically configured to:
[0165] Acquire identification information of the first file object and path identification information of the target folder based on the file move command;
[0166] Determine a first storage path based on the identification information of the first file object;
[0167] Based on the path identification information of the target folder, a second storage path is determined.
[0168] In a possible implementation manner, the first updating module 63 is specifically configured to:
[0169] Updating the storage path of the first file object in the electronic device from the first storage path to the second storage path, wherein the first file object after the updated storage path is located in the target folder;
[0170] In a case where the first file object is located in the target folder, the MTP management information is updated based on the first storage path and the second storage path.
[0171] In a possible implementation manner, the first updating module 63 is specifically configured to:
[0172] Based on the first storage path and the second storage path, generate a command parameter of the rename function;
[0173] Based on the command parameters, a rename function is called to update the storage path of the first file object in the electronic device from the first storage path to the second storage path.
[0174] In a possible implementation, the file management device 60 further includes a first sending module, wherein:
[0175] The first sending module is used to send a file move response, where the file move response is used to indicate that the first file object has been moved from a source folder to a target folder.
[0176] The file management device provided in this embodiment can be used to execute the file management method shown in the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail here.
[0177] Figure 7 A file management device is provided in an embodiment of the present application. Applied to a host computer, the file management device 70 includes a display module 71, a second determination module 72 and a second sending module 73, wherein:
[0178] A display module 71, configured to display a file management interface, wherein the file management interface includes a first file object, and the first file object is initially located in a source folder;
[0179] A second determining module 72, configured to determine a second storage path of the file object in the target folder in the electronic device in response to a move instruction for moving the first file object from the source folder to the target folder;
[0180] The second sending module 73 is used to send a file move command based on the first file object and the second storage path, where the file move command is used to instruct to move the first file object from the source folder to the target folder.
[0181] In a possible implementation, the file move command includes identification information of the first file object and path identification information of the target folder, wherein:
[0182] The identification information of the first file object is used to identify the first file object, and the first file object is used to determine the first storage path of the file object in the source folder in the electronic device; the path identification information of the target folder is used to identify the second storage path, and the first storage path and the second storage path are used to move the first file object from the source folder to the target folder.
[0183] In a possible implementation, the file management device 70 further includes a second receiving module and a second updating module, wherein:
[0184] A second receiving module is used to receive a file move response, where the file move response is used to indicate that the first file object has been moved from the source folder to the target folder;
[0185] The second updating module is used to update the file management interface based on the file movement response, wherein the updated file management interface includes a target folder, and the target folder includes the first file object.
[0186] The file management device provided in this embodiment can be used to execute the file management method shown in the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail here.
[0187] Figure 8 This is a schematic diagram of the structure of a file management device provided in an embodiment of the present application. Figure 8 As shown, the file management device 80 may include: a memory 81 and at least one processor 82. Exemplarily, the memory 81 and at least one processor 82 are interconnected via a bus 83.
[0188] The memory 81 is used to store program instructions;
[0189] At least one processor 82 is used to execute the program instructions stored in the memory, so as to enable the file management device 80 to execute the method shown in the above method embodiment.
[0190] Optionally, the processor may be a central processing unit (CPU), a graphics processing unit (GPU), other general-purpose processors, a digital signal processor (DSP), or an application-specific integrated circuit (ASIC). A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of the present application may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0191] The file management device provided in the embodiment of the present application can be used to execute the file management method shown in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0192] An embodiment of the present application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the non-transitory computer-readable storage medium storing computer instructions stores computer execution instructions, and when the computer execution instructions are executed by an electronic device, they are used to implement the file management method involved in the above method embodiment.
[0193] An embodiment of the present application provides a computer program product, including a computer program, which, when executed by an electronic device, implements the file management method involved in the above method embodiment.
[0194] An embodiment of the present application provides a chip having a computer program stored thereon. When the computer program is executed by the chip, the file management method involved in the above method embodiment is implemented.
[0195] An embodiment of the present application provides a chip module, on which a computer program is stored. When the computer program is executed by the chip module, the file management method involved in the above method embodiment is implemented.
[0196] All or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a readable memory. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned memory (storage medium) includes: read-only memory (English: read-only memory, abbreviated: ROM), RAM, flash memory, hard disk, solid state drive, magnetic tape (English: magnetic tape), floppy disk (English: floppy disk), optical disc (English: optical disc) and any combination thereof.
[0197] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable terminal device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0198] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0199] These computer program instructions can also be loaded onto a computer or other programmable terminal device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0200] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
[0201] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
[0202] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A file management method, characterized in that: Applied in an electronic device, the electronic device stores media transfer protocol MTP management information, the MTP management information is used to indicate the storage path of each file object in the electronic device, the method includes: receiving a file move command for a first file object, the first file object being initially located in a source folder, the file move command being used to instruct to move the first file object from the source folder to a target folder; Based on the file move command, determining a first storage path of the file object in the source folder in the electronic device and a second storage path of the file object in the target folder in the electronic device; Based on the first storage path and the second storage path, the MTP management information is updated, wherein, for the first file object, the updated MTP management information indicates that the storage path of the first file object in the electronic device is the second storage path.
2. The method according to claim 1, characterized in that The determining, based on the file move command, a first storage path of the file object in the source folder in the electronic device and a second storage path of the file object in the target folder in the electronic device comprises: Acquire identification information of the first file object and path identification information of the target folder based on the file move command; Determining the first storage path based on the identification information of the first file object; The second storage path is determined based on the path identification information of the target folder.
3. The method according to claim 1 or 2, characterized in that: The updating of the MTP management information based on the first storage path and the second storage path includes: updating the storage path of the first file object in the electronic device from the first storage path to the second storage path, wherein the first file object after the updated storage path is located in the target folder; In a case where the first file object is located in the target folder, the MTP management information is updated based on the first storage path and the second storage path.
4. The method according to claim 3, characterized in that The updating the storage path of the first file object in the electronic device from the first storage path to the second storage path includes: Based on the first storage path and the second storage path, generate a command parameter of a renaming function; Based on the command parameters, the rename function is called to update the storage path of the first file object in the electronic device from the first storage path to the second storage path.
5. The method according to claim 1 or 2, characterized in that: The method further comprises: A file move response is sent, where the file move response is used to indicate that the first file object has been moved from the source folder to the target folder.
6. A file management method, characterized in that: Applied to a host computer, the method includes: Displaying a file management interface, wherein the file management interface includes a first file object, and the first file object is initially located in a source folder; In response to a move instruction for moving the first file object from the source folder to the target folder, determining a second storage path of the file object in the target folder in the electronic device; Based on the first file object and the second storage path, a file move command is sent, where the file move command is used to instruct to move the first file object from the source folder to the target folder.
7. The method according to claim 6, characterized in that The file move command includes the identification information of the first file object and the path identification information of the target folder, wherein: The identification information of the first file object is used to identify the first file object, and the first file object is used to determine the first storage path of the file object in the source folder in the electronic device; the path identification information of the target folder is used to identify the second storage path, and the first storage path and the second storage path are used to move the first file object from the source folder to the target folder.
8. The method according to claim 6 or 7, characterized in that: The method further comprises: receiving a file move response, the file move response being used to indicate that the first file object has been moved from the source folder to the target folder; Based on the file move response, the file management interface is updated, the updated file management interface includes the target folder, and the target folder includes the first file object.
9. A file management device, characterized in that: Applied in an electronic device, the electronic device stores MTP management information, the MTP management information is used to indicate the storage path of each file object in the electronic device, the device comprises: A first receiving module, configured to receive a file move command for a first file object, the first file object being initially located in a source folder, the file move command being used to instruct to move the first file object from the source folder to a target folder; A first determining module, configured to determine, based on the file move command, a first storage path of the file object in the source folder in the electronic device and a second storage path of the file object in the target folder in the electronic device; The first updating module is used to update the MTP management information based on the first storage path and the second storage path, wherein, for the first file object, the updated MTP management information indicates that the storage path of the first file object in the electronic device is the second storage path.
10. A file management device, characterized in that: Applied to a host computer, the device comprises: A display module, configured to display a file management interface, wherein the file management interface includes a first file object, and the first file object is initially located in a source folder; A second determining module, configured to determine a second storage path of the file object in the target folder in the electronic device in response to a move instruction for moving the first file object from the source folder to the target folder; The second sending module is used to send a file moving command based on the first file object and the second storage path, where the file moving command is used to instruct to move the first file object from the source folder to the target folder.
11. A file management device, characterized in that: include: Memory and processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 5.
12. A file management device, characterized in that: include: Memory and processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 6 to 8.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.