Resource storage and reading method, device, computer equipment and storage medium
By compressing and storing game resource files into resource compression packages in virtual file system format and uploading them to cloud servers, the problem of game files taking up a large storage space is solved, the game loading efficiency and installation success rate are improved, and the security of game resources is enhanced.
Patent Information
- Application Number
- CN202010777890.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-05
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2040-08-05
AI Technical Summary
During the game development process, game files occupy a large amount of storage space, resulting in too large game installation packages and low installation success rate and efficiency.
The game resource files are compressed and stored as resource compression packages in the virtual file system format and uploaded to the cloud server. The game is downloaded from the cloud when it is started, and the file integrity and security is ensured using chunked storage and verification components.
It reduces storage space usage, improves game loading efficiency and installation success rate, avoids excessive game installation packages, and enhances the security of game resources.
Smart Images

Figure CN114053719B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a resource storage and reading method, apparatus, computer equipment, and storage medium. Background Art
[0002] During game development, the developed game files typically include game program code files and game resource files (such as sounds, images, animations, etc.). Related technologies place all game files into a game package, for example, packaging the game resource files into the Asset directory under an APK (Android application package) or the Raw directory under an IPA (iOS application package). After the user installs the game package through a terminal and launches the game, the game resource files are decompressed from the APK or IPA to an additional storage location. When the game resource files need to be loaded, they are read from the corresponding storage location. However, related technologies require a large amount of storage space. Summary of the Invention
[0003] Based on this, it is necessary to provide a resource storage and reading method, device, computer equipment and storage medium that can reduce storage space occupation in response to the above technical problems.
[0004] A resource storage method, the method comprising:
[0005] Get game resource files;
[0006] Compress and store the game resource files to generate a resource compression package in a virtual file system format; the virtual file system format includes: a data storage component and a verification component, the data storage component is used to store the game resource files in blocks, and the verification component is used to store verification data of the game resource files;
[0007] The resource compression package is uploaded to the cloud server for downloading when the game is started.
[0008] A resource storage device, comprising:
[0009] Acquisition module, used to obtain game resource files;
[0010] A storage module is used to compress and store the game resource files to generate a resource compression package in a virtual file system format; the virtual file system format includes: a data storage component and a verification component, the data storage component is used to store the game resource files in blocks, and the verification component is used to store verification data of the game resource files;
[0011] The upload module is used to upload the resource compression package to the cloud server for downloading when the game is started.
[0012] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0013] Get game resource files;
[0014] Compress and store the game resource files to generate a resource compression package in a virtual file system format; the virtual file system format includes: a data storage component and a verification component, the data storage component is used to store the game resource files in blocks, and the verification component is used to store verification data of the game resource files;
[0015] The resource compression package is uploaded to the cloud server for downloading when the game is started.
[0016] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0017] Get game resource files;
[0018] Compress and store the game resource files to generate a resource compression package in a virtual file system format; the virtual file system format includes: a data storage component and a verification component, the data storage component is used to store the game resource files in blocks, and the verification component is used to store verification data of the game resource files;
[0019] The resource compression package is uploaded to the cloud server for downloading when the game is started.
[0020] The above-mentioned resource storage method, device, computer equipment and storage medium compress and store game resource files into resource compression packages in the virtual file system format, so that the game resource files can be read directly from the resource compression package later without having to decompress each game resource file in the resource compression package to additional storage space for reading, thereby reducing the storage space occupied; using block storage, game resources can be loaded and displayed without downloading all files during reading, thereby improving game loading efficiency; in addition, by uploading the resource compression package to the cloud server, the problem of the game installation package being too large due to packaging the game resource files together into the game installation package can be avoided, thereby improving the success rate and efficiency of game installation.
[0021] A resource reading method, the method comprising:
[0022] When the game is started, the corresponding resource compression package is downloaded from the cloud server; the resource compression package represents a resource compression package in a virtual file system format generated by compressing and storing the game resource files. The virtual file system format includes: a data storage component and a verification component. The data storage component is used to store the game resource files in blocks, and the verification component is used to store verification data of the game resource files.
[0023] The resource compression package is read to obtain the corresponding game resource file.
[0024] A resource reading device, comprising:
[0025] A download module, configured to download a corresponding resource compression package from a cloud server when the game is launched; the resource compression package represents a resource compression package in a virtual file system format generated by compressing and storing the game resource files. The virtual file system format includes a data storage component and a verification component. The data storage component is configured to store the game resource files in blocks, and the verification component is configured to store verification data for the game resource files.
[0026] The reading module is used to read the resource compression package to obtain the corresponding game resource file.
[0027] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0028] When the game is started, the corresponding resource compression package is downloaded from the cloud server; the resource compression package represents a resource compression package in a virtual file system format generated by compressing and storing the game resource files. The virtual file system format includes: a data storage component and a verification component. The data storage component is used to store the game resource files in blocks, and the verification component is used to store verification data of the game resource files.
[0029] The resource compression package is read to obtain the corresponding game resource file.
[0030] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0031] When the game is started, the corresponding resource compression package is downloaded from the cloud server; the resource compression package represents a resource compression package in a virtual file system format generated by compressing and storing the game resource files. The virtual file system format includes: a data storage component and a verification component. The data storage component is used to store the game resource files in blocks, and the verification component is used to store verification data of the game resource files.
[0032] The resource compression package is read to obtain the corresponding game resource file.
[0033] The above-mentioned resource reading method, device, computer equipment and storage medium download the corresponding resource compression package from the cloud server when the game is started. The resource compression package is a resource compression package in a virtual file system format generated by compressing and storing the game resource files of the started game. The game resource files can be read directly from the resource compression package without decompressing each game resource file in the resource compression package to an additional storage space for reading, thereby reducing the storage space occupied; using block storage, the game resources can be loaded and displayed without downloading all files during reading, thereby improving the game loading efficiency; in addition, by downloading the resource compression package from the cloud server, the problem of the game installation package being too large due to packaging the game resource files together into the game installation package can be avoided, thereby improving the success rate and efficiency of game installation. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A diagram of an application environment of a resource storage and reading method in one embodiment;
[0035] Figure 2 1 is a flow chart of a resource storage method according to an embodiment;
[0036] Figure 3 A schematic diagram of a resource compression package in VFS format according to an embodiment;
[0037] Figure 4 Schematic diagram of a resource reading method in one embodiment;
[0038] Figure 5 A schematic diagram of a Unity plug-in use case in one embodiment;
[0039] Figure 6 This is an application scenario diagram of a resource storage and reading method in one embodiment;
[0040] Figure 7 is a structural block diagram of a resource storage device in one embodiment;
[0041] Figure 8 is a structural block diagram of a resource reading device in one embodiment;
[0042] Figure 9 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0044] The resource storage and reading method provided in this application can be applied to Figure 1 In the application environment shown. The application environment involves a first terminal 102, a second terminal 104 and a cloud server 106, wherein the first terminal 102 and the second terminal 104 both communicate with the cloud server 106 via a network. The game developer can compress and store game resource files through the first terminal 102, generate a resource compression package in a virtual file system format, and upload the resource compression package to the cloud server 106. The game user can install and run the game through the second terminal 104, and when the game is detected to be started, download the corresponding resource compression package from the cloud server 106, read the resource compression package, and obtain the corresponding game resource files. Among them, the first terminal 102 and the second terminal 104 can be, but are not limited to, various personal computers, laptops, smart phones and tablet computers, and the cloud server 106 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0045] In one embodiment, Figure 2 As shown, a resource storage method is provided, which is applied to Figure 1 Taking the first terminal in the example as an example, the method includes the following steps S202 to S206.
[0046] S202, obtaining game resource files.
[0047] Taking the Unity game development platform as an example, developers can use Unity to create a game project and develop corresponding game files under the game project. The game files include game program logic files (such as game operation logic, reading logic, etc.) and game resource files (such as sounds, pictures, animations, etc. that need to be loaded during the game operation). The first terminal can obtain the game files from Unity and process the game files.
[0048] S204, compress and store the game resource files to generate a resource compression package in a virtual file system format; the virtual file system format includes: a data storage component and a verification component, the data storage component is used to store the game resource files in blocks, and the verification component is used to store verification data of the game resource files.
[0049] The game resource files used by Unity are usually in the Assetbundle (AB) format. Game files usually contain a large number of AB format game resource files. After the first terminal obtains the AB format game resource files from Unity, it can compress and store all the AB format game resource files and package them into a resource compression package in the virtual file system (VFS) format for easy reading.
[0050] S206, uploading the resource compression package to the cloud server for downloading when the game starts.
[0051] The first terminal can process the game program logic file into an application package (apk or ipa) and upload it to the application store, and process the game resource file into a resource compression package in VFS format and upload it to the cloud server. The user can download the application package from the application store and install the corresponding game to the second terminal. When the second terminal starts the game, it downloads the corresponding resource compression package from the cloud server.
[0052] In the above-mentioned resource storage method, by compressing and storing the game resource files into a resource compression package in the virtual file system format, the game resource files can be read directly from the resource compression package later, without the need to decompress each game resource file in the resource compression package to an additional storage space for reading, thereby reducing the storage space occupied; using block storage, the game resources can be loaded and displayed without downloading all the files during reading, thereby improving the game loading efficiency; in addition, by uploading the resource compression package to the cloud server, the problem of the game installation package being too large due to packaging the game resource files together into the game installation package can be avoided, thereby improving the success rate and efficiency of the game installation.
[0053] In one embodiment, the steps of compressing and storing game resource files to generate a resource compression package in a virtual file system format may specifically include the following steps: dividing each game resource file into blocks according to a preset block length to obtain block data; calculating the first encryption information of each game resource file and the second encryption information of each block data, and determining the verification data of the game resource file based on each first encryption information and each second encryption information; and generating a resource compression package in a virtual file system format based on the block data and the verification data.
[0054] Among them, the block length can be set according to the actual situation, for example, it is set to 16K. The game resource file is stored in the form of data blocks. For example, if the length of a game resource file is 32K, then the game resource file is divided into two 16K block data for storage after block processing.
[0055] The encrypted information can specifically be an MD5 value. The first encrypted information represents the MD5 value of the game resource file, and the second encrypted information represents the MD5 value of the block data. The message digest algorithm (MD5) can generate a special string (MD5 value) from a file according to certain rules. The MD5 value corresponding to a file is fixed. When the file content changes, its MD5 value will also change. Therefore, the MD5 value can be used as the file's encryption information to verify whether the file has been tampered with.
[0056] In this embodiment, by storing the game resource files in blocks and setting encryption information for each game resource file and each block data, the game resources are not easily cracked and tampered game resources are easily identified, thereby enhancing the security of the game resources.
[0057] In one embodiment, the virtual file system format further includes: a file header component and a bitmap component, wherein the file header component is used to store file header information, and the bitmap component is used to store block information of the game resource file. The step of generating a resource compression package in the virtual file system format based on the block data and the check data may specifically include the following steps: determining the block information of the game resource file based on the number of block data; determining the file header information based on the file header length, the total length of the game resource file, the check data, and the block information; and generating the resource compression package in the virtual file system format based on the file header information, the block data, the check data, and the block information.
[0058] The block information is used to indicate whether the data block is empty data, and is stored in the form of a bitmap. The bitmap can mark whether the data block is empty data for subsequent data writing. Specifically, each data block occupies a bit in the bitmap. If the data block stores data, the bit corresponding to the data block is set to 1. If the data block is empty data, the bit corresponding to the data block is set to 0. The file header length can be a preset file header size, for example, it can be set to 172 bytes. The total length of the game resource file represents the total size of all game resource files, and the required storage capacity can be determined based on the total size of the game resource files. The verification data can be specifically stored in the form of a hash table, including a file hash table and a data hash table, which respectively store the first encryption information of the game resource file and the second encryption information of the block data.
[0059] In one embodiment, the step of determining the file header information based on the file header length, the total length of the game resource file, the check data and the block information may specifically include the following steps: determining the basic header information based on the file header length, the total length of the game resource file, the block length, the position and length of the check data, and the position and length of the block information; calculating the third encrypted information of the check data, and calculating the fourth encrypted information based on the third encrypted information and the basic header information; determining the file header information based on the basic header information, the third encrypted information and the fourth encrypted information.
[0060] The file header information includes basic header information, third encryption information, and fourth encryption information. The basic header information includes: file header length, total length of the game resource file, block length, position and length of verification data, and position and length of block information. The position and length of the verification data can specifically be the position and length of the Hash table where the verification data is located. The position and length of the block information can specifically be the position and length of the Bitmap where the block information is located. The third encryption information can specifically be the MD5 value of the Hash table where the verification data is located, which is used to verify the Hash table. The third encryption information and the basic header information are regarded as a whole file, and the fourth encryption information represents the MD5 value of the whole file, which is used to verify the file header information.
[0061] like Figure 3 As shown, a schematic diagram of a resource compression package (Res.vfs) in VFS format in one embodiment is shown. The VFS format includes the following four components: a header component (Header), a data storage component (Data Segment), a check component (HashTable) and a bitmap component (Bitmap). The Header includes: basic header information (HeaderInfo), hash table encryption information (HashTable MD5) and header encryption information (Header MD5). HeaderInfo includes: file type (dwID), file header length (HeaderSize), version information (FormatVersion), block length (MD5PieceSize), file length (Archivesize), hash table position (HashTablePos), hash table length (HashTableSize), bitmap position (BitmapPos), and bitmap length (BitmapSize). The Data Segment includes all game resource files (File), each game resource file is stored in the form of data blocks, and the size of each data block is 16K. The HashTable contains the encryption information of the game resource file (File MD5) and the encryption information of the block data (Block MD5). Specifically, when compressing and storing the game resource file, you can first create an empty VFS format file, and then write the corresponding information of each component in the order of Header, DataSegment, HashTable, and Bitmap to obtain a VFS format resource compression package.
[0062] In the above embodiment, by compressing and storing scattered game resource files into a resource compression package in a virtual file system format, the integrity of the game resources can be enhanced; by reading the game resource files from the resource compression package in the virtual file system format, there is no need to decompress each game resource file in the resource compression package to an additional storage space for reading, which can reduce the storage space occupied; by storing the game resource files in blocks and setting verification data, it helps to identify tampered resources, which can enhance the security of the game resources; by uploading the resource compression package to the cloud server, the capacity of the game installation package or update package can be greatly reduced, lowering the threshold for new game entrants.
[0063] In one embodiment, Figure 4 As shown, a resource reading method is provided, which is applied to Figure 1 Taking the second terminal in as an example, the method includes the following steps S402 to S404.
[0064] S402, when the game is started, the corresponding resource compression package is downloaded from the cloud server; the resource compression package represents a resource compression package in a virtual file system format generated after compressing and storing the game resource files, and the virtual file system format includes: a data storage component and a verification component, the data storage component is used to store the game resource files in blocks, and the verification component is used to store the verification data of the game resource files.
[0065] S404: Read the resource compression package to obtain the corresponding game resource file.
[0066] In the above-mentioned resource reading method, when the game is started, the corresponding resource compression package is downloaded from the cloud server. The resource compression package is a resource compression package in a virtual file system format generated by compressing and storing the game resource files of the started game. The game resource files can be read directly from the resource compression package without decompressing each game resource file in the resource compression package to an additional storage space for reading, thereby reducing the storage space occupied; using block storage, the game resources can be loaded and displayed without downloading all files during reading, thereby improving the game loading efficiency; in addition, by downloading the resource compression package from the cloud server, the problem of the game installation package being too large due to packaging the game resource files together into the game installation package can be avoided, thereby improving the success rate and efficiency of game installation.
[0067] In one embodiment, a method for generating a resource compression package in a virtual file system format includes the following steps: segmenting each game resource file into blocks according to a preset segment length to obtain segmented data; calculating first encryption information for each game resource file and second encryption information for each segmented data; determining verification data for the game resource file based on each first encryption information and each second encryption information; and generating a resource compression package in a virtual file system format based on the segmented data and the verification data. The specific description of this embodiment can be found in the previous embodiment and will not be repeated here.
[0068] In one embodiment, the virtual file system format further includes: a file header component and a bitmap component, wherein the file header component is used to store file header information, and the bitmap component is used to store block information of the game resource file; the step of generating a resource compression package in the virtual file system format based on the block data and the check data may specifically include the following steps: determining the block information of the game resource file based on the number of block data; determining the file header information based on the file header length, the total length of the game resource file, the check data, and the block information; and generating a resource compression package in the virtual file system format based on the file header information, the block data, the check data, and the block information. The specific description of this embodiment can be referred to the previous embodiment and will not be repeated here.
[0069] In one embodiment, the step of determining the file header information based on the file header length, the total length of the game resource file, the check data, and the block information may specifically include the following steps: determining the basic header information based on the file header length, the total length of the game resource file, the block length, the position and length of the check data, and the position and length of the block information; calculating third encrypted information of the check data, and calculating fourth encrypted information based on the third encrypted information and the basic header information; and determining the file header information based on the basic header information, the third encrypted information, and the fourth encrypted information. The specific description of this embodiment can be referred to the previous embodiment and will not be repeated here.
[0070] In one embodiment, the step of reading the resource compression package to obtain the corresponding game resource file may specifically include the following steps: reading the file header information in the resource compression package based on the file header length; verifying the file header information based on the fourth encryption information, and after the verification passes, reading the verification data in the resource compression package; verifying the verification data based on the third encryption information, and after the verification passes, determining the location and length of the game resource file; reading the block data in the resource compression package based on the location and length of the game resource file, and obtaining the corresponding game resource file based on the read block data.
[0071] Specifically, after obtaining the resource compression package (Res.vfs) in VFS format, you can open the file handle of Res.vfs, read the first 172 bytes of Res.vfs (the file header length is 172 bytes), and obtain the file header information of Res.vfs (that is, the information included in the Header); verify the file header information based on the fourth encryption information (Header MD5), and after the verification passes, read the verification data (that is, HashTable data) in Res.vfs; verify the HashTable data based on the third encryption information (HashTableMD5), and after the verification passes, rebuild the file directory tree; determine the location and length of the game resource file according to the file directory tree; read the block data in Res.vfs according to the location and length of the game resource file, and restore the original game resource file based on the read block data.
[0072] In this embodiment, by directly reading the game resource files in the resource compression package, there is no need to decompress each game resource file in the resource compression package to an additional storage space for reading, thereby reducing the storage space occupied. Compared with reading multiple scattered game resource files separately, the reading efficiency can be improved, thereby improving the game loading efficiency and reducing user waiting time.
[0073] In one embodiment, the step of reading the resource compression package to obtain the corresponding game resource file can specifically be: calling the virtual file system format reading plug-in, reading the resource compression package based on the virtual file system format reading plug-in instance, and obtaining the corresponding game resource file.
[0074] In this embodiment, the VFS format reading plug-in is called, and the resource compression package is read based on the VFS format reading plug-in instance, so that the resource compression package can be read according to the reading method defined in the VFS format reading plug-in instance, thereby realizing direct reading of the VFS file.
[0075] like Figure 5 As shown, a schematic diagram of a Unity plug-in use case in an embodiment is provided. The Unity plug-in system can take over the underlying Unity file system to implement a direct read solution for VFS files, while this read solution is transparent to upper-level users. Specifically, the VFS library is first referenced to the Unity Plugin. During initialization, a VFS read plug-in instance is created. The VFS format read plug-in instance is registered with the Unity file system through FileSystem::MountHandler (VFS format read plug-in instance). When Unity loads AB format files, the path prefix is vfs: / / . In this way, when reading AB format files, it will read according to the read method defined in the VFS format read plug-in instance.
[0076] This application also provides an application scenario, which applies the above-mentioned resource storage and reading method. Specifically, Figure 6 As shown, the application of the resource storage and reading method in this application scenario is as follows:
[0077] The developer checks out the Unity project from Git or SVN to the first terminal. The first terminal processes the game resource files in the Unity project into a resource compression package (Res.vfs) in the virtual file system format, processes the game program logic files into an application package (mini.apk), and simultaneously generates a version upgrade configuration file (config). The first terminal uploads Res.vfs to the cloud server, updates the config to the policy server, and uploads the mini.apk to the app store. The user downloads the mini.apk from the app store and installs it on the second terminal. When the second terminal launches the game corresponding to the mini.apk, it first obtains the current latest program version from the policy server and then downloads Res.vfs from the cloud server. This download can only download incremental data, without downloading the entire file. After a successful download, the second terminal performs an integrity check on Res.vfs. If the check passes, it reads the game resource files in Res.vfs to load game-related content.
[0078] It should be understood that although Figure 2 、 4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2 、 4 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0079] In one embodiment, Figure 7 As shown, a resource storage device 700 is provided. The device can be a software module or a hardware module, or a combination of the two to form a part of a computer device. The device specifically includes: an acquisition module 710, a storage module 720 and an upload module 730, wherein:
[0080] The acquisition module 710 is used to acquire game resource files.
[0081] The storage module 720 is used to compress and store game resource files and generate resource compression packages in the virtual file system format; the virtual file system format includes: a data storage component and a verification component, the data storage component is used to store game resource files in blocks, and the verification component is used to store verification data of game resource files.
[0082] The upload module 730 is used to upload the resource compression package to the cloud server for downloading when the game is started.
[0083] In one embodiment, the storage module 720 includes a block division unit, a determination unit, and a generation unit. The block division unit is configured to divide each game resource file into blocks according to a preset block length to obtain block data. The determination unit is configured to calculate first encryption information for each game resource file and second encryption information for each block data, and determine verification data for the game resource file based on each first encryption information and each second encryption information. The generation unit is configured to generate a resource compression package in a virtual file system format based on the block data and the verification data.
[0084] In one embodiment, the virtual file system format further includes: a file header component and a bitmap component, wherein the file header component is used to store file header information, and the bitmap component is used to store block information of the game resource file. When generating a resource compression package in the virtual file system format based on the block data and the check data, the generation unit is specifically configured to: determine the block information of the game resource file based on the number of block data; determine the file header information based on the file header length, the total length of the game resource file, the check data, and the block information; and generate the resource compression package in the virtual file system format based on the file header information, the block data, the check data, and the block information.
[0085] In one embodiment, the generation unit determines the block information of the game resource file based on the number of block data; determines the file header information based on the file header length, the total length of the game resource file, the check data and the block information, and is specifically used to: determine the basic header information based on the file header length, the total length of the game resource file, the block length, the position and length of the check data, and the position and length of the block information; calculate the third encryption information of the check data, and calculate the fourth encryption information based on the third encryption information and the basic header information; determine the file header information based on the basic header information, the third encryption information and the fourth encryption information.
[0086] For the specific definition of the resource storage device, please refer to the definition of the resource storage method above, which will not be repeated here. The various modules in the above-mentioned resource storage device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0087] In one embodiment, Figure 8 As shown, a resource reading device 800 is provided. The device can be a software module or a hardware module, or a combination of the two to form a part of a computer device. The device specifically includes: a download module 810 and a reading module 820, wherein:
[0088] Download module 810 is used to download the corresponding resource compression package from the cloud server when the game is started; the resource compression package represents a resource compression package in a virtual file system format generated after compressing and storing the game resource files. The virtual file system format includes: a data storage component and a verification component. The data storage component is used to store the game resource files in blocks, and the verification component is used to store the verification data of the game resource files.
[0089] The reading module 820 is used to read the resource compression package to obtain the corresponding game resource file.
[0090] In one embodiment, a method for generating a resource compression package in a virtual file system format includes: performing block processing on each game resource file according to a preset block length to obtain block data; calculating the first encryption information of each game resource file and the second encryption information of each block data, and determining the verification data of the game resource file based on each first encryption information and each second encryption information; and generating a resource compression package in a virtual file system format based on the block data and the verification data.
[0091] In one embodiment, the virtual file system format also includes: a file header component and a bitmap component, the file header component is used to store file header information, and the bitmap component is used to store block information of the game resource file; generating a resource compression package in the virtual file system format based on the block data and the verification data, including: determining the block information of the game resource file based on the number of block data; determining the file header information based on the file header length, the total length of the game resource file, the verification data and the block information; generating a resource compression package in the virtual file system format based on the file header information, the block data, the verification data and the block information.
[0092] In one embodiment, the file header information is determined based on the file header length, the total length of the game resource file, the check data, and the block information, including: determining the basic header information based on the file header length, the total length of the game resource file, the block length, the position and length of the check data, and the position and length of the block information; calculating the third encrypted information of the check data, and calculating the fourth encrypted information based on the third encrypted information and the basic header information; determining the file header information based on the basic header information, the third encrypted information, and the fourth encrypted information.
[0093] In one embodiment, when the reading module 820 reads the resource compression package and obtains the corresponding game resource file, it is specifically used to: read the file header information in the resource compression package according to the file header length; verify the file header information based on the fourth encryption information, and after the verification is passed, read the verification data in the resource compression package; verify the verification data based on the third encryption information, and after the verification is passed, determine the location and length of the game resource file; read the block data in the resource compression package according to the location and length of the game resource file, and obtain the corresponding game resource file based on the read block data.
[0094] In one embodiment, when the reading module 820 reads the resource compression package and obtains the corresponding game resource file, it is specifically used to: call the virtual file system format reading plug-in, read the resource compression package based on the virtual file system format reading plug-in instance, and obtain the corresponding game resource file.
[0095] For the specific definition of the resource reading device, please refer to the definition of the resource reading method above, which will not be repeated here. The various modules in the above-mentioned resource reading device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0096] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 9As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a resource storage method and / or a resource reading method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0097] Those skilled in the art will understand that Figure 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0098] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.
[0099] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above-mentioned method embodiments when executed by a processor.
[0100] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps of each of the above-described method embodiments.
[0101] It should be understood that the terms "first", "second", etc. in the above embodiments are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features.
[0102] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0103] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0104] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A resource storage method, characterized in that: The method comprises: Get game resource files; Create an empty file in virtual file system format; The game resource file is compressed and stored, and the information corresponding to each component in the empty file is written in sequence to generate a resource compression package in a virtual file system format; the virtual file system format includes: a data storage component, a verification component, and a bitmap component; the data storage component is used to store the game resource file in the form of data blocks, the verification component is used to store verification data of the game resource file, and the bitmap component is used to store block information of the game resource file; the block information is used to identify whether the data block is empty data, so as to facilitate subsequent data writing; The resource compression package is uploaded to the cloud server for downloading when the game is started.
2. The method according to claim 1, characterized in that Compressing and storing the game resource files to generate a resource compression package in a virtual file system format includes: Each of the game resource files is divided into blocks according to a preset block length to obtain block data; Calculating first encryption information of each of the game resource files and second encryption information of each of the block data, and determining verification data of the game resource file based on each of the first encryption information and each of the second encryption information; A resource compression package in a virtual file system format is generated according to the block data and the verification data.
3. The method according to claim 2, characterized in that The virtual file system format further includes a file header component, and the file header component is used to store file header information; Generating a resource compression package in a virtual file system format according to the block data and the verification data, including: Determining the block information of the game resource file according to the number of the block data; Determine file header information according to the file header length, the total length of the game resource file, the verification data, and the block information; A resource compression package in a virtual file system format is generated according to the file header information, the block data, the verification data, and the block information.
4. The method according to claim 3, characterized in that Determining file header information according to the file header length, the total length of the game resource file, the verification data, and the block information includes: Determine basic header information based on the file header length, the total length of the game resource file, the block length, the position and length of the verification data, and the position and length of the block information; Calculating third encrypted information of the verification data, and calculating fourth encrypted information based on the third encrypted information and the basic header information; The file header information is determined according to the header basic information, the third encrypted information, and the fourth encrypted information.
5. A resource reading method, characterized in that: The method comprises: When the game is started, the corresponding resource compression package is downloaded from the cloud server; the resource compression package represents a resource compression package in a virtual file system format generated after compressing and storing the game resource files, and the virtual file system format includes: a data storage component, a verification component, and a bitmap component. The data storage component is used to store the game resource files in the form of data blocks, and the verification component is used to store verification data of the game resource files; the bitmap component is used to store the block information of the game resource files; the block information is used to identify whether the data block is empty data, so as to facilitate subsequent data writing; The resource compression package is read to obtain the corresponding game resource file.
6. The method according to claim 5, characterized in that The method for generating a resource compression package in the virtual file system format includes: Each of the game resource files is divided into blocks according to a preset block length to obtain block data; Calculating first encryption information of each of the game resource files and second encryption information of each of the block data, and determining verification data of the game resource file based on each of the first encryption information and each of the second encryption information; A resource compression package in a virtual file system format is generated according to the block data and the verification data.
7. The method according to claim 6, characterized in that The virtual file system format further includes a file header component, and the file header component is used to store file header information; Generating a resource compression package in a virtual file system format according to the block data and the verification data, including: Determining the block information of the game resource file according to the number of the block data; Determine file header information according to the file header length, the total length of the game resource file, the verification data, and the block information; A resource compression package in a virtual file system format is generated according to the file header information, the block data, the verification data, and the block information.
8. The method according to claim 7, characterized in that Determining file header information according to the file header length, the total length of the game resource file, the verification data, and the block information includes: Determine basic header information based on the file header length, the total length of the game resource file, the block length, the position and length of the verification data, and the position and length of the block information; Calculating third encrypted information of the verification data, and calculating fourth encrypted information based on the third encrypted information and the basic header information; The file header information is determined according to the header basic information, the third encrypted information, and the fourth encrypted information.
9. The method according to claim 8, characterized in that Read the resource compression package to obtain the corresponding game resource file, including: Read the file header information in the resource compression package according to the file header length; Verifying the file header information based on the fourth encrypted information, and after the verification passes, reading the verification data in the resource compression package; Verifying the verification data based on the third encrypted information, and determining the location and length of the game resource file after the verification passes; According to the position and length of the game resource file, the block data in the resource compression package is read, and the corresponding game resource file is obtained based on the read block data.
10. The method according to claim 5, characterized in that Read the resource compression package to obtain the corresponding game resource file, including: The virtual file system format reading plug-in is called, and the resource compression package is read based on the virtual file system format reading plug-in instance to obtain the corresponding game resource file.
Citation Information
Patent Citations
Virtual resource management method and system
CN106776012A
File compression and decompression method and device
CN109582653A