File access method, electronic equipment and readable storage medium

By creating a file access space in the first electronic device and mapping the file resources of the second electronic device, and determining the access method according to the access operation type and file path, the problem of cross-device file access is solved, and an efficient and rich file access experience is achieved.

CN120104566AActive Publication Date: 2025-06-06HONOR DEVICE CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202311626338.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-29
Publication Date
2025-06-06
Estimated Expiration
2043-11-29

AI Technical Summary

Technical Problem

The prior art is difficult to achieve file access across devices, especially in scenarios where multiple electronic devices work together.

Method used

Cross-device access of files is achieved by creating a file access space in the first electronic device, mapping file resources of the second electronic device, and determining the target access method according to the access operation type and file path.

Benefits of technology

It realizes efficient access to files across devices, improves the richness and pertinence of file access methods, and simplifies user file operations between multiple devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104566A_ABST
    Figure CN120104566A_ABST
Patent Text Reader

Abstract

The invention discloses a file access method, electronic equipment and a readable storage medium, and belongs to the technical field of computers. The method is applied to first electronic equipment and comprises the steps that under the condition that it is detected that connection with second electronic equipment is established, file resources of the second electronic equipment are mapped to a first mapping space in a file access space of the first electronic equipment, and the first mapping space is used for mapping file resources in a database of the second electronic equipment; under the condition that a first access operation on a first target file is received, a target access mode corresponding to the first target file is determined according to the type of the first access operation and a file path of the first target file in the first mapping space, and the first target file is any file in the first mapping space; and accessing the first target file according to the target access mode. The access mode of the file is related to the access operation and the file path of the file, so that the determined access mode is more targeted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a file access method, an electronic device and a readable storage medium. Background Art

[0002] With the development of terminal technology, the types of electronic devices used by users are increasing, and in the process of using multiple electronic devices, there are more and more scenarios in which multiple electronic devices work together. For example, cross-device file access may be required. Therefore, a file access method is urgently needed. Summary of the invention

[0003] The present application provides a file access method, an electronic device and a readable storage medium, which can be used to implement cross-device access to files. The technical solution is as follows:

[0004] In a first aspect, a method for accessing a file is provided, which is applied in a first electronic device, and the method includes:

[0005] When a connection is detected with a second electronic device, file resources of the second electronic device are mapped to a first mapping space in the file access space of the first electronic device, and the first mapping space is used to map file resources in a database of the second electronic device; when a first access operation to a first target file is received, a target access mode corresponding to the first target file is determined according to a type of the first access operation and a file path of the first target file in the first mapping space, and the first target file is any file in the first mapping space; and the first target file is accessed according to the target access mode.

[0006] It should be noted that the first target file is any file in the first mapping space, and the file may include a folder.

[0007] In this way, after the first electronic device is connected to the second electronic device, when the 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 according to the type of the first access operation on the first target file and the file path of the first target file, thus achieving cross-device access to the file. And because the access method is related to the access operation and the file path of the file, the determined access method is more targeted, and the file access method is more abundant.

[0008] As an example of the present application, when the first electronic device detects that a connection is established with the second electronic device, the operation of mapping the file resource of the second electronic device to the first mapping space in the file access space of the first electronic device includes:

[0009] When a connection is detected with a 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; and an operational correspondence is established 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 an access method corresponding to the type of each operation in a plurality of 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, whether the name of the resource access control of the file access space meets preset standards, etc.

[0011] It is worth noting that by setting a corresponding preset access mode set for the file path of each file resource in the first mapping space, the access operation to each file resource is more targeted, thereby improving the efficiency of file access.

[0012] As an example of the present 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 any file resource accessed from the first mapping space according to the type of any file resource.

[0014] In this way, mapping the file resource classifications in the database by file resource type can facilitate subsequent rapid access to file resources by the type to which the file resources belong, thereby improving the efficiency of accessing file resources.

[0015] As an example of the present application, the file access space also includes a second mapping space, which is used to map file resources in the file system of a 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, and the second target file resource is mapped to any file resource in the second mapping space.

[0016] As an example, a file access space may also be referred to as a drive.

[0017] In this way, the file resources of the database and the 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 driver.

[0018] As an example of the present application, when the first electronic device receives a first access operation to a first target file, the operation of determining the target access mode corresponding to the first target file according to the type of the first access operation and the file path of the first target file in the first mapping space includes:

[0019] When a first access operation to a first target file is received, the file path of the first target file in the first mapping space is determined to obtain the first file path; when the first file path is not a root directory path, the target preset access mode set corresponding to the first file path is determined from the operation correspondence. When the first access operation is not a file open operation, the access mode corresponding to the type of access operation in the target preset access mode set is determined as the target access mode; when the first access operation is a file open operation, the preset access mode is determined as the target access mode.

[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 to multiple preset access method sets, and each preset access method set includes an access method corresponding to the type of each operation in the multiple operations.

[0021] In some embodiments, the first electronic device may also first 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, and if the first file path is not a root directory file path, determine the target preset access method set corresponding to the first file path from the operation correspondence, 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, determine the first file path, and determine the target preset access method set corresponding to the first file path from the operation correspondence, and determine the access method corresponding to the type of access operation in the target preset access method set as the target access method.

[0022] In this way, by setting the operation correspondence, the target preset access mode set corresponding to the first file path can be quickly determined.

[0023] As an example of the present application, the target preset access mode set also includes a path conversion mode, the first access operation is a file opening operation, and the target access mode is a preset access mode; in this case, the operation of the first electronic device accessing the first target file according to the target access mode includes:

[0024] Determine a 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; convert the second file path into a target file path through a path conversion method, the target file path being 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] In this way, when the access operation is an opening operation for the first target file, after determining the first file path, the second file path corresponding to the first 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 through a fixed access method according to the target file path. Since the target file path supports a fixed access method (preset access method), in this way, when there are other ways to mount the second electronic device in the first electronic device, the file resources of the second electronic device can still be accessed through a fixed access method, thereby achieving compatibility of the access methods.

[0026] As an example of the present application, when the first file path is not a root directory path, the first electronic device may also determine 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 relationship; when the length of the first file path is not a preset length, it is determined that the first file path is not a root directory path.

[0027] As an example, the first electronic device may also determine whether the format of the first file path conforms to the format of the root directory path, and if the format of the first file path does not conform to the format of the root directory path, determine that the first file path is not the root directory path. If the format of the first file path conforms to the format of the root directory path, determine that the first file path is the root directory path.

[0028] As an example, the first electronic device may also compare the first file path with the root directory path, and determine that the first file path is the root directory path if the first file path is the same as the root directory path, and determine that the first file path is not the root directory path if the first file path is not the same as the root directory path.

[0029] In this way, since the length of the root directory path is fixed, whether the first file path is the root directory path can be determined by the length of the first file path, so that it is possible to quickly determine whether the first file path is the root directory file path, thereby improving the efficiency and accuracy of judging the root directory path.

[0030] As an example of the present application, when the first electronic device receives a first access operation to a first target file, it determines a file path of the first target file in a first mapping space, and after obtaining the first file path, it can also access the first target file through the operating kernel of the first electronic device when the first file path is a root directory path and the first access operation is not a file open operation;

[0031] When the first file path is the root directory path and the first access operation is a file opening operation, a target preset access mode set corresponding to the first file path is determined from the operation correspondence, and the preset access mode is determined as the target access mode.

[0032] Thus, when the first file path is a root directory path and the first access operation is not a file opening operation, the first target file can be directly accessed through the operation kernel without determining a preset access mode set, thereby improving the access efficiency to the root directory.

[0033] As an example of the present 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, 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 in 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 in 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; and 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, when other access operations are subsequently performed on the first target file after it is opened, the corresponding target preset access mode set can be quickly determined.

[0035] As an example of the present application, the method further includes:

[0036] When it is detected that a connection has been established with a second electronic device, a trigger operation of a file resource management application of the first electronic device is received; a resource management application interface of the file resource management application is displayed, wherein a resource access control of a file access space is displayed in the resource management application interface, and control display information of the resource access control includes a device name of the second electronic device, the size of used space and the size of unused space in the storage space of the second electronic device, and a drive letter corresponding to the file access space; when a trigger operation of the resource access control is received, a file display interface is displayed, wherein the file display interface includes a classification view and an external storage control, wherein the classification view includes multiple file access controls, each file access control is an entry for accessing file resources of a corresponding file type mapped to the first mapping space, and the external storage control is an entry for accessing individual file resources mapped to the second mapping space.

[0037] In this way, after the first electronic device establishes a connection with the second electronic device, when the 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 on the first target file and the file path of the first target file, thereby achieving cross-device access to the file. And because the access method is related to the access operation and the file path of the file, the determined access method is more targeted, and the file access method is more abundant. In addition, because multiple file access controls can be displayed in the classification view, each file access control is an entry for accessing the file resource mapped to the corresponding file type in the first mapping space, so that the user can quickly find the required file resources by file type, thereby improving the efficiency of file resource search.

[0038] In a second aspect, a first electronic device is provided, wherein the structure of the first electronic device includes a processor and a memory, wherein the memory is used to store a program that supports the first electronic device to execute the file access method provided in the first aspect, and to store data involved in 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 also include a communication bus, wherein the communication bus is used to establish a connection between the processor and the memory.

[0039] According to a third aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is executed on a computer, the computer executes the file access method according to the first aspect.

[0040] In a fourth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the file access method described in the first aspect.

[0041] The technical effects obtained by the above-mentioned second aspect, third aspect and fourth aspect are similar to the technical effects obtained by the corresponding technical means in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is a schematic diagram of an application scenario provided by an embodiment of the present application;

[0043] Figure 2 is a schematic diagram of another application scenario provided by an embodiment of the present application;

[0044] Figure 3 is a schematic diagram of another application scenario provided by an embodiment of the present application;

[0045] Figure 4 is a schematic diagram of another application scenario provided by an embodiment of the present application;

[0046] Figure 5 is a flowchart of a method for creating a file access space provided by an embodiment of the present application;

[0047] Figure 6 is a schematic diagram of another application scenario provided by an embodiment of the present application;

[0048] Figure 7 This is a file access solution architecture diagram provided by an embodiment of the present application;

[0049] Figure 8 is a flowchart of a method for accessing a file provided by an embodiment of the present application;

[0050] Fig. 9 is a flowchart of another file access method provided by an embodiment of the present application;

[0051] Fig.10 is a flowchart of another file access method provided by an embodiment of the present application;

[0052] Fig.11 is a flowchart of another file access method provided by an embodiment of the present application;

[0053] Fig.12 is a flowchart of another file access method provided by an embodiment of the present application;

[0054] Fig.13 It is a structural schematic diagram of a first electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0055] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0056] It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, the words "first" and "second" are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not limit them to be different.

[0057] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0058] In some application scenarios, users use more and more electronic devices, such as computers, mobile phones, tablet computers, e-readers, etc., and when users use multiple electronic devices, there are more and more scenarios where multiple electronic devices work together. For example, users may need to open files in their mobile phones through computers. Therefore, a method for accessing files is urgently needed.

[0059] In order to achieve cross-device file access, the embodiment of the present application provides a file access method, in which the first electronic device can map the file resources of the second electronic device to the first mapping space in the file access space of the first electronic device when detecting that the connection is established with the second electronic device, and the first mapping space is used to map the file resources in the database of the second electronic device; the first electronic device can determine the target access mode corresponding to the first target file according to the type of the first access operation and the file path of the first target file in the first mapping space when receiving the first access operation to the first target file, and the first target file is any file in the first mapping space; according to the target access mode, access the first target file. In the embodiment of the present application, after the first electronic device is connected to the second electronic device, when the user needs to access the first target file through the first electronic device, the first electronic device can determine the target access mode for accessing the first target file according to the type of the first access operation to the first target file and the file path of the first target file, so as to achieve cross-device access to the file. And because the access mode is related to the access operation and the file path of the file, the determined access mode is more targeted, and the file access mode is more abundant.

[0060] For ease of understanding, before introducing the method provided in the embodiments of the present application in detail, the application scenarios involved in the embodiments of the present application are introduced below.

[0061] Please refer to Figure 1 , Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present application. In an application scenario, a user may need to use some information in a mobile phone, such as texts, videos, etc. in a mobile phone, while using a computer. Figure 1 In Figure (a), the user may connect the computer S1 and the mobile phone S2 via a data cable (of course, they may also be connected in other ways). After the computer S1 and the mobile phone S2 are connected, the user may click on the application identifier S3 of the file resource management application displayed on the desktop of the computer S1 (the application identifier S3 of the file resource management application is represented by "My Computer" and a computer-shaped icon in the accompanying drawings of the embodiment of the present application); when the computer S1 receives the click operation on the application identifier S3, it may display the following Figure 1 The first application interface S4 of the file resource management application shown in FIG. (b) of FIG. 1 shows a resource access control S5 related to the mobile phone S2. The control display information of the resource access control S5 includes the name of the mobile phone (XX mobile phone), the total storage space and the used space size of the mobile phone S2, the corresponding drive letter, etc. The user can continue to click on the resource access control S5. When the computer receives the click operation on the resource access control S5, it displays the following information: Figure 1 The file display interface S6 shown in Figure (c) includes a classification view S61 and a local view S62. The classification view S61 includes multiple file access controls, which are picture access controls, video access controls, document access controls, compressed package access controls, application access controls, and music access controls. The local view S62 includes an external storage control, and the display information of the external storage control can be "My Mobile Phone". If the user needs to access pictures in the mobile phone S2 through the computer S1, the user can click the picture access control. When the computer S1 receives a click operation on the picture access control, it can display the following information: Figure 1 In the picture browsing interface S7 shown in FIG. 7 (d), the user can view the pictures that need to be accessed in the image browsing interface.

[0062] In another application scenario, the computer S1 displays Figure 2 In the case of the file display interface S6 shown in Figure (a) of FIG. 1 , the user can also access the file resources such as pictures and documents in the mobile phone S2 through the external storage control. The external storage control is equivalent to a secondary directory (the primary directory is the resource access control S5). The user can click the external storage control; when the computer S1 receives the click operation on the external storage control, it can display the following Figure 2 In the three-level directory interface S8 shown in FIG. (b), the user can select a folder to be accessed from the three-level directory interface S8 and continue clicking until the image to be accessed is accessed.

[0063] In another application scenario, when the computer displays Figure 3 In the case of the first application interface S4 of the file resource management application shown in FIG. (a), if the user clicks the resource access control S5 in the first application interface S4, and a problem occurs in the connection between the computer S1 and the mobile phone S2, such as a disconnection or a poor connection, then after the computer S1 receives the click operation on the resource access control S5, the computer S1 may display the following Figure 3 The prompt interface S9 shown in Figure (b) displays "Connection failed, please try again".

[0064] Please refer to Figure 4 , Figure 4 A schematic diagram of another application scenario provided by an embodiment of the present application. In another application scenario, a user can not only trigger the computer S1 to display the first application interface S4 of the file resource management application through the application identifier S3 of the file resource management application from the desktop of the computer S1, but also can trigger it through other methods, such as the user can trigger it through the computer housekeeper application. For example, when the computer S1 displays Figure 4In the case of the second application interface S10 of the computer manager application shown in FIG. (a), the user can click the "storage sharing" control in the second application interface S10, and when the computer S1 receives the click operation on the storage sharing control, the computer S1 can display the following Figure 4 In (b) the first application interface S4, when the computer S1 is connected to the mobile phone S2, the first application interface S4 displays a resource access control S5.

[0065] It should be noted that, in the embodiments of the present application, only the above Figure 1-Figure 4 The application scenario shown is used as an example for illustration and does not limit the application scenario of the embodiments of the present application.

[0066] Based on the application scenario provided in the above embodiment, in order to facilitate understanding of the embodiment of the present application, the method for creating a file access space provided in the embodiment of the present application is introduced below. Please refer to Figure 5 , Figure 5 This is a flow chart of a method for creating a file access space according to an exemplary embodiment. As an example but not a limitation, the method is described by taking application to a first electronic device as an example. The method may include some or all of the following contents:

[0067] Step 501: when it is detected that a connection is established with a second electronic device, a drive letter corresponding to the file access space is determined.

[0068] It should be noted that the file access space is a space in the first electronic device for mapping the file resources of the second electronic device. The file access space may include a first mapping space and / or a second mapping space. Figure 6 The first mapping space is used to map the file resources in the database of the second electronic device, and the second mapping space is used to map the file resources in the file system of the second electronic device. Generally, the file access space can also be called a driver, which is not specifically limited in the present application embodiment.

[0069] As an example, when the first electronic device detects that a connection has been established with the second electronic device, in order to facilitate the user to access the file resources in the second electronic device through the first electronic device, the first electronic device can usually call a software development kit (SDK) interface to create a file access space. Usually, the first electronic device can first determine the resource access control corresponding to the file access space. The resource access control is the entry to access each file resource mapped to the file access space, and the control display information of the resource access control may include information such as the device name of the second electronic device and the drive letter corresponding to the file access space. Therefore, when the first electronic device establishes a connection with the second electronic device, the first electronic device can determine the drive letter corresponding to the file access space. Exemplarily, the resource access control can be as follows: Figure 1 As shown in Figure (b).

[0070] In some embodiments, when the first electronic device establishes a connection with the second electronic device, the first electronic device may randomly determine a drive letter from preset drive letters, or determine a drive letter by other means, which is not specifically limited in the embodiments of the present application.

[0071] Step 502: Determine whether the determined drive letter is occupied. If so, execute the operation of the following step 503; if not, execute the operation of the following step 504.

[0072] It should be noted that the drive letter belongs to the control display information of the resource access control, and the drive letter needs to 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, end the operation, or, if it is occupied, perform the operation of the following step 503, that is, re-determine a drive letter.

[0073] Step 503: Re-determine other drive letters and return to the operation of step 502.

[0074] It should be noted that the drive letter re-acquired by the first electronic device is different from the drive letter determined previously. For example, if the drive letter determined last time is F, the drive letter determined this time may be another 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 meets the preset standard. If yes, perform the operation of the following step 505, if no, end this operation.

[0076] It should be noted that the preset standard can be pre-set according to requirements, for example, the preset standard can be the UTF-8 encoding rule.

[0077] Step 505: Set the attributes of the file access space.

[0078] Exemplarily, the first electronic device can set the root directory attribute, access attribute, modification time, state change time and other attributes of the file access space. Among them, 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 state change time of the file access space to the time when the file access space is created.

[0079] Step 506: Determine whether the file access space includes the first mapping space. If so, execute the operation of the following step 507; if not, execute the operation of the following step 509.

[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, a creation rule is preset in the first electronic device. When the creation rule indicates the creation of a first mapping space, it is determined that the first mapping space is included in the file access space; when the creation rule does not indicate the creation of the first mapping space, it is determined that the first mapping space is not included in the file access 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] Since the database of the second electronic device can store different types of file resources, such as pictures, documents, compressed packages, applications, videos, music, etc., and in order to quickly access the file resources that need to be accessed 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, according to the type of any file resource, the file path corresponding to accessing any file resource from the first mapping space.

[0085] It should be noted that in the embodiment of the present 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, but rather achieving the mapping of file resources by establishing a corresponding relationship between the file path of the file resources in the second electronic device and the memory address of the memory in the first electronic device.

[0086] In some embodiments, the first electronic device may send a file acquisition message for a database to the second electronic device. When the second electronic device receives the file acquisition message for a database, the second electronic device may map an 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 identifier of a file resource is used to uniquely indicate the corresponding file resource. Since different types of file resources have different storage formats, the storage format of a file resource can indicate the type of the corresponding file resource. Therefore, the identifier of a file resource can be the name + format of the file resource. For example, if the file resource is a picture, the identifier of the file resource can be the name and format of the picture (1.jpg, 2.gif), etc. If the file resource is a document, the identifier of the file resource can be the name and format of the document (3.txt, 4.doc, 5.pdf), etc.

[0088] As an example, the first electronic device can set multiple folders in the first mapping space, and each folder is 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 the corresponding type. Among them, the file path of any folder and the path of the file in the any folder are the file paths of the mapped file resources in the first mapping space.

[0089] Step 508: Establish an operational correspondence between the file path of each file resource in the first mapping space and the corresponding preset access mode set.

[0090] It should be noted that each preset access mode set includes an access mode corresponding to each type of operation in the multiple operations, such as at least one of attribute query mode, read mode, write mode, delete mode, open mode, file path conversion mode, copy mode, paste mode and storage mode.

[0091] As an example, the first electronic device can randomly correspond the file path of each file resource in the first mapping space to any one of a plurality of preset access method sets. Alternatively, the first electronic device can establish an operational correspondence 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 correspond the file path of the same type of file resource in the first mapping space to the same access method set. Alternatively, the first electronic device can set the file path of the same level directory to correspond 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 the 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, in the case where the first mapping space is not included in the file access space, the first electronic device can directly perform the operation of step 509. In addition, in the case where the file access space includes the first mapping space and the second mapping space, the embodiment of the present application does not specifically limit the order in which the first electronic device maps the file resources in the database of the second electronic device and maps the file resources in the file system of the second electronic device. That is, in the case where the file access space includes the first mapping space and the second mapping space, the first electronic device can perform the operations of step 507 and step 509 at the same time, or perform the operation of step 509 after completing step 508; or, the first electronic device can first perform the operation of step 509, and then perform the operations of step 507 and step 508. Of course, in some embodiments, the file access space may include the first mapping space, but not the second mapping space, so the first electronic device will no longer perform the operation of step 509 after completing the operation of step 508.

[0095] In some embodiments, after completing the file path mapping of each file resource in the file access space, the first electronic device may display a resource access control in the application interface of the file resource management application when displaying the application interface of the file resource management application. The control display information of the resource access control may display at least one of the space size, used space size, and unused space size of the file access space in addition to the corresponding drive letter and the device name of the second electronic device. That is, at least one of the storage space size, used space size, and unused space size of the second electronic device is displayed.

[0096] As an example, after completing the file path mapping of each file resource in the file access space, when the first electronic device displays the application interface of the file resource management application, the first electronic device 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 mapped to each file resource in the second mapping space corresponds to the same preset remote access method set.

[0098] Exemplarily, each preset access mode set (including remote access mode set) is essentially a static function for implementing file access operations, including opening and closing files, reading and writing directories, etc. For ease of understanding, refer to Figure 7 An embodiment of the present application provides a file access scheme architecture diagram, in which 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 the remote access method set can be a remote file operation module, etc., wherein 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 in the second electronic device.

[0099] In some embodiments, see Figure 7 The first electronic device may also be provided with an operation distribution module, which may be associated with each preset access mode set (or each file operation module). Thus, when the operation distribution module determines the file operation module corresponding to any file path, it may send a call message to the corresponding file operation module.

[0100] In the embodiment of the present application, when a connection is established with a second electronic device, a file access space can be set, and different preset access mode sets can be set for different mapping spaces in the file access space, so that the access operation to each file resource is more targeted, and the efficiency of file access is improved. In addition, the file resources in the database are classified and mapped by file resource type, which can facilitate the subsequent rapid access to file resources by the type to which the file resources belong, thereby improving the efficiency of accessing file resources.

[0101] After establishing a file access space and mapping the file resources in the second electronic device to the file access space, the first electronic device can access the file resources in the second electronic device through the file access space. Next, the file access method provided by the embodiment of the present application is introduced by taking the access operation of querying the file attributes of the file in the first mapping space as an example. Figure 8 , Figure 8 This is a flowchart of a method for accessing a file according to an exemplary embodiment. As an example but not a limitation, the method is described by taking application to a first electronic device as an example. The method may include some or all of the following contents:

[0102] Step 801: upon receiving a query operation for a first target file, determining a file path of the first target file in a first mapping space to obtain a first file path.

[0103] As can be seen from the above, the first mapping space can be mapped with file resources in the second electronic device, that is, some file paths are established in the first mapping space, these file paths correspond to the file resources in the second electronic device, and the files indicated by different file paths in the first mapping space are different. In the embodiment of the present application, each folder and the content in the folder in the first mapping space can be referred to as a file, so the first target file may be a folder in the first mapping space, or it may be 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 according to the file location triggered by the query operation.

[0105] Step 802: Determine whether the first file path of the first target file is a root directory path. If yes, perform the operation of the following step 803; if no, perform the operation of the following step 804.

[0106] As an example, the first electronic device may determine the length of the first file path; if the length of the first file path is not a preset length, determine that the first file path is not a root directory path; if the length of the first file path is a preset length, determine that the first file path is a root directory path.

[0107] It should be noted that the preset length can be set according to the length of the root directory path, such as the preset length can be 1, etc. Among them, if the file path contains one slash, the length of the file path is determined to be 1, and if it contains two slashes, the length of the file path is determined to be 2, that is, if there are N slashes in the file path, the length of the file path is N, where N is an integer.

[0108] For example, if the first file path P1 is F: / test / xxx / and the preset length is 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 a root directory path. If the first file path P2 is F: / and the preset length is 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 a root directory path.

[0109] In some embodiments, the first electronic device may also determine in other ways, such as comparing the first file path with the root directory path, and determining that the first file path is not the root directory path when the first file path is different from the root directory path. If the first file path is the same as the root directory path, determining that the first file path is 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. And from the above, it can be seen that when creating the file access space, the first electronic device sets the attributes of the file access space, so the first electronic device can directly access the first target file through the operating kernel, that is, directly query the attribute information of the file access space through the operating kernel.

[0112] From the above, it can be seen that a file operation distribution module is provided in the first electronic device. In this way, when the first electronic device can determine that the first file path is a root directory path through the file operation distribution module, the attribute information of the file access space can be sent to the operating kernel of the first electronic device, so that the operating kernel of the first electronic device can complete the query of the attribute information of the file access space.

[0113] Step 804: Determine whether there is a target preset access mode set corresponding to the first file path in the operation correspondence relationship. If yes, execute the operation of the following step 805; if no, execute the operation of the following step 807.

[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, and the multiple file paths correspond one-to-one to the multiple preset access method sets, and each preset access method set includes an access method corresponding to the type of each operation in the multiple operations.

[0115] In some embodiments, the first electronic device may determine whether there is a first file path in the operation correspondence. If it is determined that there is a first file path in the operation correspondence, determine whether there is a target preset access mode set corresponding to the first file path in the operation correspondence.

[0116] As an example, the first electronic device may traverse multiple file paths in the operation correspondence, and when traversing to a file path that is the same as the first file path, determine that the first file path exists in the operation correspondence. When the traversal is completed and the file path that is the same as the first file path is not traversed, determine that the first file path and the target preset access method corresponding to the first file path do not exist in the operation correspondence.

[0117] Exemplarily, the operation correspondence may be as shown in the following Table 1.

[0118] Table 1

[0119] File Path Preset access method set F: / test / The first preset access mode set F: / test / xxx / Second preset access method set F: / test / xxx / tt / The third preset access method set

[0120] It should be noted that the embodiments of the present application are only described by taking the operation correspondence shown in Table 1 as an example, and do not constitute a limitation to the embodiments of the present application.

[0121] As an example, the first electronic device may also determine whether the first file path exists in the operation correspondence relationship in other ways, such as searching the first file path level by level in reverse order of the directory level to which the path belongs.

[0122] Exemplarily, the first file path is "F: / test / xxx / tt / ", and the first electronic device can first search from the operation correspondence whether there is "tt / " in the first file path, and the path "tt / " is the last level path in the file path, that is, there is no other path after the path "tt / ". In the case of "tt / ", continue to determine whether the upper level path of the file path containing the path "tt / " in the operation correspondence is "xxx / ", if the upper level path of the file path containing the path "tt / " is "xxx / ", then continue to determine whether the upper level path of the file path containing the path "xxx / tt / " in the operation correspondence is "test / ", if the upper level path of the file path containing the path "xxx / tt / " is "test / ", then continue to determine whether the upper level path of the file path containing the path "test / xxx / tt / " in the operation correspondence is "F: / ". If the upper level 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 correspondence.

[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 an access method corresponding to a type of each operation in the plurality of operations, the first electronic device can determine a query method corresponding to a 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 call the query method to query the attribute information of the first target file.

[0127] Step 807: Display the first prompt information.

[0128] It should be noted that the first prompt information is used to prompt that the file attribute of the first target file cannot be queried. And the first prompt information can appear in the form of a pop-up window, or it can be displayed in a new interface, which is similar to the above Figure 3 The prompt interface shown in Figure (b) in the figure.

[0129] It should also be noted that the embodiment of the present application is explained by taking the access operation of querying file attributes as an example. When the access operation is other operations except the opening operation, such as the access operation of deleting, copying, renaming, etc. on the first target file, the access to the first target file can also be achieved through the operations of the above steps 801-807, and the embodiment of the present application will not go into details one by one.

[0130] In an embodiment of the present application, the access method is determined for the first time based on whether the first file path is a root directory path. If the first file path is not a 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 of the file, the determined access method is more targeted, thereby improving the richness of the file access method.

[0131] Since the access operation may include multiple types of operations, among which the access method of the file opening operation is different from other types of access methods, the following takes the access operation of opening the file in the first mapping space (file opening operation) as an example to introduce the file access method provided by the embodiment of the present application. Fig. 9 , Fig. 9 This is a flowchart of a method for accessing a file according to an exemplary embodiment. As an example but not a limitation, the method is described by taking application to a first electronic device as an example. The method may include some or all of the following contents:

[0132] Step 901: upon receiving a file opening operation for a first target file, determining a file path of the first target file in a first mapping space to obtain a first file path.

[0133] It should be noted that the operation of step 901 can refer to the operation of the above-mentioned step 801, and the embodiment of the present application will not describe them one by one.

[0134] Step 902: Determine whether there is a target preset access mode set corresponding to the first file path in the operation correspondence relationship. If yes, execute the operation of the following step 903; if no, execute the operation of the following step 907.

[0135] It should be noted that the operation of step 902 can refer to the operation of the above-mentioned step 804, and the embodiment of the present application will not describe them one by one.

[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 mode set includes an access mode corresponding to a type of each operation in the plurality of operations, the first electronic device can determine an opening mode corresponding to the file opening operation in the target preset access mode set.

[0138] Step 904: Access the first target file according to the determined opening method.

[0139] In some embodiments, the first electronic device may call the opening method to open the first target file.

[0140] Step 905: Determine whether the first target file is accessed successfully. If yes, execute the operation of the following step 906; if no, execute the operation of the following step 907.

[0141] Step 906: Determine and cache the file handle corresponding to the first target file according to the target preset access mode set in which the target access mode corresponding to the first target file belongs.

[0142] It should be noted that the file handle includes an identifier indicating the target preset access mode set in which the target access mode belongs.

[0143] After the first target file is opened, the user may need to perform other access operations on the first electronic device, such as read operations, write operations, etc. If the first electronic device fails to determine the file handle corresponding to the first target file when receiving other access operations to the opened first target file, the first electronic device may repeat the operations of steps 901 to 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 the first target file is successfully accessed, the first electronic device may obtain the target preset access mode set according to the file handle when receiving other access operations to the opened first target file. In this way, there is no need to repeat the operations of steps 901 to 904.

[0144] In some embodiments, the first electronic device can obtain the file handle and identifier of the target preset access method set, as well as the address of the file handle of the target preset access method set; and determine the file handle of the target preset access method set, the address and identifier of the file handle of the target preset access method set as the context of the file handle corresponding to the first target file.

[0145] It is worth noting that since the address of the 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 information.

[0147] It should be noted that the second prompt message is used to prompt that the first target file cannot be opened. And the second prompt message can appear in the form of a pop-up window, or it can be displayed in a new interface, which is similar to the above Figure 3 The prompt interface shown in Figure (b) in the figure.

[0148] In an embodiment of the present application, when the access operation is an opening operation on a first target file, the first electronic device can determine the corresponding target access method set based on the first file path of the first target file, and open the first target file according to the corresponding opening method in the target access method set, and after the first target file is opened, when other access operations are performed on the opened first target file, in order to be able to quickly query the corresponding target preset access method set subsequently, the first electronic device can determine the file handle corresponding to the first target file, and the target preset access method set can be quickly found through the file handle, thereby improving the efficiency of determining the target preset access method set.

[0149] Since the second electronic device is connected to the first electronic device, the first electronic device can not only map the file resources in the second electronic device through the file access space, but may also map them through other methods. In this case, if the access operation is an operation to open a file, it may be impossible to open the first target file through the opening method recorded in the target preset access method set, but it needs to be opened through other fixed access methods (in other mapping methods, the file resources in the second electronic device can be accessed through this fixed access method), and the fixed access method usually has certain requirements for the file path. Therefore, when opening the first target file, the first electronic device can convert the file path. Next, taking the access operation as the operation to open a file in the first mapping space (file opening operation) as an example, the file access method provided in the embodiment of the present application is introduced. Please refer to Fig.10 , Fig.10 This is a flowchart of a method for accessing a file according to an exemplary embodiment. As an example but not a limitation, the method is described by taking application to a first electronic device as an example. The method may include some or all of the following contents:

[0150] The operations of step 1001-step 1002 can refer to the operations of the above-mentioned step 901-step 902, and the embodiments of the present application will not describe them one by one.

[0151] Step 1003: Determine whether the second file path exists according to the first file path. If yes, perform the operation of the following step 1004. If no, perform the operation of the following step 1008.

[0152] After mapping the file resources in the database of the second electronic device to the first mapping space, the first electronic device stores the file path of the file resources mapped to the first mapping space in the first mapping space. The first electronic device can call the SDK interface according to the first file path to query the second file path of the first target file in the second electronic device. Among them, the operation kernel of the first electronic device can obtain the second file path by calling the method of querying file attributes.

[0153] Exemplarily, the first file path of the first target file is "F: / Pictures / 1.jpg / ", and the corresponding second file path is " / sdcard / Picture / 1.jpg / ".

[0154] As an example, in the case where the second file path does not exist, it indicates that an error may have occurred during the mapping of the first target file. Therefore, the operation of step 1008 needs to be performed, or the first electronic device can also directly end this operation.

[0155] Step 1004: Convert the second file path into a target file path by means of path conversion.

[0156] It should be noted that the target file path is the path through which the first target file can be accessed by a preset access method, and the preset access method is the above-mentioned fixed access method.

[0157] As can be seen from the above, each preset access method set can include the access methods corresponding to the types of each operation in multiple operations, and of course, other methods can also be included, such as the path conversion method. In this way, the first electronic device can convert the second file path into a target file path through the path conversion method in the target preset access method set.

[0158] Exemplarily, the first electronic device converts the second file path " / sdcard / Picture / 1.jpg / " through the path conversion method, and the obtained target file path is "C: / user / user1 / dfs / devicel / default / sdcard / Picture / 1.jpg / ", or "user / user1 / dfs / devicel / default / sdcard / Picture / 1.jpg / ".

[0159] Exemplarily, the first electronic device may include a pass-through file operation module. In this way, when the first electronic device determines that the target preset access method set is the classified file operation module, the pass-through file operation module can convert the second file path into a target file path through the path conversion method and send the target file path to the remote file operation module. Exemplarily, see Figure 7 .

[0160] Step 1005: Open the first target file according to the target file path and the preset access method.

[0161] It should be noted that the preset access method is a method for opening a file in the remote operation module. Thus, when the remote operation module receives the target file path, it can notify the operation kernel, and the operation kernel can call the preset access method in the remote operation module to open the first target file.

[0162] Step 1006: Determine whether the first target file is accessed successfully. If yes, execute the operation of the following step 1007; if no, execute the operation of the following step 1008.

[0163] Step 1007: Cache the first file path and the second file path.

[0164] After the first target file is opened, if other access operations such as read operations or write operations are subsequently performed on the opened first target file, and the first electronic device performs other access operations such as read operations or write operations on the first target file according to the file handle, the operating kernel of the first electronic device will still frequently call the method of querying file attributes to obtain the second file path, resulting in a waste of the operating kernel. Therefore, in order to avoid repeated operations of querying the second file path, the first electronic device can cache the mapping relationship between the first file path and the second file path of the first target file. In this way, when other access operations such as read operations or write operations are subsequently performed on the opened first target file, the first electronic device can obtain the second file path from the cached mapping relationship. When the second file path does not exist in the cached mapping relationship, the SDK interface is called to query the second file path, thereby improving the performance of the operating kernel.

[0165] Since the user may open the first target file multiple times through the first electronic device, the first electronic device may also count the mapping relationship between the first file path and the second file path. When the first target file is opened, the count is increased by 1, and when the file handle is closed, the count is decreased by 1. When the count becomes 0, the mapping relationship between the first file path and the second file path is deleted from the cache.

[0166] Step 1008: Display the third prompt information.

[0167] It should be noted that the third prompt message is used to prompt that the first target file cannot be opened. And the third prompt message can also appear in the form of a pop-up window, or it can be displayed in a new interface, which is similar to the above Figure 3 The prompt interface shown in Figure (b) in the figure.

[0168] In an embodiment of the present application, when the operation within the access is an opening operation on the first target file, after determining the first file path, the second file path corresponding to the first 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 through a fixed access method according to the target file path. Since the target file path supports a fixed access method, in this way, when there are other ways to mount the second electronic device in the first electronic device, the file resources of the second electronic device can still be accessed through a fixed access method, thereby achieving compatibility of the access method.

[0169] The access methods to files include not only the above Figure 5 , Figure 8 , Fig. 9 and Fig.10 The method shown may also include other methods. Next, other file access methods provided by the embodiment of the present application are introduced. Please refer to Fig.11 , Fig.11 This is a flowchart of a method for accessing a file according to another exemplary embodiment. As an example but not a limitation, the method is described by taking application to a first electronic device as an example. The method may include part or all of the following contents:

[0170] Step 1101: when it is detected that a connection is established with a second electronic device, a file resource of the second electronic device is mapped to a first mapping space in a file access space of a first electronic device.

[0171] It should be noted that the first mapping space is used to map the file resources in the database of the second electronic device.

[0172] As an example, when the first electronic device detects that a connection has been established with the second electronic device, the operation of mapping the file resources of the second electronic device to the first mapping space in the file access space of the first electronic device includes: when the connection has been established with the second electronic device, creating a file access space, the file access space including 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; establishing an operational correspondence 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 including the access method corresponding to the type of each operation in the multiple operations. Exemplarily, the first electronic device can refer to the operations of steps 501 to 508 above for this process, and the embodiments of the present application will not be described one by one.

[0173] It is worth noting that by setting a corresponding preset access mode set for the file path of each file resource in the first mapping space, the access operation to each file resource is more targeted, thereby 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; for any file resource in the database, determining the file path corresponding to any file resource accessed from the first mapping space according to the type of any file resource. Exemplarily, the process can refer to the operation of step 507 above, and the embodiments of the present application will not be described one by one.

[0175] It is worth noting that mapping the file resource classifications in the database by file resource type can facilitate subsequent rapid access to file resources by the type to which the file resources belong, thereby improving the efficiency of accessing file resources.

[0176] In some embodiments, 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, 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, and the second target file resource is mapped to any file resource in the second mapping space.

[0177] As an example, when the file access space also includes the 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 be described one by one.

[0178] Step 1102: upon receiving a first access operation to a first target file, determining a target access mode corresponding to the first target file according to a type of the first access operation and a file path of the first target file in a first mapping space.

[0179] It should be noted that the first target file is any file in the first mapping space.

[0180] As an example, in the case of receiving a first access operation to a first target file, the first electronic device determines the target access mode corresponding to the first target file according to the type of the first access operation and the file path of the first target file in the first mapping space. The operation includes: in the case of receiving the first access operation to the first target file, determining the file path of the first target file in the first mapping space to obtain the first file path. In the case that the first file path is not a root directory path, determining the target preset access mode set corresponding to the first file path from the operation correspondence relationship, the operation correspondence relationship is used to indicate the correspondence between multiple file paths in the first mapping space and multiple preset access mode sets, the multiple file paths correspond to multiple preset access mode sets one by one, and each preset access mode set includes an access mode corresponding to each type of operation in multiple operations; in the case that the first access operation is not a file opening operation, determining the access mode corresponding to the type of access operation in the target preset access mode set as the target access mode; in the case that the first access operation is a file opening operation, determining the preset access mode as the target access mode.

[0181] It should be noted that the operation correspondence relationship may be as shown in Table 1 above.

[0182] It is worth noting that, by setting the operation correspondence, the target preset access mode set corresponding to the first file path can be quickly determined.

[0183] In some embodiments, the first electronic device can determine the target access mode not only by the above method, but also by other methods. For example, the first electronic device can also first determine the type of the first access operation. When the first access operation is not an open operation, the first electronic device can determine the first file path, and when the first file path is not a root directory file path, determine the target preset access mode set corresponding to the first file path from the operation correspondence, and determine the access mode corresponding to the type of access operation in the target preset access mode set as the target access mode. When the first access operation is an open operation, determine the first file path, and determine the target preset access mode set corresponding to the first file path from the operation correspondence, and determine the access mode corresponding to the type of access operation in the target preset access mode set as the target access mode.

[0184] In some embodiments, when the first electronic device obtains the first file path, it can determine the length of the first file path; when the length of the first file path is not a preset length, it is determined that the first file path is not a root directory path. When the length of the first file path is a preset length, it is determined that the first file path is a root directory path.

[0185] As an example, the first electronic device can determine whether the first file path is a root directory path not only by the length of the first file path, but also by other means. For example, the first electronic device can 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, it is determined that the first file path is not a root directory path. If the format of the first file path conforms to the format of the root directory path, it is determined that the first file path is a root directory path. Alternatively, the first electronic device can also compare the first file path with the root directory path. If the first file path is the same as the root directory path, it is determined that the first file path is a root directory path. If the first file path is not the same as the root directory path, it is determined that the first file path is not a root directory path.

[0186] It is worth noting that, since the length of the root directory path is fixed, whether the first file path is the root directory path is determined by the length of the first file path, so that it is possible to quickly determine whether the first file path is the root directory file path, thereby improving the efficiency and accuracy of judging 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 operating 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 relationship, and the preset access method is determined as the target access method.

[0188] It is worth noting that when the first file path is a root directory path and the first access operation is not a file open operation, there is no need to determine a preset access mode set, and the first target file can be accessed directly through the operating kernel, thereby improving the access efficiency to the root directory.

[0189] Step 1103: Access the first target file according to the target access mode.

[0190] As can be seen from the 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 target preset access method set. In the case where the target access method is an access method corresponding to the type of the first access operation determined from the target preset access method set, the first electronic device can directly call the target access method through the operating kernel to access the first target file.

[0191] In some embodiments, the target preset access method set also 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 first electronic device accesses the first target file according to the target access method, including: determining the second file path corresponding to the first file path, the second file path is the file path of the first target file in the database; converting the second file path into a target file path through a path conversion method, the target file path is a path that can access the first target file through the preset access method; opening the first target file according to the target file path and the preset access method. Exemplarily, the process can refer to the operations of the above steps 1003 to 1005, and the embodiments of the present application will not be repeated one by one.

[0192] In some embodiments, when the first access operation is a file opening 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 in which the target access method corresponding to the first target file is located, wherein the file handle includes an identifier indicating the target preset access method set in 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; and 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, write operations, etc., when the first electronic device receives other access operations to the opened first target file, if the file handle corresponding to the first target file cannot be determined, the first electronic device may repeatedly determine the first file path and the target preset access method set corresponding to the first file path. If the first electronic device determines the file handle corresponding to the first target file after the first target file is successfully accessed, then when the first electronic device receives other access operations to the opened first target file, it may obtain the target preset access method set according to the file handle.

[0194] It is worth noting that, by setting the file handle, when other access operations are subsequently performed on the first target file after opening, the corresponding target preset access mode 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. In this way, when performing other access operations such as read operations or write operations 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, the SDK interface is called to query the second file path, thereby improving the performance of the operating kernel.

[0196] In the embodiment of the present application, after the first electronic device is connected to the second electronic device, when the 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 according to the type of the first access operation on the first target file and the file path of the first target file, thus realizing cross-device access to the file. And because the access method is related to the access operation and the file path of the file, the determined access method is more targeted, and the file access method is more abundant.

[0197] The above is an introduction to the method for implementing file access in the first electronic device. Next, the changes in the interface displayed by the first electronic device during the process of implementing file access are introduced. Fig.12 , Fig.12 This is a flowchart of a method for accessing a file according to another exemplary embodiment. As an example but not a limitation, the method is described by taking application to a first electronic device as an example. The method may include part or all of the following contents:

[0198] Step 1201: When it is detected that a connection is established with a second electronic device, a trigger operation for a file resource management application of a first electronic device is received.

[0199] When a connection is detected with a second electronic device, the user may want the first electronic device to display an entry for accessing the file resources of the second electronic device. In this case, the user can trigger the file resource management application of the first electronic device, such as clicking on the application logo of the file resource management application. This scenario can be as described above. Figure 1 In this way, the first electronic device can receive a triggering operation on the file resource management application of the first electronic device.

[0200] In some embodiments, the user may also trigger the file resource management application in other ways, such as triggering the file resource management application in a third-party application. For this scenario, please refer to the above Figure 4 The application scenario shown.

[0201] Step 1202: Display the resource management application interface of the file resource management application.

[0202] It should be noted that the resource management application interface displays a resource access control for the file access space, and 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.

[0203] For example, the scenario in which the first electronic device displays the resource management application interface of the file resource management application program can refer to the above Figure 1 Figure (b) or Figure 4 The application scenario shown in Figure (b).

[0204] In some embodiments, before the first electronic device displays the resource management interface, the first electronic device may send an information acquisition request to the second electronic device through the SDK interface. When the second electronic device receives the information acquisition request, it may send the usage of the storage space to the first electronic device, and the usage of the storage space includes the size of the used space, the size of the unused space, and the total size of the storage space in the storage space of the second electronic device. After receiving the usage of the storage space, the first electronic device may display the resource management interface in combination with the information determined when creating the file access space.

[0205] Step 1203: upon receiving a trigger operation on a resource access control, displaying a file display interface.

[0206] It should be noted that the file display interface includes a classification view and an external storage control. The classification view includes multiple file access controls, each of which is an entry for accessing file resources of a corresponding file type mapped to the first mapping space, and the external storage control is an entry for accessing each file resource mapped to the second mapping space. For example, the application scenario can refer to the above Figure 1 The application scenario shown in Figure (c).

[0207] In some embodiments, the first electronic device receiving a trigger operation on a resource access control is equivalent to the first electronic device receiving an opening operation on a root directory. The first electronic device can determine the target preset access method set corresponding to the root directory path in the manner of the above embodiment, 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 multiple file access controls in a classification view, each of the multiple file access controls is equivalent to the first target file in the above embodiment. Therefore, the operation of the first electronic device accessing any file access control is no longer described one by one in the embodiment of the present application.

[0209] In some embodiments, since the file path mapped to each file resource 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 an embodiment of the present application, after the first electronic device establishes a connection with the second electronic device, when the 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 on the first target file and the file path of the first target file, thereby achieving cross-device access to the file. And because the access method is related to the access operation and the file path of the file, the determined access method is more targeted, and the file access method is more abundant. In addition, since multiple file access controls can be displayed in the classification view, each file access control is an entry for accessing the file resource mapped to the corresponding file type in the first mapping space, so that the user can quickly find the required file resource by the file type, thereby improving the efficiency of file resource search.

[0211] After explaining in detail the file access method provided in the embodiment of the present application, the electronic device involved in the embodiment of the present application is explained.

[0212] As an example, the method can be applied to an electronic device that can be connected to other electronic devices. As an example and not a limitation, the first electronic device can be, but is not limited to, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, a vehicle-mounted device, an ultra-mobile personal computer (UMPC), a netbook, etc. The second electronic device can be a personal digital assistant (PDA), a mobile phone, a smart watch, etc., which is not limited in the embodiments of the present application.

[0213] Fig.13 is a schematic diagram of a structure of a first electronic device provided in an embodiment of the present application. The first electronic device may be Fig.13 The electronic device shown in . Fig.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] Processor 201 may be a microprocessor (including a central processing unit (CPU) etc.), an application-specific integrated circuit (ASIC), or may be one or more integrated circuits for controlling the execution of the program of the present application.

[0215] The communication bus 202 may include a pathway for transmitting information between the above-mentioned components.

[0216] The memory 203 may be a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compressed optical disc, a laser disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is 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] The communication interface 204 uses any transceiver or other device for communicating 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 an embodiment, the processor 201 may include one or more CPUs, such as Fig.13 CPU0 and CPU1 are shown in the figure.

[0219] In a specific implementation, as an embodiment, the first electronic device may include multiple processors, such as Fig.13 201 and processor 205 shown in FIG. Each of these processors may be a single-core processor or a multi-core processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0220] In a specific implementation, as an embodiment, the first electronic device may further include an output device and an input device. The output device communicates with the processor 201 and may display information in a variety of 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. The input device communicates with the processor 201 and may receive user input in a variety of ways. For example, the input device may be a mouse, a keyboard, a touch screen device, or a sensor device.

[0221] The first electronic device mentioned above may be a general first electronic device or a dedicated first electronic device. In a specific implementation, the first electronic device may be a desktop computer, a portable computer, a network server, a palm computer, a mobile phone, a tablet computer, a wireless terminal device, a communication device or an embedded device. The embodiment of the present application does not limit the type of the first electronic device.

[0222] The memory 203 is used to store the program code 210 for executing the solution of the present application, and the processor 201 is used to execute the program code 210 stored in the memory 203. The first electronic device can implement the file access method provided by the above embodiment through the processor 201 and the program code 210 in the memory 203.

[0223] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of 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, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (such as: coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (such as: infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital versatile disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)).

[0224] The above are optional embodiments provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the technical scope disclosed in the present application shall be included in the protection scope of the present application.

Claims

1. A method for accessing files. It is characterized in that Applied in a first electronic device, the method includes: When it is detected that a connection is established with a second electronic device, mapping a file resource of the second electronic device to a first mapping space in the file access space of the first electronic device, the first mapping space being used to map a file resource in a database of the second electronic device; upon receiving a first access operation to a first target file, determining a target access mode corresponding to the first target file according to a type of the first access operation and a file path of the first target file in the first mapping space, the first target file being any file in the first mapping space; The first target file is accessed according to the target access mode.

2. The method according to claim 1, It is characterized in that The step of mapping the file resources of the second electronic device to the first mapping space in the file access space of the first electronic device upon detecting that the connection is established with the second electronic device comprises: In case of detecting that a connection is established with the second electronic device, creating the file access space, wherein the file access space includes the first mapping space; According to the type of each file resource in the database, mapping a file path corresponding to each file resource in the first mapping space; An operation correspondence relationship 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 including an access method corresponding to each type of operation in the multiple operations.

3. The method according to claim 2, It is characterized in that 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; For any file resource in the database, a file path corresponding to the any file resource is determined for accessing the any file resource from the first mapping space according to the type of the any file resource.

4. The method according to any one of claims 1 to 3, It is characterized in that 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, 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, and the second target file resource is mapped to any file resource in the second mapping space.

5. The method according to any one of claims 1 to 4, It is characterized in that The step of, upon receiving a first access operation to a first target file, determining a target access mode corresponding to the first target file according to a type of the first access operation and a file path of the first target file in the first mapping space, includes: In case of receiving a first access operation to the first target file, determining a file path of the first target file in the first mapping space to obtain a first file path; In the case where the first file path is not a root directory path, determining a target preset access method set corresponding to the first file path from an operation correspondence relationship, the operation correspondence relationship being used to indicate a correspondence relationship between a plurality of file paths in the first mapping space and a plurality of preset access method sets, the plurality of file paths corresponding to the plurality of preset access method sets one-to-one, and each preset access method set including an access method corresponding to a type of each operation in a plurality of operations; In a case where the first access operation is not the file opening operation, determining the access mode corresponding to the type of the access operation in the target preset access mode set as the target access mode; In the case where the first access operation is the file opening operation, a preset access mode is determined as the target access mode.

6. The method according to claim 5, It is characterized in that The target preset access mode set also includes a path conversion mode, the first access operation is a file opening operation, and the target access mode is a preset access mode; The step of accessing the first target file according to the target access mode includes: Determine a second file path corresponding to the first file path, where the second file path is a file path of the first target file in the database; Converting the second file path into a target file path by using the path conversion method, wherein the target file path is a path that can access the first target file by using the preset access method; Open the first target file according to the target file path and the preset access mode.

7. The method according to claim 5, It is characterized in that Before determining the target preset access mode set corresponding to the first file path from the operation correspondence relationship when the first file path is not a root directory path, the method further includes: Determining the length of the first file path; When 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.

8. The method according to claim 5 or 7, It is characterized in that The step of determining the file path of the first target file in the first mapping space upon receiving the first access operation to the first target file, and obtaining the first file path, further comprises: When the first file path is the root directory path and the first access operation is not the file opening operation, accessing the first target file 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, a target preset access method set corresponding to the first file path is determined from the operation correspondence relationship, and the preset access method is determined as the target access method.

9. The method according to claim 1, It is characterized in that The first access operation is a file opening operation; After accessing the first target file according to the target access mode, the method further includes: In the case where the first target file is accessed successfully, a file handle corresponding to the first target file is determined according to a target preset access method set in which a target access method corresponding to the first target file is located, wherein the file handle includes an identifier indicating the target preset access method set in which the target access method is located, and the target preset access method set is a preset access method set corresponding to a file path of the first target file in the first mapping space; When receiving a second access operation to the first target file, obtaining the target preset access mode set according to 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.

10. The method according to any one of claims 1 to 9, It is characterized in that The method further comprises: In case of detecting that a connection is established with the second electronic device, receiving a trigger operation for a file resource management application of the first electronic device; Displaying a resource management application interface of the file resource management application, wherein the resource management application interface displays a resource access control of the file access space, and the control display information of the resource access control includes a device name of the second electronic device, a size of used space and a size of unused space in a storage space of the second electronic device, and a drive letter corresponding to the file access space; Upon receiving a trigger operation on the resource access control, a file display interface is displayed, wherein the file display interface includes a classification view and an external storage control, wherein the classification view includes multiple file access controls, each file access control is an entry for accessing file resources of a corresponding file type mapped to the first mapping space, and the external storage control is an entry for accessing each file resource mapped to the second mapping space.

11. An electronic device, It is characterized in that The structure of the electronic device includes a processor and a memory; The memory is used to store a program that supports the electronic device to execute the method according to any one of claims 1 to 10.

12. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Terminal and file access method therefor

    CN103748565A

  • File viewing method, electronic device and file viewer

    CN106294843A

  • File access method for mobile terminal and mobile terminal

    CN110865981A

  • File access method, communication system and electronic equipment

    CN115114235A

  • Bridge file system and recording medium

    JP2004030232A