WO2012167742A1 - Method and apparatus for accessing resource files - Google Patents

Method and apparatus for accessing resource files Download PDF

Info

Publication number
WO2012167742A1
WO2012167742A1 PCT/CN2012/076648 CN2012076648W WO2012167742A1 WO 2012167742 A1 WO2012167742 A1 WO 2012167742A1 CN 2012076648 W CN2012076648 W CN 2012076648W WO 2012167742 A1 WO2012167742 A1 WO 2012167742A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
resource
area
name
content
Prior art date
Application number
PCT/CN2012/076648
Other languages
French (fr)
Chinese (zh)
Inventor
郑昕
孙健
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2012167742A1 publication Critical patent/WO2012167742A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation

Definitions

  • the embodiments of the present invention relate to the field of mobile terminal technologies, and in particular, to a resource file access method and device. Background technique
  • mobile terminals such as mobile phones
  • MMS multimedia, web browsing, video telephony, electronic maps and so on.
  • These functions can be implemented by running the corresponding functional modules (ie applications) on the mobile terminal.
  • the application program can be installed on the mobile terminal by: the mobile terminal obtains the installation package of the application by wired or wireless manner, runs the installation package of the application on the mobile terminal, and installs each file in the package. (such as picture/sound files, etc.) Created on the memory of the mobile terminal.
  • the embodiment of the invention provides a method and a device for accessing a resource file, which are used to solve the technical problems existing in the prior art.
  • An embodiment of the present invention provides a method for accessing a resource file, including:
  • the embodiment of the invention further provides a resource file accessing device, including:
  • a reading module configured to obtain a file name of the resource file to be accessed, and read an index area and a file name area of the resource package file according to the file name of the resource file to be accessed, where the resource package file includes an index area, a file name area and a file content area; a storage path of the storage area, obtained offset information of the resource file to be accessed from the index area; according to the storage path and the offset information, in the file
  • the content area obtains the content of the resource file to be accessed.
  • the method and device for accessing a resource file by making all the resource files into one resource package file, the resource package file is divided into an index area, a file name area, and a file content area, and the reading is stored in the file content area.
  • Path obtaining offset information of the resource file to be accessed from the index area, A large number of file opening/closing operations are saved, which improves the running speed of the mobile terminal and saves power consumption of the mobile terminal.
  • Figure la is a schematic view of an installation package provided in the prior art
  • Figure lb is a schematic diagram of the composition of the installation package in Figure la after decompression
  • FIG. 2 is a flowchart of a method for accessing a resource file according to an embodiment of the present invention
  • FIG. 3 is a flowchart of a method for accessing a resource file according to another embodiment of the present invention
  • FIG. 4 is a flowchart of a method for accessing a resource file according to another embodiment of the present invention
  • FIG. 5 is a resource file according to an embodiment of the present invention
  • FIG. 6 is a schematic structural diagram of a device for accessing a resource file according to another embodiment of the present invention.
  • FIG. 2 is a flowchart of a method for accessing a resource file according to an embodiment of the present invention. As shown in FIG. 2, the method includes:
  • Step 201 Obtain a file name of the resource file to be accessed, according to the obtained resource to be accessed.
  • the file name of the file reads the index area and the file name area of the resource package file, and the resource package file includes: an index area, a file name area, and a file content area.
  • the resource file that the program needs to access during operation can be referred to as the resource file to be accessed, and the program accesses the resource file according to the file name of the resource file to be accessed.
  • the resource file included in the program installation package in the prior art is a piece of a resource file.
  • the resource package file provided by the embodiment of the present invention is a binary file, and the binary file includes an index area for recording resource files.
  • the index area is used to save offset information of all resource files in the resource package file, and may include multiple index structures.
  • the binary file also includes a file name area for recording the file name of the resource file and a storage path of the resource file in the resource package file, and the file name area may include multiple file name structures.
  • the binary file also includes a file content area for recording the file content of the resource file, and the file content of each resource file is represented by a binary, which includes a plurality of file content structures.
  • the storage path of the resource file in the resource package file is actually a relative path, and the relative path can be understood as a path for obtaining a resource file from the root directory of the resource file, and the path refers to It is not the disk or sector of the resource file stored on the mobile phone, but the path to the resource file from the root directory of the resource file in the resource package file, so it is a relative path.
  • Step 202 Obtain a storage path of the resource file to be accessed in the file content area from the file name area, obtain offset information of the resource file to be accessed from the index area, and obtain offset information according to the storage path and the offset.
  • the resource file may not start from the first bit of data, but there is an offset, and only the offset is obtained. , in order to access the resource file from the beginning of the resource file.
  • the resource package file may further include: a file header area, The size of the index area, file name area, and file content area, and the respective offsets in the resource bundle file are recorded.
  • the method may further include: accessing a file header area of the resource package file, and obtaining a size and an offset of the index area, the file name area, and the file content area.
  • the file header area may also be used to record at least one: a length of a file header of the resource package file, a version of the resource package file, a size of the resource package file, and a total number of resource files in the resource package file.
  • the flowchart of the access method of the resource file provided by the embodiment of the present invention, as shown in FIG. 3, is provided by the embodiment of the present invention, in order to speed up the storage path and the offset information of the resource file.
  • Methods can include:
  • Step 300 Read the content recorded in the index area and the file name area in the resource package file, and establish an index table of the resource file according to the content recorded in the read index area and the file name area, where the index table includes the resource.
  • the content may include at least an offset of the resource file name recorded in the index area, a length of the resource file name, an offset of the file content of the resource file in the resource package file, and a length of the file content of the resource file, the file name The resource file name and storage path of the zone record.
  • Step 301 Obtain a file name of the resource file to be accessed, and read the index table according to the obtained file name.
  • the index table can exist in the form of a Hashmap.
  • Step 302 Obtain the content of the resource file to be accessed in the file content area according to the storage path and the offset information read in the index table.
  • the method may further include: maintaining an open state of the resource package file, so that a program of the mobile terminal or the like accesses the resource package file. This step preferably occurs after the resource bundle file has been accessed once.
  • FIG. 4 is a flowchart of a method for accessing a resource file according to another embodiment of the present invention.
  • the method uses a mobile phone video program to access a resource file as an example, and the method not only introduces a mobile phone video program client. How to access the resources needed when working on the mobile phone, and further explain how to make a resource package file for mobile video programs, how to make a hand Program installation package for the video program, how to install the mobile video program on the mobile phone, and how to uninstall the mobile video program.
  • the following is a description of the preferred order of occurrence between the various parts described above, but is not intended to limit the scope of the claimed invention. include:
  • Step 401 Create a resource package file of the mobile video program.
  • Obtaining information of all resource files required for the mobile video program wherein the information of the resource file includes: a name, a size, and a content of the resource file, where the foregoing information is saved in a local list; and the resource package is constructed according to the obtained information of the resource file.
  • the file header area structure, index area structure, file name area structure, and file content area structure of the file package the constructed file into a single binary file.
  • the constructed binary file may include structural information such as a file header area structure, an index area structure, a file name area structure, and a file content area structure.
  • the build resource package file may include but is not limited to the following structural information:
  • I file header area save the general information of the resource package file, the number of internal resource files, etc.
  • I index area save the offset information of all resource files, including multiple index structure
  • I file name area save all resource files File name and storage path, including multiple file name structures
  • I file content area which stores the binary content of all resource files, including multiple file contents.
  • Typedef struct ulong m_ JFsoType; ⁇ resource file type
  • Step 402 Create a mobile video program installation package.
  • the single binary resource package file created in step 401 is included in the program installation package, and the single binary resource package file to be produced and the program execution file (such as the file with the suffix exe) are made into a program installation package, which is reduced.
  • Step 403 Install the mobile video program on the mobile phone.
  • the installation process may include: loading a single binary resource package file and a program execution file in the program installation package to a specified location on the mobile phone, since only one resource package file, rather than multiple resource files, avoids repeated readings
  • the operation of the program installation package greatly improves the program installation speed.
  • the client installation speed can be increased by 10 to 20 times.
  • Step 404 The mobile video program starts, and the resource package file is indexed.
  • the file header area of the resource package file is read, and the size of the index area, the file name area, and the file content area are obtained from the file header area of the resource package file, and the resource is in the resource.
  • the offset within the package file According to the size and offset of the index area and the file name area, the information content in the index area is read, and the type of each resource file included in the resource package file, the offset of the resource file name, and the length of the resource file name are obtained.
  • the index table contains at least the name, size, offset, and storage path of the resource file, and hashes the index table The way the table is saved for subsequent quick indexing. Keep the resource bundle file open to effectively reduce the number of times the resource bundle file is opened and closed.
  • Step 405 The mobile video program runs to retrieve the resource file.
  • the mobile video program can retrieve the index table of the resource file established in step 404 according to the required resource file name, and find the storage path and offset position of the corresponding resource file in the resource package file, to the corresponding path. Read the required resource file at the corresponding offset location.
  • Step 406 Uninstall the mobile video program.
  • the resource package files installed to the mobile phone are all physically deleted, because the resource package file provided in the embodiment of the present invention exists in the form of a single binary file, thereby avoiding repeated deletion operations, which greatly improves the The speed at which the program is uninstalled.
  • the access method of the resource file provided by the embodiment of the present invention, by making all the resource files into one resource package file, the resource package file is divided into an index area, a file name area, and a file content area, and the storage path in the file content area is read. Obtaining the offset information of the resource file to be accessed from the index area, obtaining the content of the resource file to be accessed in the file content area according to the storage path and the offset information, thereby avoiding a large number of file opening/closing operations, and improving The running speed of the mobile terminal saves the power loss of the mobile terminal.
  • FIG. 5 is a schematic structural diagram of a device for accessing a resource file according to an embodiment of the present invention. As shown in FIG. 5, the device for accessing a resource file is used to implement the foregoing method, and the device for accessing the resource file includes: Module 501 and processor 502 are taken.
  • the reading module 501 is configured to: obtain a file name of the resource file to be accessed, and read an index area and a file name area of the resource package file according to the file name of the resource file to be accessed, where the resource package file includes an index area, The storage path of the file name area and the file, and the offset information of the resource file to be accessed is obtained from the index area, according to the storage path
  • the resource package file provided by the embodiment of the present invention is a binary file, and the binary file includes an index area for recording the type of the resource file, the offset of the file name of the resource file, the length of the resource file name, and the resource. The offset of the file's file content in the resource bundle file, and the length of the file content of the resource file.
  • the index area is used to save offset information of all resource files in the resource package file, and may include multiple index structures.
  • the binary file further includes a file name area for recording the file name of the resource file and a storage path of the resource file in the resource package file, and the file name area may include multiple file name structures.
  • the binary file also includes a file content area for recording the file content of the resource file, and the file content of each resource file is represented by a binary, which includes a plurality of file content structures.
  • the storage path of the resource file in the resource package file is actually a relative path, and the relative path can be understood as a path for obtaining a resource file from the root directory of the resource file, and the path refers to It is not the disk or sector of the resource file stored on the mobile phone, but the path to the resource file in the resource package file.
  • the path to the resource file is obtained, so it is a relative path.
  • the resource package file may further include: a file header area for recording the size of the index area, the file name area, and the file content area, and an offset within the resource package file.
  • the reading module 501 is further configured to: before reading the index area and the file name area of the resource package file according to the file name of the resource file to be accessed, accessing the file header area of the resource package file to obtain the index area and the file The size of the namespace and file content area and the offset in the resource bundle file.
  • FIG. 6 is a schematic structural diagram of a device for accessing a resource file according to another embodiment of the present invention.
  • the access device of the resource file includes not only the reading module 601 but also processing.
  • the 602, further includes: an establishing module 600, configured to read, before the reading module 601 obtains the file name of the resource file to be accessed, the content recorded in the index area and the file name area in the resource package file; The contents of the index area and the file name area record, and an index table of the resource file is created, and the index table includes the name, size, offset, and storage path of the resource file.
  • the content may include at least an offset of the resource file name recorded in the index area, a length of the resource file name, and The offset of the file content of the resource file in the resource bundle file, and the length of the file content of the resource file, the resource file name and storage path of the file name area record.
  • the reading module 601 is configured to: obtain a file name of the resource file to be accessed, and read an index table established by the establishing module 600 according to the obtained file name.
  • the processor 602 is configured to obtain the content of the resource file to be accessed in the file content area according to the storage path and the offset information read in the index table.
  • the access device for the resource file provided by the embodiment of the present invention, by making all the resource files into one resource package file, the resource package file is divided into an index area, a file name area, and a file content area, and the storage path in the file content area is read. Obtaining the offset information of the resource file to be accessed from the index area, obtaining the content of the resource file to be accessed in the file content area according to the storage path and the offset information, thereby avoiding a large number of file opening/closing operations, and improving The running speed of the mobile terminal saves the power loss of the mobile terminal.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Provided are a method and apparatus for accessing resource files. The method comprises: acquiring a file name of a resource file to be accessed and reading an index area and a file name area of a resource package file according to the file name of the resource file to be accessed, the resource package file comprising an index area, a file name area and a file content area; acquiring from the file name area a storage path of the resource file to be accessed in the file content area ; acquiring from the index area offset information about the resource file to be accessed; and acquiring content of the resource file to be accessed in the file content area according to the storage path and the offset information. The apparatus comprises: a reading module and a processor.

Description

资源文件的访问方法5 ^置 本申请要求于 2011年 7月 27日提交中国专利局、申请号为 201110211991.4. 发明名称为"资源文件的访问方法及装置 "的中国专利申请的优先权, 其全部 内容通过引用结合在本申请中。 技术领域  Access method of resource file 5 ^ This application is submitted to the Chinese Patent Office on July 27, 2011, and the application number is 201110211991.4. The priority of the Chinese patent application entitled "Access method and device for resource files", all of which The content is incorporated herein by reference. Technical field
本发明实施例涉及移动终端技术领域, 尤其涉及一种资源文件的访问方 法及装置。 背景技术  The embodiments of the present invention relate to the field of mobile terminal technologies, and in particular, to a resource file access method and device. Background technique
随着 3G ( 3rd Generation ) 网络的逐渐推广, 移动终端(如手机 )功能 越来越丰富, 如彩信、 多媒体、 网页浏览、 视频电话、 电子地图等等。 这 些功能可以通过在移动终端上运行相应的功能模块(即应用程序)来实现。 其中, 应用程序可以通过如下方式被安装到移动终端上: 移动终端通过有 线或者无线的方式获得该应用程序的安装包,在移动终端上运行该应用程 序的安装包, 将安装包内的各个文件 (如图片 /声音文件等) 创建到移动 终端的存储器上。 With the gradual promotion of 3G (3 rd Generation) networks, mobile terminals (such as mobile phones) are becoming more and more powerful, such as MMS, multimedia, web browsing, video telephony, electronic maps and so on. These functions can be implemented by running the corresponding functional modules (ie applications) on the mobile terminal. The application program can be installed on the mobile terminal by: the mobile terminal obtains the installation package of the application by wired or wireless manner, runs the installation package of the application on the mobile terminal, and installs each file in the package. (such as picture/sound files, etc.) Created on the memory of the mobile terminal.
为了能在手机上使用新的程序,一般需要安装适用于该手机的程序安 装包。 用户目前一般通过从电脑复制 /直接手机网络下载等方式获取程序 安装包后安装。 比如要将应用程序 application.exe安装到手机上, 首先获 取如图 la所示的安装包, 这个安装包是一个单独的文件, 这个单独的文 件在安装到手机上以后, 如图 lb所示的安装包解压后的组成示意图, 这 几个文件包括一个 application.exe的运行文件, 还包括多个资源文件。 那 么手机在运行 application这个应用程序时,可以访问上述多个资源文件中 的一个或多个。 在相应的应用程序运行过程中, 需要分别访问上述创建到 移动终端的各个资源文件, 进行大量的文件打开 /关闭的操作, 影响应用 程序的运行速度, 耗费移动终端的电能。 发明内容 In order to be able to use the new program on the phone, it is generally necessary to install a program installation package for the phone. Users currently generally install the program installation package by copying from the computer/direct mobile phone network download. For example, to install the application application.exe to the mobile phone, first obtain the installation package shown in Figure la. This installation package is a separate file. After installing this file on the mobile phone, as shown in Figure lb. The schematic diagram of the decompression of the installation package. These files include a running file of application.exe and several resource files. Then, when the application is running the application, the mobile phone can access one or more of the above multiple resource files. In the corresponding application running process, you need to separately access the above creation to Each resource file of the mobile terminal performs a large number of file opening/closing operations, affecting the running speed of the application, and consuming the power of the mobile terminal. Summary of the invention
本发明实施例提供一种资源文件的访问方法及装置, 用以解决现有技术 中存在的技术问题。  The embodiment of the invention provides a method and a device for accessing a resource file, which are used to solve the technical problems existing in the prior art.
本发明实施例提供了一种资源文件的访问方法, 包括:  An embodiment of the present invention provides a method for accessing a resource file, including:
获得待访问的资源文件的文件名, 并根据所述待访问的资源文件的文件 名读取资源包文件的索引区和文件名区, 所述资源包文件包括索引区、 文件 名区和文件内容区; Obtaining a file name of the resource file to be accessed, and reading an index area and a file name area of the resource package file according to the file name of the resource file to be accessed, where the resource package file includes an index area, a file name area, and a file content. Area;
Figure imgf000004_0001
根据所述存储路径和所述偏移量信息, 在所述文件内容区获得所述待访 问的资源文件的内容。
Figure imgf000004_0001
And obtaining, according to the storage path and the offset information, the content of the resource file to be accessed in the file content area.
本发明实施例还提供了一种资源文件的访问装置, 包括:  The embodiment of the invention further provides a resource file accessing device, including:
读取模块, 用于获得待访问的资源文件的文件名, 并根据所述待访问的 资源文件的文件名读取资源包文件的索引区和文件名区, 所述资源包文件包 括索引区、 文件名区和文件内容区; 容区的存储路径, 从所述索引区获得所述待访问的资源文件的偏移量信息; 根据所述存储路径和所述偏移量信息, 在所述文件内容区获得所述待访问的 资源文件的内容。  a reading module, configured to obtain a file name of the resource file to be accessed, and read an index area and a file name area of the resource package file according to the file name of the resource file to be accessed, where the resource package file includes an index area, a file name area and a file content area; a storage path of the storage area, obtained offset information of the resource file to be accessed from the index area; according to the storage path and the offset information, in the file The content area obtains the content of the resource file to be accessed.
本发明实施例的资源文件的访问方法及装置, 通过将全部的资源文件制 作成一个资源包文件, 资源包文件分为索引区、 文件名区和文件内容区, 读 件在文件内容区的存储路径,从索引区获得待访问的资源文件的偏移量信息, 免了大量的文件打开 /关闭的操作, 提升了移动终端的运行速度, 节约了移动 终端的电能损耗。 附图说明 The method and device for accessing a resource file according to an embodiment of the present invention, by making all the resource files into one resource package file, the resource package file is divided into an index area, a file name area, and a file content area, and the reading is stored in the file content area. Path, obtaining offset information of the resource file to be accessed from the index area, A large number of file opening/closing operations are saved, which improves the running speed of the mobile terminal and saves power consumption of the mobile terminal. DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实 施例或现有技术描述中所需要使用的附图作一筒单地介绍, 显而易见地, 下 面描述中的附图是本发明的一些实施例, 对于本领域普通技术人员来讲, 在 不付出创造性劳动的前提下, 还可以根据这些附图获得其他的附图。  In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings to be used in the embodiments or the description of the prior art will be briefly described below, and obviously, the attached in the following description The drawings are some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without any creative work.
图 la为现有技术中提供的安装包的示意图;  Figure la is a schematic view of an installation package provided in the prior art;
图 lb为图 la中的安装包解压后的组成示意图;  Figure lb is a schematic diagram of the composition of the installation package in Figure la after decompression;
图 2为本发明一个实施例提供的资源文件的访问方法流程图;  2 is a flowchart of a method for accessing a resource file according to an embodiment of the present invention;
图 3为本发明还一个实施例提供的资源文件的访问方法流程图; 图 4为本发明再一个实施例提供的资源文件的访问方法流程图; 图 5为本发明一个实施例提供的资源文件的访问装置结构示意图; 图 6为本发明又一个实施例提供的资源文件的访问装置结构示意图。 具体实施方式  FIG. 3 is a flowchart of a method for accessing a resource file according to another embodiment of the present invention; FIG. 4 is a flowchart of a method for accessing a resource file according to another embodiment of the present invention; FIG. 5 is a resource file according to an embodiment of the present invention; FIG. 6 is a schematic structural diagram of a device for accessing a resource file according to another embodiment of the present invention. detailed description
为使本发明实施例的目的、 技术方案和优点更加清楚, 下面将结合本发 明实施例中的附图, 对本发明实施例中的技术方案进行清楚、 完整地描述, 显然, 所描述的实施例是本发明一部分实施例, 而不是全部的实施例。 基于 本发明中的实施例, 本领域普通技术人员在没有作出创造性劳动前提下所获 得的所有其他实施例, 都属于本发明保护的范围。  The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
图 2为本发明一个实施例提供的资源文件的访问方法流程图, 如图 2所 示, 该方法包括:  FIG. 2 is a flowchart of a method for accessing a resource file according to an embodiment of the present invention. As shown in FIG. 2, the method includes:
步骤 201 : 获得待访问的资源文件的文件名, 根据获得的待访问的资源 文件的文件名读取资源包文件的索引区和文件名区, 该资源包文件包括: 索 引区、 文件名区和文件内容区。 Step 201: Obtain a file name of the resource file to be accessed, according to the obtained resource to be accessed. The file name of the file reads the index area and the file name area of the resource package file, and the resource package file includes: an index area, a file name area, and a file content area.
其中, 程序在运行时需要访问到的资源文件可以称之为待访问的资源文 件, 程序根据待访问的资源文件的文件名访问资源文件。  The resource file that the program needs to access during operation can be referred to as the resource file to be accessed, and the program accesses the resource file according to the file name of the resource file to be accessed.
现有技术中的程序安装包中包含的资源文件为一个一个零散的资源文 件, 本发明实施例提供的资源包文件为一个二进制文件, 该二进制文件中包 括了索引区, 用于记录资源文件的类型、 资源文件的文件名的偏移量、 资源 文件名的长度、 资源文件的文件内容在资源包文件中的偏移量, 以及资源文 件的文件内容的长度。 索引区用于保存该资源包文件中所有资源文件的偏移 量信息, 其中可以包括多个索引结构。 该二进制文件中还包括了文件名区, 用于记录资源文件的文件名和资源文件在资源包文件中的存储路径, 文件名 区中可以包括多个文件名结构。 该二进制文件还包括了文件内容区, 用于记 录资源文件的文件内容, 每一个资源文件的文件内容都是以二进制表示的, 其中包括多个文件内容结构。  The resource file included in the program installation package in the prior art is a piece of a resource file. The resource package file provided by the embodiment of the present invention is a binary file, and the binary file includes an index area for recording resource files. The type, the offset of the file name of the resource file, the length of the resource file name, the offset of the file content of the resource file in the resource bundle file, and the length of the file content of the resource file. The index area is used to save offset information of all resource files in the resource package file, and may include multiple index structures. The binary file also includes a file name area for recording the file name of the resource file and a storage path of the resource file in the resource package file, and the file name area may include multiple file name structures. The binary file also includes a file content area for recording the file content of the resource file, and the file content of each resource file is represented by a binary, which includes a plurality of file content structures.
对于上述资源文件在资源包文件中的存储路径需要说明的是, 该存储路 径实际上是一个相对路径, 该相对路径可以理解为从资源文件所在根目录获 得资源文件的一个路径, 这个路径指的并不是资源文件存储在手机上的哪个 磁盘或者哪个扇区, 而是指从资源包文件中该资源文件所在的根目录如何找 到资源文件的路径, 因此是一个相对路径。  For the storage path of the resource file in the resource package file, it should be noted that the storage path is actually a relative path, and the relative path can be understood as a path for obtaining a resource file from the root directory of the resource file, and the path refers to It is not the disk or sector of the resource file stored on the mobile phone, but the path to the resource file from the root directory of the resource file in the resource package file, so it is a relative path.
步骤 202: 从文件名区获得该待访问的资源文件在文件内容区的存储路 径, 从索引区获得该待访问的资源文件的偏移量信息, 根据存储路径和偏移 其中的偏移量信息指的是: 当获得了某一个资源文件在资源包文件中的 存储路径时, 该资源文件有可能并不是从第一位数据开始的, 而是存在一个 偏移量, 只有获得了偏移量, 才能从资源文件的起始位置开始访问资源文件。  Step 202: Obtain a storage path of the resource file to be accessed in the file content area from the file name area, obtain offset information of the resource file to be accessed from the index area, and obtain offset information according to the storage path and the offset. Refers to: When a storage path of a resource file in a resource package file is obtained, the resource file may not start from the first bit of data, but there is an offset, and only the offset is obtained. , in order to access the resource file from the beginning of the resource file.
在上述实施方式的基础上, 该资源包文件还可以包括: 文件头部区, 用 于记录上述索引区、 文件名区和文件内容区的大小, 以及在资源包文件内各 自的偏移量。 相应的, 步骤 201之前还可以包括: 访问资源包文件的文件头 部区, 获得索引区、 文件名区和文件内容区的大小和偏移量。 进一步的, 该 文件头部区还可以用于记录至少一个: 资源包文件的文件头部的长度、 资源 包文件的版本、 资源包文件的大小以及资源包文件中资源文件的总数。 Based on the foregoing implementation manner, the resource package file may further include: a file header area, The size of the index area, file name area, and file content area, and the respective offsets in the resource bundle file are recorded. Correspondingly, before step 201, the method may further include: accessing a file header area of the resource package file, and obtaining a size and an offset of the index area, the file name area, and the file content area. Further, the file header area may also be used to record at least one: a length of a file header of the resource package file, a version of the resource package file, a size of the resource package file, and a total number of resource files in the resource package file.
如图 3所示的本发明还一个实施例提供的资源文件的访问方法流程图, 在上述实施方式的基础上, 为了加快获得资源文件的存储路径以及偏移量信 息, 本发明实施例提供的方法可以包括:  The flowchart of the access method of the resource file provided by the embodiment of the present invention, as shown in FIG. 3, is provided by the embodiment of the present invention, in order to speed up the storage path and the offset information of the resource file. Methods can include:
步骤 300: 读取资源包文件中索引区和文件名区中记录的内容, 根据读 取到的索引区和文件名区中记录的内容, 建立资源文件的索引表, 该索引表 中包括该资源包文件中资源文件的名称、 大小、 偏移量和存储路径。 其中, 内容至少可以包括索引区记录的资源文件名的偏移量、 资源文件名的长度、 资源文件的文件内容在资源包文件中的偏移量、 以及资源文件的文件内容的 长度, 文件名区记录的资源文件名和存储路径。  Step 300: Read the content recorded in the index area and the file name area in the resource package file, and establish an index table of the resource file according to the content recorded in the read index area and the file name area, where the index table includes the resource. The name, size, offset, and storage path of the resource file in the package file. The content may include at least an offset of the resource file name recorded in the index area, a length of the resource file name, an offset of the file content of the resource file in the resource package file, and a length of the file content of the resource file, the file name The resource file name and storage path of the zone record.
步骤 301 : 获得待访问的资源文件的文件名, 根据该获得的文件名, 读 取索引表。  Step 301: Obtain a file name of the resource file to be accessed, and read the index table according to the obtained file name.
其中, 该索引表可以以 Hashmap (哈希表) 的形式存在。  The index table can exist in the form of a Hashmap.
步骤 302: 根据索引表中读取到的存储路径和偏移量信息在文件内容区 获得待访问的资源文件的内容。  Step 302: Obtain the content of the resource file to be accessed in the file content area according to the storage path and the offset information read in the index table.
在本发明的另一资源文件的访问方法实施例中, 该方法还可以包括: 保 持资源包文件的打开状态, 以便于移动终端等的程序访问该资源包文件。 该 步骤优选发生在资源包文件被访问一次之后。  In another embodiment of the access method of the resource file of the present invention, the method may further include: maintaining an open state of the resource package file, so that a program of the mobile terminal or the like accesses the resource package file. This step preferably occurs after the resource bundle file has been accessed once.
图 4为本发明再一个实施例提供的资源文件的访问方法流程图, 如图 4 所示, 该方法以手机视频程序访问其资源文件为例进行说明, 该方法不仅介 绍了手机视频程序客户端在手机上的工作时如何对其所需要的资源进行访 问, 而且还进一步交代了如何制作手机视频程序的资源包文件、 如何制作手 机视频程序的程序安装包、 如何在手机上安装手机视频程序、 以及如何将手 机视频程序进行卸载的方法。 下面依照上述各部分之间最优的发生顺序进行 介绍, 但并不用以限制本发明要求保护的范围。 包括: FIG. 4 is a flowchart of a method for accessing a resource file according to another embodiment of the present invention. As shown in FIG. 4, the method uses a mobile phone video program to access a resource file as an example, and the method not only introduces a mobile phone video program client. How to access the resources needed when working on the mobile phone, and further explain how to make a resource package file for mobile video programs, how to make a hand Program installation package for the video program, how to install the mobile video program on the mobile phone, and how to uninstall the mobile video program. The following is a description of the preferred order of occurrence between the various parts described above, but is not intended to limit the scope of the claimed invention. include:
步骤 401 : 制作手机视频程序的资源包文件。 获取手机视频程序所需的全部的资源文件的信息, 其中, 资源文件的信息包 括: 资源文件的名称、 大小、 内容等, 上述信息保存在本地列表中; 根据获 取的资源文件的信息构建资源包文件的文件头部区结构、 索引区结构、 文件 名区结构和文件内容区结构; 将构建的文件打包成单一的二进制文件。 所述 构建的二进制文件可以包括了文件头部区结构、 索引区结构、 文件名区结构 和文件内容区结构等结构信息。  Step 401: Create a resource package file of the mobile video program. Obtaining information of all resource files required for the mobile video program, wherein the information of the resource file includes: a name, a size, and a content of the resource file, where the foregoing information is saved in a local list; and the resource package is constructed according to the obtained information of the resource file. The file header area structure, index area structure, file name area structure, and file content area structure of the file; package the constructed file into a single binary file. The constructed binary file may include structural information such as a file header area structure, an index area structure, a file name area structure, and a file content area structure.
具体的, 构建资源包文件可以包括但不限于如下所示的结构信息: Specifically, the build resource package file may include but is not limited to the following structural information:
1.1 )文件格式: 1.1) File format:
I文件头部区, 保存该资源包文件的一般信息, 内部资源文件数目等 I索引区, 保存所有资源文件的偏移量信息,其中包括多个索引结构 I文件名区, 保存所有资源文件的文件名和存储路径,其中包括多个文 件名结构  I file header area, save the general information of the resource package file, the number of internal resource files, etc. I index area, save the offset information of all resource files, including multiple index structure I file name area, save all resource files File name and storage path, including multiple file name structures
I文件内容区, 保存所有资源文件的二进制内容,其中包括多个文件内容 结构  I file content area, which stores the binary content of all resource files, including multiple file contents.
1.2 )文件头部区结构: 1.2) File header area structure:
typedef struct ulong m_iHeaderLen; //文件头部的长度  Typedef struct ulong m_iHeaderLen; //the length of the file header
ulong m_i Version; 〃资源包的版本  Ulong m_i Version; 〃 resource pack version
ulong m_iResFileLen 〃资源包的总大小 ulong m_iFsObjCount; //资源包中的资源总数 ulong m_iIndexSecOffset; //索引区在整个资源包中的 偏移量 Ulong m_iResFileLen 总 total size of the resource bundle Ulong m_iFsObjCount; / / total number of resources in the resource bundle ulong m_iIndexSecOffset; / / index area offset in the entire resource bundle
ulong m_iIndexSecLen; 〃索引区的大小  Ulong m_iIndexSecLen; 〃 index area size
ulong m_iNameSecOffset; 〃文件名区在资源包中的偏移 ulong m_iNameSecLen; //文件名区的大小  Ulong m_iNameSecOffset; 偏移 The offset of the file name area in the resource bundle ulong m_iNameSecLen; //The size of the file name area
ulong m_iDataSecOffset; 〃资源文件内容区的偏移量 ulong m_iDataSecLen; //文件内容区的大小  Ulong m_iDataSecOffset; 偏移 offset of the content area of the resource file ulong m_iDataSecLen; / / size of the file content area
} T_ResFileHeader;  } T_ResFileHeader;
1.3 ) 索引区结构: 1.3) Index area structure:
typedef struct ulong m_ JFsoType; 〃资源文件的类型  Typedef struct ulong m_ JFsoType; 〃 resource file type
ulong m_ — sFsoNameOffset; 〃该资源文件文件名的偏移量 ulong m_ JFsoNameLen; 〃文件名的长度  Ulong m_ — sFsoNameOffset; 偏移 offset of the file name of the resource file ulong m_ JFsoNameLen; 长度 length of the file name
ulong m_iFsoDataOffset; //文件内容的偏移量 ulong m_ JFsoDataLen; //文件内容的长度  Ulong m_iFsoDataOffset; / / file content offset ulong m_ JFsoDataLen; / / file content length
} T_ResFileIndex;  } T_ResFileIndex;
1.4 )文件名区结构: 1.4) File name area structure:
typedef struct uchar m_sFsoNameBuff [N]; 〃文件名  Typedef struct uchar m_sFsoNameBuff [N]; 〃 filename
} T_ResFileNameSec; 1.5 )文件内容区结构: } T_ResFileNameSec; 1.5) File content area structure:
typedef struct uchar m_sFsoDataBuff [N]; 〃文件内容  Typedef struct uchar m_sFsoDataBuff [N]; 〃 file content
}T_ResFileDataSec;  }T_ResFileDataSec;
步骤 402: 制作手机视频程序安装包。  Step 402: Create a mobile video program installation package.
将步骤 401 中制作的单一的二进制资源包文件包含在程序安装包中, 即 将制作的单一的二进制资源包文件与程序执行文件(如后缀为. exe 的文件) 制作成一个程序安装包, 降低了制作安装包的难度, 且减少了程序安装在手 机上以后占用的磁盘空间。  The single binary resource package file created in step 401 is included in the program installation package, and the single binary resource package file to be produced and the program execution file (such as the file with the suffix exe) are made into a program installation package, which is reduced. The difficulty of making an installation package, and reducing the disk space occupied by the program after it is installed on the phone.
步骤 403: 在手机上安装手机视频程序。  Step 403: Install the mobile video program on the mobile phone.
安装过程可以包括: 将程序安装包中的单一的二进制资源包文件和程序 执行文件加载到手机的指定位置, 由于只有一个资源包文件, 而不是多个资 源文件, 避免了重复多次的读取程序安装包的操作, 大大提高了程序安装速 度。 一般而言, 采用该单一的二进制资源包文件后, 客户端的安装速度能提 高 10~20倍。  The installation process may include: loading a single binary resource package file and a program execution file in the program installation package to a specified location on the mobile phone, since only one resource package file, rather than multiple resource files, avoids repeated readings The operation of the program installation package greatly improves the program installation speed. In general, with this single binary resource package file, the client installation speed can be increased by 10 to 20 times.
步骤 404: 手机视频程序启动, 索引资源包文件。  Step 404: The mobile video program starts, and the resource package file is indexed.
具体包括: 手机视频程序的执行文件启动运行时, 读取资源包文件的文 件头部区, 从资源包文件的文件头部区中获得索引区、 文件名区和文件内容 区的大小以及在资源包文件内的偏移量。 根据索引区和文件名区各自的大小 及偏移量, 读取索引区中的信息内容, 获得资源包文件中包含的各资源文件 的类型、 资源文件名的偏移量、 资源文件名的长度、 资源文件的文件内容在 资源包文件中的偏移量、 以及资源文件的文件内容的长度, 读取文件名区中 文件在资源包文件中的存储路径, 从而建立资源文件的索引表, 该索引表中 至少包含资源文件的名称、 大小、 偏移量和存储路径, 并将该索引表以哈希 表的方式保存, 以便后续的快速索引。 保持该资源包文件的打开状态, 以有 效减少打开、 关闭资源包文件的次数。 Specifically, when the execution file of the mobile video program starts running, the file header area of the resource package file is read, and the size of the index area, the file name area, and the file content area are obtained from the file header area of the resource package file, and the resource is in the resource. The offset within the package file. According to the size and offset of the index area and the file name area, the information content in the index area is read, and the type of each resource file included in the resource package file, the offset of the resource file name, and the length of the resource file name are obtained. The offset of the file content of the resource file in the resource package file and the length of the file content of the resource file, and the storage path of the file in the resource package file in the file name area, thereby establishing an index table of the resource file, The index table contains at least the name, size, offset, and storage path of the resource file, and hashes the index table The way the table is saved for subsequent quick indexing. Keep the resource bundle file open to effectively reduce the number of times the resource bundle file is opened and closed.
步骤 405: 手机视频程序运行, 检索资源文件。  Step 405: The mobile video program runs to retrieve the resource file.
具体包括: 手机视频程序可以根据需要的资源文件名检索在步骤 404中 建立的资源文件的索引表, 并找到对应的资源文件在资源包文件中的存储路 径和偏移位置, 到相应路径中的相应偏移位置处读取所需的资源文件。 通过 上述方法, 有效避免了打开和关闭零碎的小文件, 提升了程序的运行速度, 降低了手机性能的消耗。  Specifically, the mobile video program can retrieve the index table of the resource file established in step 404 according to the required resource file name, and find the storage path and offset position of the corresponding resource file in the resource package file, to the corresponding path. Read the required resource file at the corresponding offset location. Through the above method, the small files that are fragmented and opened are effectively avoided, the running speed of the program is improved, and the performance consumption of the mobile phone is reduced.
步骤 406: 卸载手机视频程序。  Step 406: Uninstall the mobile video program.
当卸载手机视频程序时, 将安装到手机的资源包文件全部物理删除, 因 为本发明实施例中提供的资源包文件以单一的二进制文件形式存在, 避免了 重复多次的删除操作, 大大提升了程序的卸载速度。  When the mobile phone video program is uninstalled, the resource package files installed to the mobile phone are all physically deleted, because the resource package file provided in the embodiment of the present invention exists in the form of a single binary file, thereby avoiding repeated deletion operations, which greatly improves the The speed at which the program is uninstalled.
本发明实施例提供的资源文件的访问方法, 通过将全部的资源文件制作 成一个资源包文件, 资源包文件分为索引区、 文件名区和文件内容区, 读取 在文件内容区的存储路径, 从索引区获得待访问的资源文件的偏移量信息, 根据存储路径和偏移量信息在文件内容区获得待访问的资源文件的内容, 避 免了大量的文件打开 /关闭的操作, 提升了移动终端的运行速度, 节约了移动 终端的电能损耗。  The access method of the resource file provided by the embodiment of the present invention, by making all the resource files into one resource package file, the resource package file is divided into an index area, a file name area, and a file content area, and the storage path in the file content area is read. Obtaining the offset information of the resource file to be accessed from the index area, obtaining the content of the resource file to be accessed in the file content area according to the storage path and the offset information, thereby avoiding a large number of file opening/closing operations, and improving The running speed of the mobile terminal saves the power loss of the mobile terminal.
图 5为本发明一个实施例提供的资源文件的访问装置结构示意图, 如图 5 所示, 所述资源文件的访问装置用于实现上述方法实施例的, 所述资源文 件的访问装置包括: 读取模块 501和处理器 502。 其中, 读取模块 501用于: 获得待访问的资源文件的文件名, 并根据待访问的资源文件的文件名读取资 源包文件的索引区和文件名区, 该资源包文件包括索引区、 文件名区和文件 的存储路径, 从索引区获得待访问的资源文件的偏移量信息, 根据存储路径 其中, 本发明实施例提供的资源包文件为一个二进制文件, 该二进制文 件中包括了索引区, 用于记录资源文件的类型、 资源文件的文件名的偏移量、 资源文件名的长度、 资源文件的文件内容在资源包文件中的偏移量, 以及资 源文件的文件内容的长度。 索引区用于保存该资源包文件中所有资源文件的 偏移量信息, 其中可以包括多个索引结构。 该二进制文件中还包括了文件名 区, 用于记录资源文件的文件名和资源文件在资源包文件中的存储路径, 文 件名区中可以包括多个文件名结构。 该二进制文件还包括了文件内容区, 用 于记录资源文件的文件内容, 每一个资源文件的文件内容都是以二进制表示 的, 其中包括多个文件内容结构。 对于上述资源文件在资源包文件中的存储 路径需要说明的是, 该存储路径实际上是一个相对路径, 该相对路径可以理 解为从资源文件所在根目录获得资源文件的一个路径, 这个路径指的并不是 资源文件存储在手机上的哪个磁盘或者哪个扇区, 而是指从资源包文件中该 资源文件所在的根目录如何获得找到资源文件的路径, 因此是一个相对路径。 FIG. 5 is a schematic structural diagram of a device for accessing a resource file according to an embodiment of the present invention. As shown in FIG. 5, the device for accessing a resource file is used to implement the foregoing method, and the device for accessing the resource file includes: Module 501 and processor 502 are taken. The reading module 501 is configured to: obtain a file name of the resource file to be accessed, and read an index area and a file name area of the resource package file according to the file name of the resource file to be accessed, where the resource package file includes an index area, The storage path of the file name area and the file, and the offset information of the resource file to be accessed is obtained from the index area, according to the storage path The resource package file provided by the embodiment of the present invention is a binary file, and the binary file includes an index area for recording the type of the resource file, the offset of the file name of the resource file, the length of the resource file name, and the resource. The offset of the file's file content in the resource bundle file, and the length of the file content of the resource file. The index area is used to save offset information of all resource files in the resource package file, and may include multiple index structures. The binary file further includes a file name area for recording the file name of the resource file and a storage path of the resource file in the resource package file, and the file name area may include multiple file name structures. The binary file also includes a file content area for recording the file content of the resource file, and the file content of each resource file is represented by a binary, which includes a plurality of file content structures. For the storage path of the resource file in the resource package file, it should be noted that the storage path is actually a relative path, and the relative path can be understood as a path for obtaining a resource file from the root directory of the resource file, and the path refers to It is not the disk or sector of the resource file stored on the mobile phone, but the path to the resource file in the resource package file. The path to the resource file is obtained, so it is a relative path.
在本发明另一实施例中, 资源包文件还可以包括: 文件头部区, 用于记 录索引区、 文件名区和文件内容区的大小, 以及在资源包文件内的偏移量。 相应的, 读取模块 501还用于: 在根据待访问的资源文件的文件名读取资源 包文件的索引区和文件名区之前, 访问资源包文件的文件头部区, 获得索引 区、 文件名区和文件内容区的大小和在资源包文件中的偏移量。  In another embodiment of the present invention, the resource package file may further include: a file header area for recording the size of the index area, the file name area, and the file content area, and an offset within the resource package file. Correspondingly, the reading module 501 is further configured to: before reading the index area and the file name area of the resource package file according to the file name of the resource file to be accessed, accessing the file header area of the resource package file to obtain the index area and the file The size of the namespace and file content area and the offset in the resource bundle file.
图 6为本发明又一个实施例提供的资源文件的访问装置结构示意图, 如 图 6所示, 相比较于图 5所示的访问装置, 该资源文件的访问装置不仅包括 读取模块 601和处理器 602, 还包括: 建立模块 600, 用于在读取模块 601获 得待访问的资源文件的文件名之前, 读取资源包文件中的索引区和文件名区 记录的内容; 根据读取到的索引区和文件名区记录的内容, 建立资源文件的 索引表, 该索引表中包括资源文件的名称、 大小、 偏移量和存储路径。 其中, 内容至少可以包括索引区记录的资源文件名的偏移量、 资源文件名的长度、 资源文件的文件内容在资源包文件中的偏移量、 以及资源文件的文件内容的 长度, 文件名区记录的资源文件名和存储路径。 相应的, 读取模块 601用于: 获得待访问的资源文件的文件名, 根据获得的文件名, 读取建立模块 600建 立的索引表。 处理器 602用于根据索引表中读取到的存储路径和偏移量信息 在文件内容区获得待访问的资源文件的内容。 FIG. 6 is a schematic structural diagram of a device for accessing a resource file according to another embodiment of the present invention. As shown in FIG. 6, the access device of the resource file includes not only the reading module 601 but also processing. The 602, further includes: an establishing module 600, configured to read, before the reading module 601 obtains the file name of the resource file to be accessed, the content recorded in the index area and the file name area in the resource package file; The contents of the index area and the file name area record, and an index table of the resource file is created, and the index table includes the name, size, offset, and storage path of the resource file. The content may include at least an offset of the resource file name recorded in the index area, a length of the resource file name, and The offset of the file content of the resource file in the resource bundle file, and the length of the file content of the resource file, the resource file name and storage path of the file name area record. Correspondingly, the reading module 601 is configured to: obtain a file name of the resource file to be accessed, and read an index table established by the establishing module 600 according to the obtained file name. The processor 602 is configured to obtain the content of the resource file to be accessed in the file content area according to the storage path and the offset information read in the index table.
本发明实施例提供的资源文件的访问装置, 通过将全部的资源文件制作 成一个资源包文件, 资源包文件分为索引区、 文件名区和文件内容区, 读取 在文件内容区的存储路径, 从索引区获得待访问的资源文件的偏移量信息, 根据存储路径和偏移量信息在文件内容区获得待访问的资源文件的内容, 避 免了大量的文件打开 /关闭的操作, 提升了移动终端的运行速度, 节约了移动 终端的电能损耗。  The access device for the resource file provided by the embodiment of the present invention, by making all the resource files into one resource package file, the resource package file is divided into an index area, a file name area, and a file content area, and the storage path in the file content area is read. Obtaining the offset information of the resource file to be accessed from the index area, obtaining the content of the resource file to be accessed in the file content area according to the storage path and the offset information, thereby avoiding a large number of file opening/closing operations, and improving The running speed of the mobile terminal saves the power loss of the mobile terminal.
本领域普通技术人员可以理解: 实现上述方法实施例的全部或部分步骤 可以通过程序指令相关的硬件来完成, 前述的程序可以存储于一计算机可读 取存储介质中, 该程序在执行时, 执行包括上述方法实施例的步骤; 而前述 的存储介质包括: ROM、 RAM, 磁碟或者光盘等各种可以存储程序代码的介 质。  A person skilled in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by using hardware related to program instructions, and the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed. The foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
最后应说明的是: 以上实施例仅用以说明本发明的技术方案, 而非对其 限制; 尽管参照前述实施例对本发明进行了详细的说明, 本领域的普通技术 人员应当理解: 其依然可以对前述各实施例所记载的技术方案进行修改, 或 者对其中部分技术特征进行等同替换; 而这些修改或者替换, 并不使相应技 术方案的本质脱离本发明各实施例技术方案的精神和范围。  It should be noted that the above embodiments are only for explaining the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art that: The technical solutions described in the foregoing embodiments are modified, or some of the technical features are equivalently replaced. The modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

权利要求 Rights request
1、 一种资源文件的访问方法, 其特征在于, 包括:  A method for accessing a resource file, comprising:
获得待访问的资源文件的文件名, 并根据所述待访问的资源文件的文件 名读取资源包文件的索引区和文件名区, 所述资源包文件包括索引区、 文件 名区和文件内容区; Obtaining a file name of the resource file to be accessed, and reading an index area and a file name area of the resource package file according to the file name of the resource file to be accessed, where the resource package file includes an index area, a file name area, and a file content. Area;
Figure imgf000014_0001
Figure imgf000014_0001
径, 从所述索引区获得所述待访问的资源文件的偏移量信息; a path, obtaining offset information of the resource file to be accessed from the index area;
根据所述存储路径和所述偏移量信息, 在所述文件内容区获得所述待访 问的资源文件的内容。  And obtaining, according to the storage path and the offset information, the content of the resource file to be accessed in the file content area.
2、 根据权利要求 1所述的方法, 其特征在于, 所述资源包文件还包括: 文件头部区, 用于记录所述索引区、 文件名区和文件内容区的大小, 以及在 所述资源包文件内的偏移量;  2. The method according to claim 1, wherein the resource package file further comprises: a file header area, configured to record a size of the index area, a file name area, and a file content area, and The offset within the resource bundle file;
所述读取资源包文件的索引区和文件名区之前, 所述方法还包括: 访问所述资源包文件的文件头部区, 获得索引区、 文件名区和文件内容 区的大小和在所述资源包文件中的偏移量。  Before the reading the index area and the file name area of the resource package file, the method further includes: accessing a file header area of the resource package file, obtaining a size of the index area, the file name area, and the file content area The offset in the resource bundle file.
3、 根据权利要求 2所述的方法, 其特征在于, 所述文件头部区还用于记 录至少一个: 文件头部的长度、 所述资源包文件的版本、 所述资源包文件的 大小以及所述资源包文件中的资源文件总数。  The method according to claim 2, wherein the file header area is further configured to record at least one: a length of a file header, a version of the resource package file, a size of the resource package file, and The total number of resource files in the resource bundle file.
4、 根据权利要求 1至 3中任一项所述的方法, 其特征在于:  4. A method according to any one of claims 1 to 3, characterized in that:
所述索引区用于记录各资源文件的类型、 资源文件名的偏移量、 资源文 件名的长度、 资源文件的文件内容在所述资源包文件中的偏移量、 以及资源 文件的文件内容的长度;  The index area is used to record the type of each resource file, the offset of the resource file name, the length of the resource file name, the offset of the file content of the resource file in the resource package file, and the file content of the resource file. length;
所述文件名区用于记录各资源文件名和存储路径;  The file name area is used to record each resource file name and storage path;
所述文件内容区用于记录各资源文件的文件内容。  The file content area is used to record the file content of each resource file.
5、 根据权利要求 4所述的方法, 其特征在于, 所述获得待访问的资源文 件的文件名之前, 所述方法还包括: The method according to claim 4, wherein the obtaining the resource text to be accessed Before the file name of the piece, the method further includes:
读取所述资源包文件的索引区和所述文件名区记录的内容;  Reading an index area of the resource package file and a content recorded in the file name area;
根据读取到所述资源包文件的索引区和所述文件名区记录的内容, 建立 资源文件的索引表, 所述索引表中包括资源文件的名称、 大小、 偏移量和存 储路径;  Establishing an index table of the resource file according to the content of the index area read by the resource package file and the file name area, where the index table includes a name, a size, an offset, and a storage path of the resource file;
所述根据所述待访问的资源文件的文件名读取资源包文件的索引区和文 件名区, 包括:  The reading the index area and the file name area of the resource package file according to the file name of the resource file to be accessed includes:
根据所述获得的待访问的资源文件的文件名, 读取所述索引表。  And reading the index table according to the obtained file name of the resource file to be accessed.
6、 根据权利要求 5所述的方法, 其特征在于, 所述索引表以哈希表的形 式存在。  6. The method according to claim 5, wherein the index table exists in the form of a hash table.
7、 根据权利要求 1或 2所述的方法, 其特征在于, 所述方法还包括: 保持所述资源包文件的打开状态。  The method according to claim 1 or 2, wherein the method further comprises: maintaining an open state of the resource package file.
8、 一种资源文件的访问装置, 其特征在于, 包括:  8. A device for accessing a resource file, comprising:
读取模块, 用于获得待访问的资源文件的文件名, 并根据所述待访问的 资源文件的文件名读取资源包文件的索引区和文件名区, 所述资源包文件包 括索引区、 文件名区和文件内容区; 的存储路径, 从所述索引区获得所述待访问的资源文件的偏移量信息; 根据 所述存储路径和所述偏移量信息, 在所述文件内容区获得所述待访问的资源 文件的内容。  a reading module, configured to obtain a file name of the resource file to be accessed, and read an index area and a file name area of the resource package file according to the file name of the resource file to be accessed, where the resource package file includes an index area, a storage path of the file name area and the file content area; obtaining offset information of the resource file to be accessed from the index area; according to the storage path and the offset information, in the file content area Obtaining the content of the resource file to be accessed.
9、 根据权利要求 8所述的装置, 其特征在于, 所述资源包文件还包括: 文件头部区, 用于记录所述索引区、 文件名区和文件内容区的大小, 以及在 所述资源包文件内的偏移量;  The apparatus according to claim 8, wherein the resource package file further comprises: a file header area, configured to record a size of the index area, a file name area, and a file content area, and The offset within the resource bundle file;
所述读取模块还用于: 在根据所述待访问的资源文件的文件名读取资源 包文件的索引区和文件名区之前, 访问所述资源包文件的文件头部区, 获得 索引区、 文件名区和文件内容区的大小和在所述资源包文件中的偏移量。 The reading module is further configured to: before reading an index area and a file name area of the resource package file according to the file name of the resource file to be accessed, accessing a file header area of the resource package file to obtain an index area , the size of the file name area and the file content area, and the offset in the resource bundle file.
10、 根据权利要求 8或 9所述的装置, 其特征在于, 所述装置还包括: 建立模块, 用于在所述读取模块获得待访问的资源文件的文件名之前, 读取所述资源包文件中的索引区和所述文件名区记录的内容; 根据读取到所 述资源包文件中的索引区和所述文件名区记录的内容, 建立资源文件的索引 表, 所述索引表中包括资源文件的名称、 大小、 偏移量和存储路径; The device according to claim 8 or 9, wherein the device further comprises: an establishing module, configured to read the resource before the reading module obtains a file name of the resource file to be accessed An index area in the package file and the content recorded in the file name area; establishing an index table of the resource file according to the content recorded in the index area and the file name area read in the resource package file, the index table Include the name, size, offset, and storage path of the resource file;
所述读取模块用于: 获得待访问的资源文件的文件名, 并根据所述获得 的待访问的资源文件的文件名, 读取所述索引表。  The reading module is configured to: obtain a file name of the resource file to be accessed, and read the index table according to the obtained file name of the resource file to be accessed.
PCT/CN2012/076648 2011-07-27 2012-06-08 Method and apparatus for accessing resource files WO2012167742A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110211991.4A CN102902687B (en) 2011-07-27 2011-07-27 The access method of resource file and device
CN201110211991.4 2011-07-27

Publications (1)

Publication Number Publication Date
WO2012167742A1 true WO2012167742A1 (en) 2012-12-13

Family

ID=47295490

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/076648 WO2012167742A1 (en) 2011-07-27 2012-06-08 Method and apparatus for accessing resource files

Country Status (2)

Country Link
CN (1) CN102902687B (en)
WO (1) WO2012167742A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022057663A1 (en) * 2020-09-18 2022-03-24 华为技术有限公司 File generation method and electronic device
US20220107796A1 (en) * 2018-12-25 2022-04-07 Huawei Technologies Co., Ltd. Application Package Splitting and Reassembly Method and Apparatus, and Application Package Running Method and Apparatus
US12001824B2 (en) * 2018-12-25 2024-06-04 Petal Cloud Technology Co., Ltd. Application package splitting and reassembly method and apparatus, and application package running method and apparatus

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106055363B (en) 2016-05-31 2017-11-14 广东欧珀移动通信有限公司 A kind of method and mobile terminal for identifying file
CN107844483B (en) * 2016-09-18 2020-07-28 腾讯科技(深圳)有限公司 File management method and device
CN107633088B (en) * 2017-09-29 2020-04-24 深圳市金证科技股份有限公司 File management method and device
CN110968549B (en) * 2019-11-18 2024-03-29 Oppo(重庆)智能科技有限公司 File storage method, device, electronic equipment and medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073633A (en) * 2009-11-23 2011-05-25 腾讯科技(深圳)有限公司 Method and device for storing and accessing resource file

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20060133410A (en) * 2005-06-20 2006-12-26 엘지전자 주식회사 Method for managing file database and searching file in multimedia device
CN102054038B (en) * 2010-12-30 2014-05-28 东莞宇龙通信科技有限公司 File decompression method and device as well as mobile terminal

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073633A (en) * 2009-11-23 2011-05-25 腾讯科技(深圳)有限公司 Method and device for storing and accessing resource file

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220107796A1 (en) * 2018-12-25 2022-04-07 Huawei Technologies Co., Ltd. Application Package Splitting and Reassembly Method and Apparatus, and Application Package Running Method and Apparatus
US12001824B2 (en) * 2018-12-25 2024-06-04 Petal Cloud Technology Co., Ltd. Application package splitting and reassembly method and apparatus, and application package running method and apparatus
WO2022057663A1 (en) * 2020-09-18 2022-03-24 华为技术有限公司 File generation method and electronic device

Also Published As

Publication number Publication date
CN102902687B (en) 2015-09-09
CN102902687A (en) 2013-01-30

Similar Documents

Publication Publication Date Title
AU2016404863B2 (en) Patch-upgrade-based file processing method and apparatus, terminal, and storage medium
AU2003219640B2 (en) System and method for use of multiple applications
US9166866B2 (en) Hydration and dehydration with placeholders
JP5816198B2 (en) System and method for sharing the results of computing operations between related computing systems
WO2012167742A1 (en) Method and apparatus for accessing resource files
EP2888897B1 (en) Optimization of sim card initialization
US20120303905A1 (en) Method and apparatus for implementing cache
WO2010078760A1 (en) A method, a device for storing file and a method, a device for deleting file
US20130067237A1 (en) Providing random access to archives with block maps
WO2011116613A1 (en) Method and device for migrating software package version
US11422698B2 (en) Method, electronic device, and computer program product for storage management
WO2015196621A1 (en) File packing method and device
US8234247B2 (en) Content management system and method for portable device
WO2007036935A2 (en) A self-contained portable device
US20140258247A1 (en) Electronic apparatus for data access and data access method therefor
WO2021226822A1 (en) Log write method and apparatus, electronic device, and storage medium
US20230031033A1 (en) Virtual file system for dynamically providing media content
WO2019120157A1 (en) Method and device for downloading resources
SG192868A1 (en) Variants of files in a file system
US20230123921A1 (en) Facilitating the embedding of block references for reducing file access latency file systems
CN104424260A (en) Browser information sharing method and device
WO2014161289A1 (en) Information management method and apparatus
WO2015085764A1 (en) Method of file access and cloud gateway
TWI576703B (en) Electronic apparatus and method for temporarily storing data thereof
CN110287172A (en) A method of formatting HBase data

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12796893

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12796893

Country of ref document: EP

Kind code of ref document: A1