Method for generating project catalog, electronic device and computer storage medium

By obtaining and removing the public path of the file library, retaining the file category path, and generating a new project directory structure, the problem of inconvenient file access in the project directory is solved, and clear classification storage and efficient management of files are achieved.

CN116361247BActive Publication Date: 2025-09-12MIDEA GROUP CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111626918.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2025-09-12
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

The existing technology has a problem of inconvenience in accessing files in the project directory, especially the mixed management of third-party codes, which makes access difficult.

Method used

By reading the file paths in the file library, the longest common path of each type of file is obtained, the path before the file library name is identified as the shortest common path, the file category path is retained after removing the common path, and the remaining path is used to classify and save in the project directory.

Benefits of technology

It realizes a clear storage location for files, facilitates access through the project directory, and improves file management efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116361247B_ABST
    Figure CN116361247B_ABST
Patent Text Reader

Abstract

The present application discloses a method for generating a project directory, an electronic device, and a computer storage medium. The generation method includes: reading the file path of each file in a file library to obtain the longest common path of each type of file; identifying the file library name in the longest common path of each type of file from front to back, and using the path before the file library name as the shortest common path of each type of file; obtaining the remaining path after subtracting the shortest common path of each file from the file path of each file; and adding the remaining path of each file to the project directory corresponding to the file library to generate a new path. The project directory generated by the present application can classify and place various types of files for easy reference.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of program development management, and in particular to a method for generating a project directory, electronic equipment and computer storage medium. Background Art

[0002] In system development, code management is usually required. Self-developed code can be managed and stored according to its own development project directory, while third-party code needs to be processed to build a new project directory.

[0003] In the current method of constructing a project directory, all types of files are placed in one directory and displayed mixedly, which is not convenient for file browsing. Summary of the Invention

[0004] The present application provides a method for generating a project directory, an electronic device, and a computer storage medium to solve the problem in the prior art that the project directory is inconvenient for file retrieval.

[0005] To solve the above technical problems, the present application proposes a method for generating a project directory, including: reading the file path of each file in the file library to obtain the longest common path of each type of file; identifying the file library name in the longest common path of each type of file from front to back, and taking the path before the file library name as the shortest common path of each type of file; obtaining the remaining path after subtracting the shortest common path of each file from the file path of each file; and adding the remaining path of each file to the project directory corresponding to the file library to generate a new path.

[0006] In one embodiment, the file path of each file includes the file library name and the file category name in order from front to back.

[0007] In one embodiment, adding the remaining paths of each file to the project directory corresponding to the file library includes: adding the remaining paths of each file to the project directory corresponding to the file library, and generating a folder with a file category name under the project directory.

[0008] In one embodiment, the file library includes code class files and resource class files.

[0009] In one embodiment, the generation method further includes: creating a project configuration folder under the project directory, and placing the project configuration file of the file library in the project configuration folder.

[0010] In one embodiment, the generation method further includes: loading the file library, obtaining a file library name of the file library; and creating the project directory with the file library name based on a preset project structure.

[0011] In one embodiment, the preset project structure is an Xcode project structure, and the generation method is implemented by a Cocoapods tool.

[0012] In one embodiment, reading the file path of each file in the file library includes: loading the local relative path of the file library to obtain the file path of each file in the file library.

[0013] To solve the above technical problems, the present application proposes an electronic device, which includes a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to implement the above method.

[0014] In order to solve the above technical problems, the present application also proposes a computer storage medium, where the computer storage device is used to store a computer program, and the computer program can be executed to implement the above method.

[0015] This application is used to manage the file library and generate the project directory corresponding to the file library. First, the file path of each file in the file library is read, and the file paths of all files are compared and analyzed to obtain the longest common path of each type of file. The file library name in the longest common path of each type of file is identified from the front to the back, and the path before the file library name is used as the shortest common path of each type of file. The remaining path after subtracting the shortest common path of each file from the file path of each file is obtained. The path of each file removes the common path before the file library name, retaining the path of the file category, and then the remaining path of each file is added to the project directory corresponding to the file library. When generating a new path, the remaining path of the file can be used to classify and save the file. This makes the storage location of the file clearer and convenient for reference through the project directory. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0017] Figure 1 This is a flow chart of an embodiment of a method for generating a project directory of the present application;

[0018] Figure 2 It is a schematic diagram of the structure of the project directory generated by the existing method;

[0019] Figure 3 It is a schematic diagram of the structure of the project directory generated by the application method;

[0020] Figure 4 This is a structural diagram of an embodiment of an electronic device of the present application;

[0021] Figure 5 It is a structural diagram of an embodiment of the computer storage medium of the present application. DETAILED DESCRIPTION

[0022] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative work are within the scope of protection of this application. In addition, unless otherwise specified (for example, "or in addition" or "or in an alternative"), the term "or" as used herein refers to a non-exclusive "or" (that is, "and / or"). Furthermore, the various embodiments described herein are not necessarily mutually exclusive, because some embodiments can be combined with one or more other embodiments to form new embodiments.

[0023] This application is used to construct a project directory for files in a file library, making it easier to access files in the file library. This application can be applied to the management of third-party file libraries. For example, when a third-party file library is applied to this system, it can be constructed as a project directory in this system. In this process, the file path of the third-party file library itself can be used to construct the project directory of the file.

[0024] For example, you can replace the public path in the file with the path in the project directory, and then you can introduce the file library into the project directory. Figure 1 , Figure 1 The figure is a flow chart of an embodiment of a method for generating a project directory of the present application. The method for generating a project directory of the embodiment specifically includes the following steps.

[0025] S11: Read the file paths of each file in the file library and obtain the longest common path of each type of file.

[0026] This embodiment is used to establish a project directory for a third-party file library for easier management. The file library stores various files, each of which has a file path within the file library, which is its location within the file library. Each type of file is stored in a different folder within the file library, meaning that each type of file has the same location within the file library.

[0027] Every file has a corresponding file path in the file library. The shared path between each file and every other file is the portion of their file paths that are identical. The longest shared path is the entire shared portion of the file paths. The portion of the path after the longest shared path is the portion that is different. Therefore, for all files in the file library, all files are stored in the file library, and the longest shared path for all files is the path to the file library. For each file type, each type is stored in the folder corresponding to that type. Therefore, the longest shared path for each type of file is the path to the folder in the file library.

[0028] Specifically, when the file path needs to be read in this step, the local relative path of the file library, that is, the storage location of each file in the file library, is loaded to obtain the file path of each file in the file library.

[0029] S12: Identify the file library name of the longest common path for each type of file from front to back, and use the path before the file library name as the shortest common path for each type of file.

[0030] Based on the characteristics of the file path of this application, the file path is from the largest storage location to the smallest storage location from the front to the back. For each file, its file path includes the file library name and the file category name from the front to the back.

[0031] The longest public path for each file type is the path to the folder containing that file type, and therefore includes both the file repository name and the file category name. Therefore, in step S12, the file repository name in the longest public path for each file type is identified from front to back, and the path before the file repository is used as the shortest public path for that file type. This shortest public path does not include the file category name.

[0032] S13: Obtain the remaining path after subtracting the shortest common path of the files from the file path of each file.

[0033] Subtract the shortest public path of each file from its file path to obtain the remaining path. Since the shortest public path does not include the file category name, the remaining path includes the file category name of the file, but does not include the file library name and the previous public path.

[0034] S14: Add the remaining paths of each file to the project directory corresponding to the file library to generate a new path.

[0035] By adding the remaining paths of each file to the corresponding project directory in the file library, you can categorize and store various files. Based on the remaining paths, folders with file categories are automatically generated in the project directory, and the files corresponding to these categories are stored in the folders in the project directory.

[0036] In this embodiment, the common path is removed to reconstruct the project directory. If step S12 is not performed and the longest common path is directly removed from the file paths of each file, the file category name will not exist in the remaining path of each file, which will result in various types of files being mixed together in the project directory, making it inconvenient to view.

[0037] In this embodiment, step S12 is executed, and the file category names are retained in the remaining path. Therefore, when added to the project directory, various types of files can be classified and placed for easy reference.

[0038] In addition, in this embodiment, when starting to manage a third-party file library, it is necessary to load the file library to obtain the file library name of the file library, and then create a project directory with the file library name based on the preset project structure, and add the remaining path to the project directory to achieve management corresponding to the file library.

[0039] The method for generating a project directory in this embodiment can be applied to an iOS development and management system. The method for generating a project directory can be based on the Cocoapods tool, a command-line tool that helps iOS developers manage third-party code, namely third-party file libraries, which can be called pod libraries. The script provided by the Cocoapods tool can be used to load third-party file libraries remotely or from local relative paths. The project directory it creates is constructed based on the Xcode project structure.

[0040] To manage project directories on iOS, first install the Cocoapods tool. Then, create a Podfile in the root directory of your main development project. This file contains the name and version of the third-party library. Finally, execute the pod install command in the root directory of your main project to configure the project directory for the third-party library.

[0041] When the pod install command is executed, each step of the above generation method is executed. In step S11, the code class files and resource class files in the third-party file library are read to obtain the longest common path of each type of file.

[0042] Specifically, read the code file path of the code class file and calculate its longest common path. For example, if there are two code class files with paths of / xxx / xxx / podname / classes / view / file1.m and / xxx / xxx / podname / classes / view / cells / file2.m, then their longest common path is / xxx / xxx / podname / classesview.

[0043] Read the file path of the resource class file and calculate its longest common path. For example, if there are two file paths, / xxx / xxx / podname / assets / img1.png and / xxx / xxx / podname / assets / img2.png, then their longest common path is / xxx / xxx / podname / assets.

[0044] In step S12, the shortest path is determined. Specifically, the file library name in the longest public path is identified from front to back, and the path before the file library name is intercepted as the shortest public path. Currently, the shortest public path for code files and resource files is / xxx / xxx / podname.

[0045] In step S13 and step S14, the file path of the file minus the shortest public path is added to the folder corresponding to the file library, and the folder has the file library name.

[0046] The remaining path of the above code class file file1.m is / classes / view / file1.m. After adding it to the project structure, the path is: podname->classes->view->file1.m. The remaining path of file2.m is / classes / view / cells / file2.m. After adding it to the project structure, the path is: podname->classes->view->cells->file2.m.

[0047] The remaining path of the resource file img1.png is / assets / img1.png. After adding it to the project structure, the path becomes: podname->assets->img1.png. The remaining path of file2.m is / assets / img2.png. After adding it to the project structure, the path becomes: podname->assets->img2.png.

[0048] Furthermore, in step S11, the Cocoapods tool reads the configuration file of the third-party file library and creates a project configuration folder in the project directory to store the project configuration file of the file library. Specifically, the configuration folders Support File and Pod are created in the folder corresponding to the file name.

[0049] Based on the above example, if the longest common path is directly subtracted, all kinds of files will be mixed and placed in the project directory, such as Figure 2 As shown, Figure 2 This is a schematic diagram of the structure of the project directory generated by the existing method. If the method of this embodiment is adopted, various types of files are placed in categories, such as Figure 3 As shown, Figure 3 It is a structural diagram of the project directory generated by the application method.

[0050] This embodiment is used to manage the file library and generate a project directory corresponding to the file library. First, the file path of each file in the file library is read, and the file paths of all files are compared and analyzed to obtain the longest common path of each type of file. The file library name in the longest common path of each type of file is identified from front to back, and the path before the file library name is used as the shortest common path of each type of file. The remaining path after subtracting the shortest common path of each file from the file path of each file is obtained. The path of each file removes the common path before the file library name, retaining the path of the file category, and then the remaining path of each file is added to the project directory corresponding to the file library. When a new path is generated, the remaining path of the file can be used to classify and save the file. This makes the storage location of the file clearer and convenient for reference through the project directory.

[0051] See also Figure 4 , Figure 4 2 is a schematic diagram of the structure of an embodiment of the electronic device 200 of the present application. The electronic device 200 of the present application includes a processor 21, which is configured to execute a computer program to implement the method of any of the above embodiments of the present application and any non-conflicting combination thereof.

[0052] The processor 21 may also be referred to as a CPU (Central Processing Unit). The processor 21 may be an integrated circuit chip having signal processing capabilities. The processor 21 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The general-purpose processor may be a microprocessor, or the processor 21 may be any conventional processor.

[0053] The electronic device 20 may further include a memory 22 for storing computer programs required for the processor 21 to run.

[0054] See also Figure 5 , Figure 5Schematic diagram of the structure of the computer storage medium in the embodiment of the present application. The computer storage medium 300 of the embodiment of the present application stores a computer program, which, when executed, implements the method provided by any embodiment of the above-mentioned method of the present application and any non-conflicting combination. Among them, the computer program can be formed into a program file and stored in the above-mentioned storage medium 300 in the form of a software product, so that a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) executes all or part of the steps of the various embodiments of the present application. The aforementioned storage medium 300 includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, or a computer, server, mobile phone, tablet and other devices.

[0055] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.

[0056] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0057] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0058] The above is only an implementation method of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for generating a project catalog, characterized in that: The generation method comprises: Read the file paths of each file in the file library to obtain the longest common path of each type of file; wherein the longest common path is all the common parts of the file paths of each type of file; Identify the file library name in the longest public path of each type of file from front to back, and use the path before the file library name as the shortest public path of each type of file; Obtain the remaining path after subtracting the shortest common path of each file from the file path of the file; Add the remaining paths of each file to the project directory corresponding to the file library to generate a new path; The file path of each file includes the file library name and the file category name in order from front to back; Adding the remaining paths of each file to the project directory corresponding to the file library includes: The remaining paths of the various files are added to the project directory corresponding to the file library, and a folder with a file category name is generated under the project directory.

2. The generation method according to claim 1, characterized in that The file library includes code class files and resource class files.

3. The generation method according to claim 1, characterized in that The generating method further comprises: A project configuration folder is created under the project directory, and the project configuration file of the file library is placed in the project configuration folder.

4. The generation method according to claim 1, characterized in that The generating method further comprises: Load the file library and obtain the file library name of the file library; The project directory with the file library name is created based on a preset project structure.

5. The generation method according to claim 4, characterized in that The preset project structure is an Xcode project structure, and the generation method is implemented by the Cocoapods tool.

6. The generation method according to claim 1, characterized in that The file path of each file in the file library is read, including: The local relative path of the file library is loaded to obtain the file path of each file in the file library.

7. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory is used to store a computer program, and the processor is used to execute the computer program to implement the method according to any one of claims 1 to 6.

8. A computer storage medium, characterized in that The computer storage medium stores a computer program, and the computer program is configured to be executed to implement the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Management device and method for recovering file path structure after disaster

    CN103713971A

  • Method and device for judging route and package name correspondences and electronic device

    CN105095521A