Introduction
This plugin can unzip the .zip
file and read the zipped file in memory. The function likes PakPlatformFile.
You can zip the asset (.uasset
, .umap
, etc) of UE4, and mount it like .pak
.
Feature
- Unzip in memory without disk
- Only read
- Just use zlib to unzip the file
- Mount and unmount
- Need the mount point
- Support to unzip with the password
- Blueprint functions
Usage
Download the code from https://github.com/jixingcn/ZipPlatformFile, and unzip into your UE4
’s Plugins
, or add it as the git
repo of your UE4
.
Example
There is a D:\test.zip
file, its passward is password
, and its structure like this:
- scheme.json
- companies/
- companyA/
- users/
- john.json
- john.xlsx
- users/
- companyB/
- users/
- lily.json
- lili.docx
- lily.xlsx
- users/
- companyA/
Mount a .zip
file
Use UZipPlatformFileBlueprintFunctionLibrary::Mount
mount the file, and the mount point is /Game/test_zip
:
Blueprint:
Code:
UZipPlatformFileBlueprintFunctionLibrary::Mount(this, TEXT("/Game/test_zip"), TEXT("D:\\test.zip"), TEXT("password"));
You can custom the mount point, but the root of the mount point need to reference the
UE4
official document. For examples:
/Engine
: is theContent
directory of the engine/Game
: is theContent
directory of the project/ZipPlatformFile
: is thePlugins/ZipPlatformFile/Content
directory of the projectThe password is empty if the file is without any password.
Load a file from .zip
Load companies/companyB/users/lily.json
:
Blueprint:
Code:
FString LilyJsonContext;
FFileHelp::LoadToString(TEXT("/Game/test_zip/companies/companyB/users/lily.json"), LilyJsonContext);
/// Or
UZipPlatformFileBlueprintFunctionLibrary::LoadFileToString(this, TEXT("/Game/test_zip/companies/companyB/users/lily.json"), LilyJsonContext);
Load companies/companyB/users/lily.xlsx
:
TArray<uint8> LilyXlsxContext;
FFileHelp::LoadFileToArray(TEXT("/Game/test_zip/companies/companyB/users/lily.xlsx"), LilyXlsxContext);
/// Or
UZipPlatformFileBlueprintFunctionLibrary::LoadFileToArray(this, TEXT("/Game/test_zip/companies/companyB/users/lily.json"), LilyXlsxContext);
Check a file or directory does exist
Blueprint:
Code:
FPaths::FileExists(TEXT("/Game/test_zip/scheme.json"));
/// Or
UZipPlatformFileBlueprintFunctionLibrary::FileExists(this, TEXT("/Game/test_zip/scheme.json"));
FPaths::DirectoryExists(TEXT("/Game/test_zip/companies/companyA"));
/// Or
UZipPlatformFileBlueprintFunctionLibrary::DirectoryExists(this, TEXT("/Game/test_zip/companies/companyA"));
Get the timestamp of a file or directory
Blueprint:
Code:
FDateTime CreationTime, AccessTimeStamp;
UZipPlatformFileBlueprintFunctionLibrary::GetTimeStamp(this, TEXT("/Game/test_zip/companies/companyA/users/john.xlsx"), CreationTime, AccessTimeStamp);
Get the status of a file or directory
FFileStatData FileStatData;
UZipPlatformFileBlueprintFunctionLibrary::GetFileStatData(this, TEXT("/Game/test_zip/scheme.json"), FileStatData);
Unmount the .zip
file
Blueprint:
Code:
UZipPlatformFileBlueprintFunctionLibrary::Unmount(this, TEXT("D:\\test.zip"));
Notice
You must use IPlatformFile
or FFileHelper
or FPaths
or UZipPlatformFileBlueprintFunctionLibrary
to operate the file in a .zip
file, because the plugin is an extend of IPlatformFile
.
If you want to load the UE4
asset from the .zip
file, you are careful about the mount point.
Update
Thanks
https://blueprintue.com/ is a great 👍 website, it can show the blueprint in HTML.