Disclosure of Invention
The embodiment of the invention provides a file path processing method and device, which solve the technical problem of complex search caused by searching files through a relative path based on the files and traversing all contacts in a deep path once when the files are searched in the deep path.
The file path processing method provided by the embodiment of the invention comprises the following steps:
extracting the file name and the relative path of the acquired new file;
generating a vpath (virtual path) which does not contain root directory information and corresponds to the file name according to the relative path;
and storing the generated information of the vpath and the new file to a database.
Preferably, in the above file path processing method, generating a vpath corresponding to the file name and not including root directory information according to the relative path specifically includes:
and judging whether the relative path directly belongs to a root directory, if so, generating the vpath as a direct reference form of the new file, and if not, generating the vpath as a path reference form of the new file.
Preferably, in the above file path processing method, the direct reference is in the form of a delimiter + the file name.
Preferably, in the above file path processing method, the path refers to a form of a delimiter + a path + the file name, where the path is a relative path under the root directory.
Preferably, in the file path processing method, after saving the generated vpath and the information of the new file in a database, the method further includes:
and inquiring the new file according to a preset search mode based on the vpath.
Preferably, in the file path processing method, querying the new file according to a preset search mode based on the vpath specifically includes:
acquiring an inquiry instruction for inquiring the new file;
extracting file information which comprises the vpath and corresponds to the new file;
and directly positioning the new file according to the path based on the vpath.
An embodiment of the present invention provides a file path processing apparatus, including:
the extracting unit is used for extracting the file name and the relative path of the acquired new file;
a generating unit, configured to generate a vpath that does not include root directory information and corresponds to the file name according to the relative path;
and the storage unit is used for storing the generated information of the vpath and the new file to a database.
Preferably, in the above file path processing apparatus, the generating unit specifically includes:
the judging subunit is used for judging whether the relative path directly belongs to the root directory, if so, triggering the first generating subunit, and if not, triggering the second generating subunit;
the first generating subunit is configured to generate the vpath in a direct reference form of the new file;
and the second generating subunit is configured to generate the vpath in a path reference form of the new file.
Preferably, in the above file path processing apparatus, the direct reference is in the form of a delimiter + the file name;
the path refers to a form of a delimiter + a path + the filename, wherein the path is a relative path under the root directory.
Preferably, in the above-mentioned file path processing apparatus, the file path processing apparatus further includes:
the query unit is used for querying the new file according to a preset search mode based on the vpath;
wherein, the query unit specifically includes:
the obtaining subunit is used for obtaining a query instruction for querying the new file;
the extracting subunit is used for extracting the file information which comprises the vpath and corresponds to the new file;
and the positioning subunit is used for directly positioning the new file according to the path based on the vpath.
According to the technical scheme, the embodiment of the invention has the following advantages:
the embodiment of the invention provides a file path processing method and a device, wherein the processing method comprises the following steps: extracting the file name and the relative path of the acquired new file; generating a vpath which corresponds to the file name and does not contain root directory information according to the relative path; and saving the generated vpath and the information of the new file to a database. In the embodiment, the vpath which corresponds to the file name and does not contain the root directory information is generated according to the relative path, so that the root directory information contained in the full path is avoided in the full path, and the design that the required file can be quickly positioned by calling the relative path when the required file needs to be searched through searching the relative path based on the retrieval of the file relative path is solved.
Detailed Description
The embodiment of the invention provides a file path processing method and device, which solve the technical problem of complex search caused by searching files through a relative path based on the files and traversing all contacts in a deep path once when the files are searched in the deep path.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, an embodiment of a file path processing method according to an embodiment of the present invention includes:
101. extracting the file name and the relative path of the acquired new file;
in this embodiment, when a user creates a new file in a network disk or a network disk based on a cloud technology, a new path needs to be processed on the new file, and first, a file name and a relative path of the new file need to be extracted.
102. Generating a vpath which corresponds to the file name and does not contain root directory information according to the relative path;
after the file name and the relative path of the newly-created file are extracted, a vpath which does not include root directory information and corresponds to the file name needs to be generated according to the relative path, and it should be noted that a specific generation process of the vpath which does not include root directory information and corresponds to the file name according to the relative path will be described in detail in the following embodiments, and details are not repeated here.
103. And saving the generated vpath and the information of the new file to a database.
After a vpath corresponding to a file name and not including root directory information is generated according to a relative path, the generated vpath and information of a new file need to be saved in a database, and it can be understood that the database may be a local server database or a database in a cloud server, which is not specifically limited herein.
In the embodiment, the vpath which corresponds to the file name and does not contain the root directory information is generated according to the relative path, so that the root directory information contained in the full path is avoided in the full path, and the design that the required file can be quickly positioned by calling the relative path when the required file needs to be searched through searching the relative path based on the retrieval of the file relative path is solved.
In the above, a process of the file path processing method is described in detail, and in the following, a process of generating a vpath corresponding to a file name and not including root directory information is described in detail, referring to fig. 2, an embodiment of the file path processing method provided in the embodiment of the present invention includes:
201. extracting the file name and the relative path of the acquired new file;
in this embodiment, when a user creates a new file in a network disk or a network disk based on a cloud technology, a new path needs to be processed on the new file, and first, a file name and a relative path of the new file need to be extracted.
202. Judging whether the relative path directly belongs to the root directory, if so, executing step 203, otherwise, executing step 204;
after extracting the file name and the relative path of the acquired new file, it is necessary to determine whether the relative path directly belongs to the root directory, if so, step 203 is executed, otherwise, step 204 is executed.
203. The generated vpath is a direct reference form of the new file;
when the relative path is determined to belong to the root directory directly, the generated vpath is a direct reference form of the new file, and it should be noted that the direct reference form is a separator + a file name, and the separator may be a slash commonly used in the operating system to represent a parameter of a separation command line, such as "/".
204. The generated vpath is a path reference form of the new file;
when it is determined that the relative path does not directly belong to the root directory, the generated vpath is a path reference form of the new file, and it should be noted that the path reference form is a separator + path + file name, where the path is a relative path under the root directory, and the separator may be a slash, such as "/", which is usually used in an operating system to indicate a parameter of a separation command line.
205. And saving the generated vpath and the information of the new file to a database.
After the vpath generated in step 203 is in the direct reference form of the new file and the vpath generated in step 204 is in the path reference form of the new file, the information of the vpath and the new file needs to be saved in a database, which can be understood as the database in the local server, or can be a database in the cloud server, and is not specifically limited here.
In this embodiment, by determining whether the relative path directly belongs to the root directory and performing processing corresponding to the determination result, the full path is specifically implemented without including root directory information in the full path, and a design that a desired file can be quickly located by calling the relative path when the desired file needs to be searched through retrieving the relative path based on the file is solved.
In the above, a process of generating a vpath corresponding to a file name and not including root directory information is described in detail, and in the following, a process of querying an attached file according to a preset search mode based on the vpath is described in detail, referring to fig. 3, an embodiment of a file path processing method provided in an embodiment of the present invention includes:
301. extracting the file name and the relative path of the acquired new file;
in this embodiment, when a user creates a new file in a network disk or a network disk based on a cloud technology, a new path needs to be processed on the new file, and first, a file name and a relative path of the new file need to be extracted.
302. Judging whether the relative path directly belongs to the root directory, if so, executing a step 303, otherwise, executing a step 304;
after extracting the file name and the relative path of the acquired new file, it is necessary to determine whether the relative path directly belongs to the root directory, if so, execute step 303, otherwise execute step 304.
303. The generated vpath is a direct reference form of the new file;
when the relative path is determined to belong to the root directory directly, the generated vpath is a direct reference form of the new file, and it should be noted that the direct reference form is a separator + a file name, and the separator may be a slash commonly used in the operating system to represent a parameter of a separation command line, such as "/".
304. The generated vpath is a path reference form of the new file;
when it is determined that the relative path does not directly belong to the root directory, the generated vpath is a path reference form of the new file, and it should be noted that the path reference form is a separator + path + file name, where the path is a relative path under the root directory, and the separator may be a slash, such as "/", which is usually used in an operating system to indicate a parameter of a separation command line.
305. Storing the generated vpath and the information of the new file to a database;
after the vpath generated in step 303 is in the direct reference form of the new file and the vpath generated in step 304 is in the path reference form of the new file, the information of the vpath and the new file needs to be saved in a database.
306. Inquiring the new file according to a preset search mode based on vpath;
after the generated vpath and the information of the new file are stored in the database, the vpath and the new file generated corresponding to the vpath need to be stored, for example, when there are too many files in the network disk and the new file needs to be quickly located and searched, the new file can be queried according to a preset search mode based on the vpath.
It should be noted that, the querying the new file according to the preset search mode based on the vpath specifically includes the steps shown in fig. 4:
401. acquiring an inquiry instruction for inquiring the new file;
in this embodiment, when the new file needs to be quickly located and searched, a query instruction for querying the new file needs to be obtained, and it can be understood that the query instruction may be triggered by a user on a mobile terminal.
402. Extracting file information which comprises vpath and corresponds to the new file;
after the query instruction for querying the new file is obtained, file information that includes the vpath and corresponds to the new file needs to be extracted, it should be understood that the file information may be a file name or a keyword in the file, and a mapping relationship is established between the file information and the vpath, and it should be noted that the vpath may be the vpath generated in step 303 or 304.
403. And directly positioning the new file according to the path based on the vpath.
When the file information which comprises the vpath and corresponds to the new file is extracted, the new file needs to be directly positioned according to the path based on the vpath.
In this embodiment, by determining whether the relative path directly belongs to the root directory and performing processing corresponding to the determination result, the full path is specifically implemented without including root directory information in the full path, and the technical problem of complex search caused by searching the required file through the relative path based on the file is solved, so that the required file can be quickly located by calling the relative path when the required file needs to be searched, if the file is in the deep path, the file needs to be searched by traversing all contacts in the deep path once when the file is searched, and meanwhile, the design of querying a new file according to a preset search mode based on vpath further avoids the technical problem of complex search.
Referring to fig. 5, an embodiment of a file path processing apparatus according to the present invention includes:
an extracting unit 501, configured to extract a filename and a relative path of the acquired new file;
a generating unit 502, configured to generate a vpath that does not include root directory information and corresponds to the file name according to the relative path;
and a storage unit 503, configured to save the generated vpath and information of the new file to a database.
In this embodiment, the generation unit 502 generates the vpath which does not include the root directory information and corresponds to the file name according to the relative path, so that the full path is free from including the root directory information in the full path, and the design that the required file can be quickly located by calling the relative path when the required file needs to be searched through searching the relative path based on retrieving the relative path of the file is solved.
In the above, the units of the document path processing apparatus are described in detail, and in the following, the sub-units of the generating unit are described in detail, referring to fig. 6, another embodiment of the document path processing apparatus provided in the embodiment of the present invention includes:
an extracting unit 601, configured to extract a filename and a relative path of the acquired new file;
a generating unit 602, configured to generate a vpath that does not include root directory information and corresponds to the file name according to the relative path;
further, the generating unit 602 may further include:
a determining subunit 6021, configured to determine whether the relative path directly belongs to the root directory, if yes, trigger the first generating subunit 6022, and if not, trigger the second generating subunit 6023;
a first generation subunit 6022, configured to generate vpath in a direct reference form of the new file, where the direct reference form is a separator and a file name;
the second generating subunit 6023 is configured to generate vpath as a path reference form of the new file, where the path reference form is a delimiter + a path + a file name, and the path is a relative path in the root directory.
And a storage unit 603, configured to save the generated vpath and information of the new file to a database.
In this embodiment, the judgment subunit 6021 judges whether the relative path directly belongs to the root directory, and triggers the first generation subunit 6022 or the second generation subunit 6023 to perform the processing corresponding to the judgment result, so that the root directory information included in the full path is avoided in the full path, and the design that the required file can be quickly located by calling the relative path when the required file needs to be searched by retrieving the relative path based on the file is solved.
In the above, a detailed description is made of the sub-units of the generating unit, and in the following, referring to fig. 7, a detailed description is made of additional units, and another embodiment of the file path processing apparatus provided in the embodiment of the present invention includes:
an extracting unit 701, configured to extract a filename and a relative path of the acquired new file;
a generating unit 702, configured to generate a vpath that does not include root directory information and corresponds to the file name according to the relative path;
further, the generating unit 702 may further include:
a determining subunit 7021, configured to determine whether the relative path directly belongs to the root directory, if yes, trigger the first generating subunit 6022, and if not, trigger the second generating subunit 7023;
a first generation subunit 6022, configured to generate vpath in a direct reference form of the new file, where the direct reference form is a separator and a file name;
the second generating subunit 7023 is configured to generate vpath as a path reference form of the new file, where the path reference form is a delimiter + a path + a file name, and the path is a relative path under the root directory.
A storage unit 703, configured to store the generated vpath and information of the new file in a database;
a query unit 704, configured to query the new file according to a preset search mode based on vpath;
the querying unit 704 specifically includes:
an obtaining subunit 7041, configured to obtain an inquiry instruction for inquiring the new file;
an extracting subunit 7042, configured to extract file information that includes vpath and corresponds to the new file;
and the positioning subunit 7043 is configured to directly position the new file according to the path based on vpath.
In this embodiment, the determining subunit 7021 determines whether the relative path directly belongs to the root directory, and triggers the first generating subunit 6022 or the second generating subunit 7023 to perform the processing corresponding to the determination result, so that the full path is free from the root directory information included in the full path, and the technical problem of complex search caused by searching through the relative path based on the file is solved, so that the required file can be quickly located by calling the relative path when the required file needs to be searched, and if the file is in the deep path, the file needs to be searched by traversing all the contacts in the deep path once when the file is searched, and meanwhile, the querying unit 704 queries the newly-created file according to the preset search mode based on vpath, thereby further avoiding the technical problem of complex search.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.