File access method, electronic device and readable storage medium
By mapping file resources of the second electronic device to the first electronic device and determining the access method based on the access operation and path, the problems of inefficiency and limited access methods for cross-device file access are solved, achieving efficient and targeted file access.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2023-11-29
- Publication Date
- 2026-06-09
Smart Images

Figure CN120104566B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method for accessing files, an electronic device, and a readable storage medium. Background Technology
[0002] With the development of terminal technology, users are using an increasing variety of electronic devices, and the scenarios where multiple electronic devices need to work together are also becoming more frequent. For example, cross-device file access may be required. Therefore, a file access method is urgently needed. Summary of the Invention
[0003] This application provides a file access method, an electronic device, and a readable storage medium, which can be used to enable cross-device file access. The technical solution is as follows:
[0004] Firstly, a file access method is provided, applied in a first electronic device, the method comprising:
[0005] Upon detecting a connection with the second electronic device, the file resources of the second electronic device are mapped to a first mapping space in the file access space of the first electronic device. This first mapping space is used to map file resources in the database of the second electronic device. Upon receiving a first access operation for a first target file, the target access method corresponding to the first target file is determined based on the type of the first access operation and the file path of the first target file in the first mapping space. The first target file can be any file in the first mapping space. The first target file is then accessed according to the target access method.
[0006] It should be noted that the first target file can be any file within the first mapping space. This file can include folders.
[0007] Thus, after the first electronic device and the second electronic device establish a connection, when a user needs to access the first target file through the first electronic device, the first electronic device can determine the target access method for accessing the first target file based on the type of the first access operation and the file path of the first target file. This enables cross-device access to files. Furthermore, because the access method is related to the access operation and the file path, the determined access method is more targeted, enriching the file access options.
[0008] As an example of this application, the operation of the first electronic device mapping the file resources of the second electronic device to a first mapping space in the file access space of the first electronic device when it detects that a connection has been established with the second electronic device includes:
[0009] Upon detecting a connection with the second electronic device, a file access space is created, which includes a first mapping space. According to the type of each file resource in the database, the file path corresponding to each file resource is mapped in the first mapping space. An operation correspondence is established between the file path of each file resource in the first mapping space and the corresponding preset access method set. Each preset access method set includes the access method corresponding to the type of each operation among multiple operations.
[0010] In some embodiments, when creating a file access space, the first electronic device can also verify the legitimacy of the file access space, that is, whether the drive letter of the file access space is occupied, and whether the name of the resource access control of the file access space conforms to a preset standard, etc.
[0011] It is worth noting that by setting a corresponding preset access method set for each file resource's file path in the first mapping space, the access operation for each file resource becomes more targeted, thus improving the efficiency of file access.
[0012] As an example of this application, the operation of the first electronic device mapping the file path corresponding to each file resource in the first mapping space according to the type of each file resource in the database includes:
[0013] Determine the type of each file resource in the database; for any file resource in the database, determine the file path corresponding to accessing any file resource from the first mapping space based on the type of any file resource.
[0014] In this way, by mapping file resources in the database according to their types, it is easier to quickly access file resources by their type, thus improving the efficiency of accessing file resources.
[0015] As an example of this application, the file access space also includes a second mapping space, which is used to map file resources in the file system of the second electronic device. The file path for accessing the second target file resource from the second mapping space is the same as the file path of the second target file resource in the file system. The second target file resource is any file resource mapped to the second mapping space.
[0016] As an example, file access space can also be referred to as a drive.
[0017] In this way, file resources of the database and file system in the second electronic device can be mapped in different ways in the file access space, thereby realizing different file access methods under the same drive.
[0018] As an example of this application, when a first electronic device receives a first access operation on a first target file, the operation of determining the target access method corresponding to the first target file based on the type of the first access operation and the file path of the first target file in the first mapping space includes:
[0019] Upon receiving a first access operation on a first target file, the file path of the first target file in the first mapping space is determined, thus obtaining the first file path. If the first file path is not the root directory path, the target preset access method set corresponding to the first file path is determined from the operation correspondence. If the first access operation is not a file open operation, the access method corresponding to the type of access operation in the target preset access method set is determined as the target access method. If the first access operation is a file open operation, the preset access method is determined as the target access method.
[0020] It should be noted that the operation correspondence is used to indicate the correspondence between multiple file paths in the first mapping space and multiple preset access method sets. Multiple file paths correspond one-to-one with multiple preset access method sets, and each preset access method set includes access methods corresponding to the type of each operation in multiple operations.
[0021] In some embodiments, the first electronic device may further determine the type of the first access operation. If the first access operation is not an open operation, the first electronic device may determine the first file path. If the first file path is not the root directory file path, it may determine the target preset access method set corresponding to the first file path from the operation mapping relationship, and determine the access method corresponding to the type of access operation in the target preset access method set as the target access method. If the first access operation is an open operation, the first file path is determined, and the target preset access method set corresponding to the first file path is determined from the operation mapping relationship, and the access method corresponding to the type of access operation in the target preset access method set is determined as the target access method.
[0022] In this way, by setting the operation correspondence, the target preset access method set corresponding to the first file path can be quickly determined.
[0023] As an example of this application, the target preset access method set also includes a path conversion method, where the first access operation is a file open operation and the target access method is a preset access method; in this case, the operation of the first electronic device accessing the first target file according to the target access method includes:
[0024] Determine the second file path corresponding to the first file path, where the second file path is the file path of the first target file in the database; convert the second file path into a target file path using a path conversion method, where the target file path is a path that can access the first target file through a preset access method; open the first target file according to the target file path and the preset access method.
[0025] Thus, when the access operation is to open the first target file, after determining the first file path, the corresponding second file path can be determined, and the second file path can be converted to obtain the target file path. The first electronic device can then open the first target file using a fixed access method based on the target file path. Since the target file path supports a fixed access method (preset access method), even if the first electronic device has other methods of mounting the second electronic device, the file resources of the second electronic device can still be accessed through the fixed access method, achieving access method compatibility.
[0026] As an example of this application, if the first electronic device determines the length of the first file path before determining the target preset access method set corresponding to the first file path from the operation correspondence when the first file path is not the root directory path; if the length of the first file path is not the preset length, it determines that the first file path is not the root directory path.
[0027] As an example, the first electronic device can also determine whether the format of the first file path conforms to the format of the root directory path. If the format of the first file path does not conform to the format of the root directory path, then the first file path is determined to be a root directory path. If the format of the first file path conforms to the format of the root directory path, then the first file path is determined to be a root directory path.
[0028] As an example, the first electronic device can also compare the first file path with the root directory path. If the first file path and the root directory path are the same, the first file path is determined to be the root directory path. If the first file path and the root directory path are different, the first file path is determined not to be the root directory path.
[0029] Since the length of the root directory path is fixed, the length of the first file path can be used to determine whether the first file path is the root directory path, thus quickly determining whether the first file path is the root directory file path, improving the efficiency and accuracy of determining the root directory path.
[0030] As an example of this application, when the first electronic device receives a first access operation on the first target file, it determines the file path of the first target file in the first mapping space. After obtaining the first file path, it can also access the first target file through the operation kernel of the first electronic device when the first file path is the root directory path and the first access operation is not a file open operation.
[0031] If the first file path is the root directory path and the first access operation is a file open operation, determine the target preset access method set corresponding to the first file path from the operation correspondence, and determine the preset access method as the target access method.
[0032] Thus, if the first file path is the root directory path and the first access operation is not a file open operation, there is no need to determine the preset access mode set. The first target file can be accessed directly by operating the kernel, which improves the access efficiency to the root directory.
[0033] As an example of this application, the first access operation is a file opening operation. In this case, after the first electronic device accesses the first target file according to the target access method, it can also determine the file handle corresponding to the first target file based on the target preset access method set where the target access method of the first target file is located, provided that the access to the first target file is successful. The file handle includes an identifier indicating the target preset access method set where the target access method is located, and the target preset access method set is the preset access method set corresponding to the first file path. Upon receiving a second access operation for the first target file, the target preset access method set is obtained based on the file handle. The first target file is accessed according to the access method corresponding to the type of the second access operation recorded in the target preset access method set.
[0034] In this way, by setting the file handle, the corresponding target preset access method set can be quickly determined when performing other access operations on the first target file after it has been opened.
[0035] As an example of this application, the method further includes:
[0036] Upon detecting a connection with the second electronic device, a trigger operation is received for the file resource management application of the first electronic device; the resource management application interface of the file resource management application is displayed, which displays resource access controls for file access space. The control display information of the resource access controls includes the device name of the second electronic device, the size of the used space and the size of the unused space in the storage space of the second electronic device, and the drive letter corresponding to the file access space; upon receiving a trigger operation for the resource access controls, a file display interface is displayed, which includes a category view and an external storage control. The category view includes multiple file access controls, each of which is the entry point for accessing file resources of the corresponding file type mapped to the first mapping space, and the external storage control is the entry point for accessing various file resources mapped to the second mapping space.
[0037] Thus, after the first electronic device and the second electronic device establish a connection, when a user needs to access the first target file through the first electronic device, the first electronic device can determine the target access method for accessing the first target file based on the type of the first access operation and the file path of the first target file. This achieves cross-device file access. Furthermore, because the access method is related to the access operation and the file path, the determined access method is more targeted, enriching the file access options. Additionally, since the category view can display multiple file access controls, each of which is an entry point for accessing file resources of the corresponding file type mapped to the first mapping space, users can quickly find the required file resources by file type, improving the efficiency of file resource retrieval.
[0038] In a second aspect, a first electronic device is provided, comprising a processor and a memory. The memory stores a program that supports the first electronic device in executing the file access method provided in the first aspect, and stores data related to implementing the file access method described in the first aspect. The processor is configured to execute the program stored in the memory. The first electronic device may further include a communication bus for establishing a connection between the processor and the memory.
[0039] Thirdly, a computer-readable storage medium is provided, wherein instructions are stored therein, which, when executed on a computer, cause the computer to perform the file access method described in the first aspect.
[0040] Fourthly, a computer program product containing instructions is provided, which, when run on a computer, causes the computer to execute the file access method described in the first aspect above.
[0041] The technical effects achieved by the second, third, and fourth aspects mentioned above are similar to those achieved by the corresponding technical means in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0042] Figure 1 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application;
[0043] Figure 2 This is a schematic diagram illustrating another application scenario provided by an embodiment of this application;
[0044] Figure 3 This is a schematic diagram illustrating another application scenario provided by an embodiment of this application;
[0045] Figure 4 This is a schematic diagram illustrating another application scenario provided by an embodiment of this application;
[0046] Figure 5 This is a flowchart illustrating a method for creating a file access space according to an embodiment of this application;
[0047] Figure 6 This is a schematic diagram illustrating another application scenario provided by an embodiment of this application;
[0048] Figure 7 This is an architecture diagram of a file access scheme provided in an embodiment of this application;
[0049] Figure 8 This is a flowchart of a file access method provided in an embodiment of this application;
[0050] Figure 9 This is a flowchart of another file access method provided in an embodiment of this application;
[0051] Figure 10 This is a flowchart of another file access method provided in an embodiment of this application;
[0052] Figure 11 This is a flowchart of another file access method provided in an embodiment of this application;
[0053] Figure 12 This is a flowchart of another file access method provided in an embodiment of this application;
[0054] Figure 13 This is a schematic diagram of the structure of a first electronic device provided in an embodiment of this application. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0056] It should be understood that "multiple" as mentioned in this application refers to two or more. In the description of this application, unless otherwise stated, " / " indicates "or," for example, A / B can mean A or B; "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist, for example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, to facilitate a clear description of the technical solutions of this application, the terms "first," "second," etc., are used to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first," "second," etc., do not limit the quantity or execution order, and that "first," "second," etc., do not necessarily imply differences.
[0057] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0058] In some application scenarios, users are using an increasing number of electronic devices, such as computers, mobile phones, tablets, and e-readers. Furthermore, there are increasingly more scenarios where these multiple devices need to work together. For example, a user might need to open a file on their mobile phone via a computer. Therefore, there is a pressing need for a method to access files.
[0059] To achieve cross-device file access, this application provides a file access method. In this method, when a first electronic device detects a connection with a second electronic device, it can map the file resources of the second electronic device to a first mapping space in the file access space of the first electronic device. This first mapping space is used to map file resources in the database of the second electronic device. When the first electronic device receives a first access operation for a first target file, it can determine the target access method corresponding to the first target file based on the type of the first access operation and the file path of the first target file in the first mapping space. The first target file can be any file in the first mapping space. The first target file is then accessed according to the target access method. In this application embodiment, after the first electronic device and the second electronic device establish a connection, when a user needs to access the first target file through the first electronic device, the first electronic device can determine the target access method for accessing the first target file based on the type of the first access operation and the file path of the first target file. This achieves cross-device file access. Furthermore, since the access method is related to the access operation and the file path, the determined access method is more targeted, enriching the file access methods.
[0060] To facilitate understanding, before providing a detailed description of the methods provided in the embodiments of this application, the application scenarios involved in the embodiments of this application will be introduced below.
[0061] Please refer to Figure 1 , Figure 1 This is a schematic diagram illustrating an application scenario provided by an embodiment of this application. In one application scenario, a user may need to use some information on their mobile phone while using a computer, such as text and video. See [link to relevant documentation]. Figure 1 In Figure (a), the user may connect computer S1 and mobile phone S2 via a data cable (or other methods). After connecting computer S1 and mobile phone S2, the user can click the application icon S3 of the file resource management application displayed on the desktop of computer S1 (in the accompanying drawings of this application embodiment, the application icon S3 of the file resource management application is represented by an icon of "My Computer" and a computer shape). When computer S1 receives the click operation on the application icon S3, it can display as follows: Figure 1 Figure (b) shows the first application interface S4 of the file resource management application. This first application interface S4 displays a resource access control S5 for the mobile phone S2. The control S5 displays information including the phone's name (XX phone), the total storage space and used space of the phone S2, and the corresponding drive letter. The user can continue to click on the resource access control S5. Upon receiving a click on the resource access control S5, the computer displays the following... Figure 1 The file display interface S6 shown in Figure (c) displays a category view S61 and a local view S62. The category view S61 includes multiple file access controls, namely, an image access control, a video access control, a document access control, a compressed file access control, an application access control, and a music access control. The local view S62 includes an external storage control, whose display information can be "My Phone". If a user needs to access images on the phone S2 via the computer S1, the user can click the image access control. Upon receiving a click on the image access control, the computer S1 can display the following... Figure 1 As shown in Figure (d) of the image browsing interface S7, users can view the images they need to access in the image browsing interface.
[0062] In yet another application scenario, the computer S1 displays as follows: Figure 2 In the case of the file display interface S6 shown in Figure (a), the user can also access file resources such as pictures and documents on the mobile phone S2 through the external storage control. The external storage control is equivalent to a second-level directory (the first-level directory is the resource access control S5). The user can click on the external storage control; when the computer S1 receives the click operation on the external storage control, it can display as follows: Figure 2 As shown in Figure (b) of the three-level directory interface S8, the user can select the folder to be accessed from the three-level directory interface S8 and continue to click until the image to be accessed is accessed.
[0063] In another application scenario, when a computer displays something like... Figure 3 In the case of the first application interface S4 of the file resource management application shown in Figure (a), if the connection between computer S1 and mobile phone S2 encounters a problem after the user clicks the resource access control S5 in the first application interface S4, such as a disconnection or poor connection, then after computer S1 receives the click operation on the resource access control S5, computer S1 can display as follows: Figure 3 The prompt interface S9 shown in Figure (b) displays "Connection failed, please try again".
[0064] Please refer to Figure 4 , Figure 4 This is a schematic diagram illustrating another application scenario provided by an embodiment of this application. In yet another application scenario, the user can not only trigger the display of the first application interface S4 of the file resource management application on the computer S1 desktop via the application identifier S3 of the file resource management application, but also trigger it in other ways, such as through a PC manager application. For example, the computer S1 displays... Figure 4In the case of the second application interface S10 of the PC Manager application shown in Figure (a), the user can click the "Storage Sharing" control in the second application interface S10. When the computer S1 receives the click operation on the storage sharing control, the computer S1 can display as shown in Figure (a). Figure 4 In (b) the first application interface S4, and when the computer S1 and the mobile phone S2 are connected, the first application interface S4 displays a resource access control S5.
[0065] It should be noted that the embodiments in this application are based only on the above. Figures 1-4 The application scenarios shown are for illustrative purposes only and do not constitute a limitation on the application scenarios of the embodiments of this application.
[0066] Based on the application scenarios provided in the above embodiments, and to facilitate understanding of the embodiments of this application, the method for creating a file access space provided in the embodiments of this application will be described below. Please refer to... Figure 5 , Figure 5 This is a flowchart illustrating a method for creating a file access space according to an exemplary embodiment. It is provided as an example and not a limitation. The method is illustrated using an application to a first electronic device as an example, and may include some or all of the following:
[0067] Step 501: If a connection with the second electronic device is detected, determine the drive letter corresponding to the file access space.
[0068] It should be noted that the file access space is the space in the first electronic device used to map file resources of the second electronic device. This file access space may include the first mapping space and / or the second mapping space. See [link to documentation]. Figure 6 The first mapping space is used to map file resources in the database of the second electronic device, and the second mapping space is used to map file resources in the file system of the second electronic device. Typically, this file access space can also be referred to as a drive, and this embodiment does not impose specific limitations on it.
[0069] As an example, when a first electronic device detects a connection with a second electronic device, to facilitate user access to file resources on the second electronic device, the first electronic device can typically call a Software Development Kit (SDK) interface to create a file access space. Generally, the first electronic device can first determine the resource access control corresponding to the file access space. This resource access control is the entry point for accessing the various file resources mapped to the file access space, and the control's display information can include the device name of the second electronic device and the drive letter corresponding to the file access space. Therefore, when a connection is established with the second electronic device, the first electronic device can determine the drive letter corresponding to the file access space. For example, this resource access control can be as follows: Figure 1 As shown in Figure (b) of the document.
[0070] In some embodiments, when a connection is established between the first electronic device and the second electronic device, the first electronic device may randomly determine a drive letter from a preset set of drive letters. Alternatively, a drive letter may be determined by other means, and this application embodiment does not impose specific limitations on this.
[0071] Step 502: Determine whether the specified drive letter is occupied. If yes, proceed to step 503 below; otherwise, proceed to step 504 below.
[0072] It should be noted that the drive letter is part of the control display information of the resource access control. The drive letter must be different from the drive letter of the existing storage space in the first electronic device. Therefore, the first electronic device needs to determine whether the determined drive letter is occupied. If it is occupied, the operation ends. Alternatively, if it is occupied, the operation of step 503 below is performed, that is, a new drive letter is determined.
[0073] Step 503: Reassign a different drive letter and return to the operation in step 502.
[0074] It should be noted that the drive letter re-acquired by the first electronic device is different from the previously determined drive letter. For example, if the drive letter was determined to be F last time, then the drive letter determined this time can be a drive letter other than F, such as G.
[0075] Step 504: Determine whether the name of the resource access control corresponding to the file access space conforms to the preset standard. If yes, proceed to step 505 below; otherwise, end the operation.
[0076] It should be noted that this preset standard can be set in advance according to needs. For example, the preset standard can be the UTF-8 encoding rule.
[0077] Step 505: Set the attributes of the file access space.
[0078] For example, the first electronic device can set attributes such as root directory attribute, access attribute, modification time, and status change time of the file access space. Specifically, the first electronic device can set the root directory attribute of the file access space to the default value, set the access attribute of the file access space to allow access, set the modification time of the file access space, and set the status change time of the file access space to the time when the file access space was created.
[0079] Step 506: Determine whether the file access space includes the first mapping space. If yes, proceed to step 507 below. If no, proceed to step 509 below.
[0080] It should be noted that after determining the control display information of the resource access control, the first electronic device can determine whether the created file access space includes the first mapping space. That is, the first electronic device needs to determine which mapping spaces are included in the created file access space.
[0081] As an example, the first electronic device has a preset creation rule. If the creation rule indicates that a first mapping space is to be created, it is determined that the file access space includes the first mapping space; if the creation rule does not indicate that a first mapping space is to be created, it is determined that the file access space does not include the first mapping space.
[0082] Step 507: Map the file path corresponding to each file resource in the first mapping space according to the type of each file resource in the database of the second electronic device.
[0083] Because the database of the second electronic device can store different types of file resources, such as images, documents, compressed files, applications, videos, and music, and in order to enable quick access to the file resources in the second electronic device through the first electronic device, the first electronic device can map the file path corresponding to each file resource in the first mapping space according to the type of each file resource in the database of the second electronic device.
[0084] As an example, the operation of the first electronic device mapping the file path corresponding to each file resource in the first mapping space according to the type of each file resource in the database of the second electronic device includes: determining the type of each file resource in the database; for any file resource in the database, determining the file path corresponding to accessing any file resource from the first mapping space according to the type of any file resource.
[0085] It should be noted that, in this embodiment of the application, mapping the file resources of the second electronic device to the first mapping space does not mean transferring the file resources in the second electronic device to the first mapping space. Rather, it is achieved by establishing a correspondence between the file paths of the file resources in the second electronic device and the memory addresses of the memory in the first electronic device.
[0086] In some embodiments, the first electronic device may send a file retrieval message for a database to the second electronic device. Upon receiving the file retrieval message for a database, the second electronic device may map the identifier of a file resource in the database to the first electronic device, wherein the identifier of the file resource includes information indicating the type of the file resource; the first electronic device receives the identifier of the file resource sent by the second electronic device and obtains the type of the file resource from the identifier of the file resource.
[0087] It should be noted that the file resource identifier is used to uniquely identify the corresponding file resource. Since different types of file resources have different storage formats, the storage format of a file resource can indicate its type. Therefore, the file resource identifier can be the file resource's name plus its format. For example, if the file resource is an image, the file resource identifier can be the image's name and format (1.jpg, 2.gif, etc.). If the file resource is a document, the file resource identifier can be the document's name and format (3.txt, 4.doc, 5.pdf, etc.).
[0088] As an example, the first electronic device can set up multiple folders in the first mapping space, each folder being used to map a type of file resource. In this way, the first device can map each file resource in the database of the second electronic device to the corresponding folder according to its type. The file path of any folder and the path of the file within that folder constitute the file path of the mapped file resource in the first mapping space.
[0089] Step 508: Establish the operation correspondence between the file path of each file resource in the first mapping space and the corresponding preset access method set.
[0090] It should be noted that each preset access method includes access methods corresponding to each type of operation in multiple operations. For example, it includes at least one of the following: attribute query method, read method, write method, delete method, open method, file path conversion method, copy method, paste method, and save method.
[0091] As an example, the first electronic device can randomly map the file path of each file resource in the first mapping space to any one of the preset access method sets from a set of multiple preset access methods. Alternatively, the first electronic device can establish an operational mapping relationship between the file path of each file resource in the first mapping space and the corresponding preset access method set according to the type of each resource file. For example, the first electronic device can map the file paths of file resources of the same type in the first mapping space to the same access method set. Or, the first electronic device can set the file paths of files in the same directory level to the same access method set.
[0092] Step 509: Map the file path of each file resource in the second mapping space according to the file path of each file resource in the file system of the second electronic device.
[0093] As an example, the first electronic device can obtain the file path of each file resource in the file system of the second electronic device and map the obtained file path of each file resource to a second mapping space. That is, the file path of the file resource mapped to the second mapping space is the same as its file path in the file system.
[0094] It should be noted that if the file access space does not include the first mapping space, the first electronic device can directly execute the operation of step 509. Furthermore, if the file access space includes both the first and second mapping spaces, this embodiment does not impose specific restrictions on the order in which the first electronic device maps file resources in the database of the second electronic device and maps file resources in the file system of the second electronic device. That is, if the file access space includes both the first and second mapping spaces, the first electronic device can execute steps 507 and 509 simultaneously, or execute step 509 after completing step 508; alternatively, the first electronic device can execute step 509 first, and then execute steps 507 and 508. Of course, in some embodiments, the file access space may include the first mapping space but not the second mapping space; in such cases, the first electronic device will not execute step 509 after completing step 508.
[0095] In some embodiments, after the file path mapping for each file resource is completed in the file access space, when the first electronic device displays the application interface of the file resource management application, the application interface may display a resource access control. In addition to the corresponding drive letter and the device name of the second electronic device, the control display information of the resource access control may also display at least one of the following: the size of the file access space, the size of the used space, and the size of the unused space. That is, it displays at least one of the storage space size, the size of the used space, and the size of the unused space of the second electronic device.
[0096] As an example, after completing the file path mapping for each file resource in the file access space, the first electronic device, while displaying the application interface of the file resource management application, can query the device information of the second electronic device through the disk information query function, and display at least one of the storage space size, used space size, and unused space size of the second electronic device in the application interface of the file resource management application.
[0097] In some embodiments, the file path of each file resource mapped in the second mapping space corresponds to the same preset set of remote access methods.
[0098] For example, each preset access mode set (including the remote access mode set) is essentially a static function that implements file access operations, including opening and closing files, reading and writing directories, etc. For ease of understanding, refer to... Figure 7 This application provides a file access scheme architecture diagram. In this architecture diagram, each preset access method set is represented by a virtual module. For example, multiple preset access method sets can be classified file operation modules, transparent file operation modules, etc., and remote access method sets can be remote file operation modules, etc. Among them, the transparent file operation module and the classified file operation module belong to the modules corresponding to the first mapping space, and the remote file operation module is used to access the modules in the file system of the second electronic device.
[0099] In some embodiments, see Figure 7 The first electronic device can also be equipped with an operation distribution module, which can be associated with each preset access method set (or each file operation module). In this way, when the operation distribution module determines the file operation module corresponding to any file path, it can send a call message to the corresponding file operation module.
[0100] In this embodiment, when a connection is established with a second electronic device, a file access space can be set, and different preset access method sets can be set for different mapping spaces in the file access space. This makes the access operation for each file resource more targeted and improves the efficiency of file access. In addition, file resources in the database are classified and mapped according to file resource type, which facilitates subsequent quick access to file resources by their type, thus improving the efficiency of accessing file resources.
[0101] After establishing a file access space and mapping file resources in the second electronic device to the file access space, the first electronic device can access file resources in the second electronic device through that file access space. Next, taking the operation of querying file attributes in the first mapped space as an example, the file access method provided in this application embodiment will be described. Please refer to... Figure 8 , Figure 8 This is a schematic flowchart illustrating a file access method according to an exemplary embodiment. It is provided as an example and not a limitation, and the method is illustrated using an application to a first electronic device as an example. The method may include some or all of the following:
[0102] Step 801: Upon receiving a query operation for the first target file, determine the file path of the first target file in the first mapping space to obtain the first file path.
[0103] As described above, the first mapping space can map file resources in the second electronic device. That is, the first mapping space establishes some file paths, which correspond to file resources in the second electronic device, and different file paths in the first mapping space indicate different files. In this embodiment, each folder and its contents in the first mapping space can be referred to as a file. Therefore, the first target file may be a folder in the first mapping space or an identifier of a mapped file resource.
[0104] As an example, since the first electronic device determines the file path corresponding to any file resource in the database of the second electronic device in the first mapping space, the first electronic device can obtain the first file path based on the file location triggered by the query operation.
[0105] Step 802: Determine whether the first file path of the first target file is the root directory path. If yes, proceed to step 803 below; otherwise, proceed to step 804 below.
[0106] As an example, the first electronic device can determine the length of the first file path; if the length of the first file path is not a preset length, it determines that the first file path is not the root directory path. If the length of the first file path is a preset length, it determines that the first file path is the root directory path.
[0107] It should be noted that this preset length can be set according to the length of the root directory path, such as a preset length of 1. Specifically, if a file path contains one forward slash, its length is determined to be 1; if it contains two forward slashes, its length is determined to be 2. That is, if a file path contains N forward slashes, its length is N, where N is an integer.
[0108] For example, if the first file path P1 is F: / test / xxx / and has a preset length of 1, then since the length of the first file path P1 is 3, it can be determined that the first file path P1 is not the root directory path. If the first file path P2 is F: / and has a preset length of 1, then since the length of the first file path P2 is also 1, it can be determined that the first file path P2 is the root directory path.
[0109] In some embodiments, the first electronic device may also determine the root directory path in other ways, such as comparing the first file path with the root directory path. If the first file path and the root directory path are different, the first file path is determined to be not the root directory path. If the first file path and the root directory path are the same, the first file path is determined to be the root directory path.
[0110] Step 803: Access the first target file through the operating kernel of the first electronic device.
[0111] Since the first file path is the root directory path, the first target file is the resource access control of the file access space. Furthermore, as mentioned above, when the file access space is created, the first electronic device sets the attributes of the file access space. Therefore, the first electronic device can directly access the first target file by operating the kernel, that is, directly query the attribute information of the file access space by operating the kernel.
[0112] As can be seen from the above, the first electronic device is equipped with a file operation distribution module. Thus, when the first electronic device determines that the first file path is the root directory path through the file operation distribution module, it can send the attribute information of the file access space to the operation kernel of the first electronic device, so that the operation kernel of the first electronic device can complete the query of the attribute information of the file access space.
[0113] Step 804: Determine whether the target preset access method set corresponding to the first file path exists in the operation correspondence. If yes, then perform the operation in step 805 below; if not, then perform the operation in step 807 below.
[0114] It should be noted that the operation correspondence is used to indicate the correspondence between multiple file paths in the first mapping space and multiple preset access method sets. These multiple file paths correspond one-to-one with the multiple preset access method sets, and each preset access method set includes access methods corresponding to the type of each operation in multiple operations.
[0115] In some embodiments, the first electronic device may determine whether a first file path exists in the operation mapping relationship. If it is determined that a first file path exists in the operation mapping relationship, it may then determine whether a target preset access method set corresponding to the first file path exists in the operation mapping relationship.
[0116] As an example, the first electronic device can traverse multiple file paths in the operation mapping relationship. If a file path identical to the first file path is encountered during traversal, it is determined that the first file path exists in the operation mapping relationship. If the traversal ends and no file path identical to the first file path is encountered, it is determined that the first file path and the target preset access method corresponding to the first file path do not exist in the operation mapping relationship.
[0117] For example, the operation correspondence can be shown in Table 1 below.
[0118] Table 1
[0119] File path Preset access method set F: / test / First preset access method set F: / test / xxx / Second preset access method set F: / test / xxx / tt / Third preset access method set
[0120] It should be noted that the embodiments of this application are only illustrated using the operation correspondence shown in Table 1 as an example, and do not constitute a limitation on the embodiments of this application.
[0121] As an example, the first electronic device can also determine whether the first file path exists in the operation correspondence in other ways. For example, it can search for the first file path in reverse order of the directory level to which the path belongs, level by level.
[0122] For example, if the first file path is "F: / test / xxx / tt / ", the first electronic device can first check if "tt / " exists in the operation mapping relationship, and if the path "tt / " is the last level path in the file path it belongs to, that is, there are no other paths after the path "tt / ". If "tt / " exists, it further determines whether the parent path of the file path containing the path "tt / " in the operation mapping relationship is "xxx / ". If the parent path of the file path containing the path "tt / " is "xxx / ", it further determines whether the parent path of the file path containing the path "xxx / tt / " in the operation mapping relationship is "test / ". If the parent path of the file path containing the path "xxx / tt / " is "test / ", it further determines whether the parent path of the file path containing the path "test / xxx / tt / " in the operation mapping relationship is "F: / ". If the parent path of the file path containing the path "test / xxx / tt / " is "F: / ", it is determined that the first file path "F: / test / xxx / tt / " exists in the operation mapping relationship.
[0123] Step 805: Determine the query method corresponding to the target preset access method centralized query operation.
[0124] Since each preset access method set includes access methods corresponding to each type of operation in multiple operations, the first electronic device can determine the query method corresponding to the query operation in the target preset access method set.
[0125] Step 806: Access the first target file according to the determined query method.
[0126] In some embodiments, the first electronic device may invoke the query method to query the attribute information of the first target file.
[0127] Step 807: Display the first prompt message.
[0128] It should be noted that this first prompt message indicates that the file attributes of the first target file cannot be queried. This first prompt message can appear as a pop-up window or in a new interface similar to the one described above. Figure 3 The prompt interface shown in Figure (b) is shown in the image.
[0129] It should also be noted that the example in this application embodiment is a query operation that queries file attributes. When the access operation is any other than the open operation, such as the deletion, copying, or renaming of the first target file, the access to the first target file can also be achieved through the operations in steps 801-807 above. This application embodiment will not elaborate on these points.
[0130] In this embodiment of the application, the access method is determined for the first time based on whether the first file path is the root directory path. If the first file path is not the root directory path, the corresponding target preset access method set can be selected to access the first target file. Since the access method is related to the access operation and the file path, the determined access method is more targeted and the file access methods are enriched.
[0131] Since access operations can include various types of operations, and the access method for file opening operations differs from other types of access methods, the following description uses the operation of opening a file in the first mapped space (file opening operation) as an example to introduce the file access method provided in this application embodiment. Please refer to... Figure 9 , Figure 9 This is a schematic flowchart illustrating a file access method according to an exemplary embodiment. It is provided as an example and not a limitation, and the method is illustrated using an application to a first electronic device as an example. The method may include some or all of the following:
[0132] Step 901: Upon receiving a file open operation for the first target file, determine the file path of the first target file in the first mapping space to obtain the first file path.
[0133] It should be noted that the operation of step 901 can refer to the operation of step 801 above, and this application embodiment will not describe it in detail.
[0134] Step 902: Determine whether the target preset access method set corresponding to the first file path exists in the operation correspondence. If yes, then perform the operation in step 903 below; if no, then perform the operation in step 907 below.
[0135] It should be noted that the operation of step 902 can refer to the operation of step 804 above, and this application embodiment will not describe it in detail.
[0136] Step 903: Determine the opening method corresponding to the file opening operation in the target preset access method set.
[0137] Since each preset access method set includes access methods corresponding to each type of operation in multiple operations, the first electronic device can determine the opening method corresponding to the file opening operation in the target preset access method set.
[0138] Step 904: Access the first target file according to the determined opening method.
[0139] In some embodiments, the first electronic device may invoke the open method to open the first target file.
[0140] Step 905: Determine whether the first target file was accessed successfully. If yes, proceed to step 906 below; otherwise, proceed to step 907 below.
[0141] Step 906: Determine and cache the file handle corresponding to the first target file based on the target preset access method set where the target access method corresponding to the first target file is located.
[0142] It should be noted that the file handle includes an identifier that indicates the target preset access method set to which the target access method is located.
[0143] Since the user may need to perform other access operations on the first electronic device after the first target file is opened, such as read operations and write operations, if the first electronic device cannot determine the file handle corresponding to the first target file when it receives other access operations for the opened first target file, then the first electronic device can repeat steps 901-904 to perform other access operations on the opened first target file. If the first electronic device determines and caches the file handle corresponding to the first target file after successful access, then when the first electronic device receives other access operations for the opened first target file, it can obtain the target preset access method set based on the file handle. In this way, it is not necessary to repeat the above steps 901-904.
[0144] In some embodiments, the first electronic device may obtain the file handle and identifier of the target preset access mode set, as well as the address of the file handle of the target preset access mode set; and determine the file handle of the target preset access mode set, the address of the file handle of the target preset access mode set, and the identifier as the context of the file handle corresponding to the first target file.
[0145] It is worth noting that since the address of a file handle is unique and will not be repeated, the uniqueness of the file handle corresponding to the first target file can be guaranteed by using the address of the file handle of the target preset access mode set as the file handle corresponding to the first target file.
[0146] Step 907: Display the second prompt message.
[0147] It should be noted that this second prompt message is used to indicate that the first target file cannot be opened. This second prompt message can appear as a pop-up window or in a new interface similar to the one described above. Figure 3 The prompt interface shown in Figure (b) is shown in the image.
[0148] In this embodiment of the application, when the access operation is an open operation on the first target file, the first electronic device can determine the corresponding target access method set according to the first file path of the first target file, and open the first target file according to the open method corresponding to the target access method set. After the first target file is opened, when other access operations are performed on the opened first target file, in order to quickly find the corresponding target preset access method set later, the first electronic device can determine the file handle corresponding to the first target file. Subsequently, the target preset access method set can be quickly found through the file handle, which improves the efficiency of determining the target preset access method set.
[0149] When the second electronic device is connected to the first electronic device, the first electronic device can not only map file resources in the second electronic device through file access space, but may also map them through other methods. In this case, if the access operation is a file opening operation, it may be impossible to open the first target file using the opening method recorded in the target preset access method set. Instead, it may need to be opened using another fixed access method (among other mapping methods, file resources in the second electronic device can be accessed through this fixed access method). Moreover, this fixed access method usually has certain requirements on the file path. Therefore, when opening the first target file, the first electronic device can perform file path conversion. Next, taking the access operation of opening a file in the first mapping space (file opening operation) as an example, the file access method provided in the embodiments of this application will be described. Please refer to Figure 10 , Figure 10 This is a schematic flowchart illustrating a file access method according to an exemplary embodiment. It is provided as an example and not a limitation, and the method is illustrated using an application to a first electronic device as an example. The method may include some or all of the following:
[0150] The operations of steps 1001-1002 can be referred to the operations of steps 901-902 above, and will not be described in detail in this embodiment.
[0151] Step 1003: Determine if a second file path exists based on the first file path. If yes, proceed to step 1004 below. If no, proceed to step 1008 below.
[0152] Since the file resources in the database of the second electronic device are mapped to the first mapping space, the first electronic device stores the file paths of the file resources mapped to the first mapping space in the first mapping space. The first electronic device can call the SDK interface based on the first file path to query the second file path of the first target file in the second electronic device. Specifically, the operating kernel of the first electronic device can obtain the second file path by calling the method to query file attributes.
[0153] For example, the first file path of the first target file is "F: / image / 1.jpg / ", and the second file path corresponding to the first file path is " / sdcard / Picture / 1.jpg / ".
[0154] As an example, if the second file path does not exist, it indicates that an error may have occurred during the mapping process of the first target file. Therefore, it is necessary to perform the operation in step 1008 below, or the first electronic device can directly end this operation.
[0155] Step 1004: Convert the second file path into the target file path using path conversion.
[0156] It should be noted that the target file path is the path that can be accessed through a preset access method, which is the fixed access method mentioned above.
[0157] As described above, each preset access method set can include access methods corresponding to each type of operation in multiple operations, and can also include other methods, such as path conversion methods. Thus, the first electronic device can convert the second file path into the target file path using the path conversion method in the target preset access method set.
[0158] For example, the first electronic device converts the second file path " / sdcard / Picture / 1.jpg / " using a path conversion method, resulting in a target file path of "C: / user / user1 / dfs / devicel / default / sdcard / Picture / 1.jpg / " or "user / user1 / dfs / devicel / default / sdcard / Picture / 1.jpg / ".
[0159] For example, the first electronic device may include a transparent file operation module. Thus, when the first electronic device determines that the target preset access method set is a categorized file operation module, the transparent file operation module can convert the second file path into a target file path using a path conversion method, and send the target file path to the remote file operation module. For example, see [link to example]. Figure 7 .
[0160] Step 1005: Open the first target file according to the target file path and preset access method.
[0161] It should be noted that this preset access method is one of the file opening methods in the aforementioned remote operation module. Thus, when the remote operation module receives the target file path, it can notify the operation kernel, which can then invoke the preset access method in the remote operation module to open the first target file.
[0162] Step 1006: Determine whether the first target file was accessed successfully. If yes, proceed to step 1007 below; otherwise, proceed to step 1008 below.
[0163] Step 1007: Cache the first file path and the second file path.
[0164] After the first target file is opened, if subsequent read or write operations are performed on it, the first electronic device will frequently call the method to query file attributes to obtain the second file path, resulting in wasted kernel resources. Therefore, to avoid repeatedly querying the second file path, the first electronic device can cache the mapping between the first and second file paths. This way, when subsequent read or write operations are performed on the first target file, the first electronic device can obtain the second file path from the cached mapping. If the second file path is not found in the cached mapping, it will call the SDK interface to query it, thereby improving the performance of the kernel.
[0165] Since a user may open the first target file multiple times via the first electronic device, the first electronic device can also count the mapping relationship between the first file path and the second file path. The count is incremented by 1 when the first target file is opened and decremented by 1 when the file handle is closed. When the count reaches 0, the mapping relationship between the first file path and the second file path is removed from the cache.
[0166] Step 1008: Display the third prompt message.
[0167] It should be noted that this third prompt message is used to indicate that the first target file cannot be opened. This third prompt message can appear as a pop-up window or in a new interface similar to the one described above. Figure 3 The prompt interface shown in Figure (b) is shown in the image.
[0168] In this embodiment, when the access operation is an open operation on the first target file, after determining the first file path, the corresponding second file path can be determined, and the second file path can be converted to obtain the target file path. The first electronic device can open the first target file using a fixed access method based on the target file path. Since the target file path supports a fixed access method, even if there are other ways to mount the second electronic device within the first electronic device, the file resources of the second electronic device can still be accessed through the fixed access method, thus achieving access method compatibility.
[0169] The methods for accessing files can include more than just the above. Figure 5 , Figure 8 , Figure 9 and Figure 10 The method shown may also include other approaches. Next, other file access methods provided in the embodiments of this application will be described. Please refer to... Figure 11 , Figure 11 This is a schematic flowchart illustrating a file access method according to another exemplary embodiment. It is provided as an example and not as a limitation. The method is described with the application of it to a first electronic device as an example. The method may include some or all of the following:
[0170] Step 1101: Upon detecting a connection with the second electronic device, map the file resources of the second electronic device to the first mapping space in the file access space of the first electronic device.
[0171] It should be noted that the first mapping space is used to map file resources in the database of the second electronic device.
[0172] As an example, when a first electronic device detects a connection with a second electronic device, the operation of mapping the file resources of the second electronic device to a first mapping space in the file access space of the first electronic device includes: upon detecting a connection with the second electronic device, creating a file access space, which includes the first mapping space; mapping the file path corresponding to each file resource in the first mapping space according to the type of each file resource in the database; and establishing an operation correspondence between the file path of each file resource in the first mapping space and the corresponding preset access method set, where each preset access method set includes access methods corresponding to the type of each operation among multiple operations. Exemplarily, the first electronic device can refer to steps 501-508 above for this process, and this embodiment will not elaborate further.
[0173] It is worth noting that by setting a corresponding preset access method set for each file resource's file path in the first mapping space, the access operation for each file resource becomes more targeted, thus improving the efficiency of file access.
[0174] In some embodiments, the operation of the first electronic device mapping the file path corresponding to each file resource in the first mapping space according to the type of each file resource in the database includes: determining the type of each file resource in the database; and for any file resource in the database, determining the file path corresponding to accessing any file resource from the first mapping space based on the type of any file resource. Exemplarily, this process can refer to the operation of step 507 above, and will not be described in detail in this embodiment.
[0175] It is worth noting that classifying and mapping file resources in the database by file resource type facilitates quick access to file resources by their type, thus improving the efficiency of accessing file resources.
[0176] In some embodiments, the file access space further includes a second mapping space, which is used to map file resources in the file system of the second electronic device, and the file path for accessing the second target file resource from the second mapping space is the same as the file path of the second target file resource in the file system, wherein the second target file resource is any file resource mapped to the second mapping space.
[0177] As an example, if the file access space also includes a second mapping space, when the first electronic device establishes a connection with the second electronic device, it can also map the file path of each file resource in the second mapping space according to the file path of each file resource in the file system of the second electronic device. Exemplarily, this process can refer to the operation of step 509 above, and this embodiment of the application will not describe it in detail.
[0178] Step 1102: Upon receiving a first access operation for the first target file, determine the target access method corresponding to the first target file based on the type of the first access operation and the file path of the first target file in the first mapping space.
[0179] It should be noted that the first target file can be any file in the first mapping space.
[0180] As an example, upon receiving a first access operation on a first target file, the first electronic device determines the target access method corresponding to the first target file based on the type of the first access operation and the file path of the first target file in the first mapping space. This includes: upon receiving the first access operation on the first target file, determining the file path of the first target file in the first mapping space to obtain the first file path; if the first file path is not a root directory path, determining the target preset access method set corresponding to the first file path from an operation correspondence relationship. This operation correspondence relationship indicates the correspondence between multiple file paths and multiple preset access method sets in the first mapping space, with each file path corresponding one-to-one with each preset access method set. Each preset access method set includes access methods corresponding to the type of each operation in multiple operations; if the first access operation is not a file open operation, determining the access method corresponding to the type of the access operation in the target preset access method set as the target access method; if the first access operation is a file open operation, determining the preset access method as the target access method.
[0181] It should be noted that the correspondence of this operation can be shown in Table 1 above.
[0182] It is worth noting that by setting the operation correspondence, the target preset access method set corresponding to the first file path can be quickly determined.
[0183] In some embodiments, the first electronic device can determine the target access method not only through the methods described above, but also through other methods. For example, the first electronic device can first determine the type of the first access operation. If the first access operation is not an open operation, the first electronic device can determine the first file path. If the first file path is not the root directory file path, it can determine the target preset access method set corresponding to the first file path from the operation mapping relationship, and determine the access method corresponding to the type of access operation in the target preset access method set as the target access method. If the first access operation is an open operation, the first file path is determined, and the target preset access method set corresponding to the first file path is determined from the operation mapping relationship, and the access method corresponding to the type of access operation in the target preset access method set is determined as the target access method.
[0184] In some embodiments, when the first electronic device obtains the first file path, it can determine the length of the first file path; if the length of the first file path is not a preset length, it determines that the first file path is not a root directory path. If the length of the first file path is a preset length, it determines that the first file path is a root directory path.
[0185] As an example, the first electronic device can determine whether a first file path is a root directory path not only by its length, but also through other methods. For instance, it can determine whether the format of the first file path conforms to the format of a root directory path. If the format does not conform, the first file path is determined not to be a root directory path. If the format conforms, the first file path is determined to be a root directory path. Alternatively, the first electronic device can compare the first file path with the root directory path. If they are the same, the first file path is determined to be a root directory path. If they are different, the first file path is determined not to be a root directory path.
[0186] It is worth noting that since the length of the root directory path is fixed, determining whether the first file path is the root directory path by using the length of the first file path can quickly determine whether the first file path is the root directory file path, thus improving the efficiency and accuracy of determining the root directory path.
[0187] In some embodiments, when the first file path is a root directory path and the first access operation is not a file open operation, the first target file is accessed through the operation kernel of the first electronic device; when the first file path is a root directory path and the first access operation is a file open operation, the target preset access method set corresponding to the first file path is determined from the operation correspondence, and the preset access method is determined as the target access method.
[0188] It is worth noting that when the first file path is the root directory path and the first access operation is not a file open operation, there is no need to determine the preset access mode set. The first target file can be accessed directly by operating the kernel, which improves the access efficiency to the root directory.
[0189] Step 1103: Access the first target file according to the target access method.
[0190] As described above, the target access method may be a preset access method, or it may be an access method corresponding to the type of the first access operation determined from the set of target preset access methods. When the target access method is the type of the first access operation determined from the set of target preset access methods, the first electronic device can directly invoke this target access method through its operating kernel to access the first target file.
[0191] In some embodiments, the target preset access method set further includes a path conversion method. The first access operation is a file opening operation, and the target access method is a preset access method. In this case, the operation of the first electronic device to access the first target file according to the target access method includes: determining the second file path corresponding to the first file path, the second file path being the file path of the first target file in the database; converting the second file path into a target file path through the path conversion method, the target file path being a path that can access the first target file through the preset access method; and opening the first target file according to the target file path and the preset access method. Exemplarily, this process can refer to the operations of steps 1003 to 1005 above, and this application embodiment will not elaborate on them one by one.
[0192] In some embodiments, when the first access operation is a file open operation, after the first electronic device accesses the first target file according to the target access method, it can also, if the access to the first target file is successful, determine the file handle corresponding to the first target file according to the target preset access method set to which the target access method corresponding to the first target file is located. The file handle includes an identifier indicating the target preset access method set to which the target access method is located, and the target preset access method set is the preset access method set corresponding to the first file path. When a second access operation to the first target file is received, the target preset access method set is obtained according to the file handle. The first target file is accessed according to the access method corresponding to the type of the second access operation recorded in the target preset access method set.
[0193] Since the user may need to perform other access operations on the first electronic device after the first target file is opened, such as read operations and write operations, if the first electronic device cannot determine the file handle corresponding to the first target file when it receives other access operations for the opened first target file, then the first electronic device can repeatedly determine the first file path and the target preset access mode set corresponding to the first file path. If the first electronic device determines the file handle corresponding to the first target file after successful access, then the first electronic device can obtain the target preset access mode set based on the file handle when it receives other access operations for the opened first target file.
[0194] It is worth noting that by setting the file handle, when performing other access operations on the first target file after it has been opened, the corresponding target preset access method set can be quickly determined.
[0195] In some embodiments, the first electronic device can not only determine and cache the file handle corresponding to the first target file, but also cache the mapping relationship between the first file path and the second file path of the first target file. Thus, when subsequent read or write operations are performed on the opened first target file, the first electronic device can obtain the second file path from the cached mapping relationship. If the second file path does not exist in the cached mapping relationship, it can call the SDK interface to query the second file path, thereby improving the performance of the operating kernel.
[0196] In this embodiment, after the first electronic device and the second electronic device establish a connection, when a user needs to access a first target file through the first electronic device, the first electronic device can determine the target access method for accessing the first target file based on the type of the first access operation to the first target file and the file path of the first target file. This enables cross-device access to the file. Furthermore, since the access method is related to the access operation and the file path, the determined access method is more targeted, enriching the file access methods.
[0197] The above describes the method for implementing file access within the first electronic device. Next, we will describe the changes in the interface displayed by the first electronic device during the file access process. Please refer to [link / reference]. Figure 12 , Figure 12 This is a schematic flowchart illustrating a file access method according to another exemplary embodiment. It is provided as an example and not as a limitation. The method is described with the application of it to a first electronic device as an example. The method may include some or all of the following:
[0198] Step 1201: Upon detecting a connection with the second electronic device, receive a trigger operation from the file resource management application of the first electronic device.
[0199] Upon detecting a connection with the second electronic device, the user may want the first electronic device to display an entry point for accessing the file resources of the second electronic device. In this case, the user can trigger an action on the file resource management application of the first electronic device, such as clicking the application icon of the file resource management application. This scenario can be described as described above. Figure 1 The application scenario is illustrated. In this way, the first electronic device can receive trigger operations from the file resource management application on the first electronic device.
[0200] In some embodiments, users can also trigger the file resource management application in other ways, such as triggering the file resource management application in a third-party application, as described above. Figure 4 The application scenarios shown.
[0201] Step 1202: Display the file resource management application interface.
[0202] It should be noted that the resource management application interface displays a resource access control for file access space. The control displays information including the device name of the second electronic device, the amount of used space and unused space in the storage space of the second electronic device, and the drive letter corresponding to the file access space.
[0203] For example, the scenario where the first electronic device displays the resource management application interface of a file resource management application can be referred to the above. Figure 1 Figure (b) in the middle or Figure 4 The application scenario is shown in Figure (b).
[0204] In some embodiments, before displaying the resource management interface, the first electronic device can send an information retrieval request to the second electronic device via an SDK interface. Upon receiving the information retrieval request, the second electronic device can send information about its storage space usage to the first electronic device, including the amount of used space, the amount of unused space, and the total size of its storage space. After receiving the storage space usage information, the first electronic device can display the resource management interface based on the information determined when accessing the space during file creation.
[0205] Step 1203: Upon receiving a trigger operation on the resource access control, display the file display interface.
[0206] It should be noted that the file display interface includes a category view and an external storage control. The category view includes multiple file access controls, each serving as an entry point to access file resources of the corresponding file type mapped to the first mapping space. The external storage control serves as an entry point to access various file resources mapped to the second mapping space. For example, this application scenario can be referenced as described above. Figure 1 The application scenario is shown in Figure (c).
[0207] In some embodiments, the first electronic device receiving a trigger operation on the resource access control is equivalent to the first electronic device receiving an open operation on the root directory. The first electronic device can determine the target preset access method set corresponding to the root directory path in accordance with the above embodiments, open the root directory through the target preset access method set, and display the file display interface.
[0208] In some embodiments, when a user triggers an operation on multiple file access controls in a category view, each of the multiple file access controls is equivalent to the first target file in the above embodiments. Therefore, the operation of the first electronic device accessing any one of the file access controls will not be described in detail in this application embodiment.
[0209] In some embodiments, since the file path of each file resource mapped in the second mapping space corresponds to the same preset remote access method set, the first electronic device can access the external storage control through the remote access method set.
[0210] In this embodiment, after the first electronic device and the second electronic device establish a connection, when a user needs to access a first target file through the first electronic device, the first electronic device can determine the target access method for accessing the first target file based on the type of the first access operation and the file path of the first target file. This achieves cross-device access to the file. Furthermore, since the access method is related to the access operation and the file path, the determined access method is more targeted, enriching the file access methods. Additionally, since multiple file access controls can be displayed in the category view, and each file access control is an entry point for accessing file resources of the corresponding file type mapped to the first mapping space, users can quickly find the required file resources by file type, improving the efficiency of file resource retrieval.
[0211] After explaining in detail the document access methods provided in the embodiments of this application, the electronic devices involved in the embodiments of this application will be described.
[0212] As an example, this method can be applied to electronic devices capable of connecting to other electronic devices. By way of example and not limitation, the first electronic device can be, but is not limited to, tablet computers, desktop computers, laptop computers, handheld computers, laptops, in-vehicle devices, ultra-mobile personal computers (UMPCs), netbooks, etc. The second electronic device can be a personal digital assistant (PDA), mobile phone, smartwatch, etc., and this application embodiment does not limit this.
[0213] Figure 13 This is a schematic diagram of the structure of a first electronic device provided in an embodiment of this application. The first electronic device may be... Figure 13 The electronic device shown. See also Figure 13 The electronic device includes at least one processor 201, a communication bus 202, a memory 203, and at least one communication interface 204.
[0214] The processor 201 may be a microprocessor (including a central processing unit (CPU) or the like), an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program of the present application.
[0215] The communication bus 202 may include a path for transmitting information between the aforementioned components.
[0216] The memory 203 may be a read-only memory (ROM), random access memory (RAM), electrically erasable programmable read-only memory (EEPROM), optical disc (including compact disc read-only memory (CD-ROM), compressed optical disc, laser disc, digital versatile optical disc, Blu-ray disc, etc.), magnetic disk storage medium, or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but not limited thereto. The memory 203 may exist independently and be connected to the processor 201 via the communication bus 202. The memory 203 may also be integrated with the processor 201.
[0217] Communication interface 204 uses any transceiver-like device to communicate with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc.
[0218] In a specific implementation, as one example, the processor 201 may include one or more CPUs, such as... Figure 13 CPU0 and CPU1 are shown in the diagram.
[0219] In a specific implementation, as one example, the first electronic device may include multiple processors, such as... Figure 13 The processors 201 and 205 are shown. Each of these processors may be a single-core processor or a multi-core processor. Here, "processor" may refer to one or more devices, circuits, and / or processing cores used to process data (such as computer program instructions).
[0220] In a specific implementation, as one embodiment, the first electronic device may further include an output device and an input device. The output device communicates with the processor 201 and can display information in various ways. For example, the output device may be a liquid crystal display (LCD), a light-emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device communicates with the processor 201 and can receive user input in various ways. For example, the input device may be a mouse, a keyboard, a touchscreen device, or a sensing device, etc.
[0221] The aforementioned first electronic device can be a general-purpose first electronic device or a dedicated first electronic device. In specific implementations, the first electronic device can be a desktop computer, a portable computer, a network server, a handheld computer, a mobile phone, a tablet computer, a wireless terminal device, a communication device, or an embedded device. The embodiments of this application do not limit the type of the first electronic device.
[0222] The memory 203 stores program code 210 for executing the scheme of this application, and the processor 201 executes the program code 210 stored in the memory 203. The first electronic device can implement the file access method provided in the above embodiments through the processor 201 and the program code 210 in the memory 203.
[0223] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line, DSL) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer, or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., Digital Versatile Discs (DVDs)), or semiconductor media (e.g., Solid State Disks (SSDs)).
[0224] The above-described embodiments are optional embodiments provided by this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the technical scope disclosed in this application should be included within the protection scope of this application.
Claims
1. A method for accessing a file, characterized in that, Applied in a first electronic device, the method includes: Upon detecting a connection with the second electronic device, a file access space is created, which includes a first mapping space and a second mapping space. The first mapping space is used to map file resources in the database of the second electronic device, and the second mapping space is used to map file resources in the file system of the second electronic device. According to the type of each file resource in the database, map the file path corresponding to each file resource in the first mapping space; Establish an operation correspondence between the file path of each file resource in the first mapping space and the corresponding preset access method set, wherein each preset access method set includes access methods corresponding to the type of each operation in multiple operations; Based on the file path of each file resource in the file system of the second electronic device, the file path of each file resource is mapped in the second mapping space. The file path of each file resource mapped in the second mapping space corresponds to the same preset remote access mode set. The mapping of file resources is achieved by establishing a correspondence between the file path of the file resource in the second electronic device and the memory address of the memory in the first electronic device. Upon receiving a first access operation for the first target file, the file path of the first target file in the first mapping space is determined to obtain the first file path, wherein the first target file is any file in the first mapping space; If the first file path is not the root directory path, the target preset access method set corresponding to the first file path is determined from the operation correspondence relationship. The operation correspondence relationship is used to indicate the correspondence between multiple file paths and multiple preset access method sets in the first mapping space. The multiple file paths and the multiple preset access method sets correspond one-to-one. Access the first target file according to the target preset access method set; If the first access operation is an open operation, and the first target file cannot be accessed through the target preset access method set, then the second file path corresponding to the first file path is determined, and the second file path is the file path of the first target file in the database. The second file path is converted into a target file path by using the path conversion methods included in the target preset access method set. The target file path is a path that can access the first target file through a preset access method. The preset access method is an access method in the remote access method set. Access the first target file according to the target file path and the preset access method.
2. The method as described in claim 1, characterized in that, The step of mapping the file path corresponding to each file resource in the first mapping space according to the type of each file resource in the database includes: Determine the type of each file resource in the database; For any file resource in the database, the file path corresponding to the file resource is determined from the first mapping space based on the type of the file resource.
3. The method as described in claim 1, characterized in that, Before determining the target preset access method set corresponding to the first file path from the operation correspondence when the first file path is not the root directory path, the method further includes: Determine the length of the first file path; If the length of the first file path is not a preset length, it is determined that the first file path is not the root directory path.
4. The method as described in claim 1 or 3, characterized in that, Upon receiving a first access operation on the first target file, after determining the file path of the first target file in the first mapping space and obtaining the first file path, the method further includes: When the first file path is the root directory path and the first access operation is not a file open operation, the first target file is accessed through the operating kernel of the first electronic device; When the first file path is the root directory path and the first access operation is the file open operation, the target preset access method set corresponding to the first file path is determined from the operation correspondence, and the preset access method is determined as the target access method.
5. The method as described in claim 1, characterized in that, The first access operation is a file open operation; the method further includes: If access to the first target file is successful, the file handle corresponding to the first target file is determined according to the target preset access method set where the target access method corresponding to the first target file is located. The file handle includes an identifier indicating the target preset access method set where the target access method is located. The target preset access method set is the preset access method set corresponding to the file path of the first target file in the first mapping space. Upon receiving a second access operation to the first target file, the target preset access method set is obtained based on the file handle; Access the first target file according to the access method corresponding to the type of the second access operation recorded in the target preset access method set.
6. The method according to any one of claims 1-3, characterized in that, The method further includes: Upon detecting a connection with the second electronic device, a trigger operation is received on the file resource management application of the first electronic device; The resource management application interface of the file resource management application is displayed. The resource management application interface displays the resource access control of the file access space. The control display information of the resource access control includes the device name of the second electronic device, the size of the used space and the size of the unused space in the storage space of the second electronic device, and the drive letter corresponding to the file access space. Upon receiving a trigger operation on the resource access control, a file display interface is displayed. The file display interface includes a category view and an external storage control. The category view includes multiple file access controls, each of which is an entry point for accessing file resources of the corresponding file type mapped to the first mapping space. The external storage control is an entry point for accessing various file resources mapped to the second mapping space.
7. An electronic device, characterized in that, The electronic device includes a processor and a memory. The memory is used to store programs that enable the electronic device to perform the method as described in any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-6.