Download

[Plugin] ZipUtility (7zip)

Update to 0.2.2
-Thanks to #4](Allow concurrent usage of zip library for list, zip and unzip operations by error454 · Pull Request #4 · getnamo/Zip) @hyperdr1ve](error454 (Zachary Burke) · GitHub) the plugin now supports multiple simultaneous operations working independently on their own threads with proper callbacks.
-Added windows listing folder content function with FileListInterface expected to receive the content data

Example of listing contents of a folder:

Note that self should respond to a FileListInterface.

releases found at the usual place Releases · getnamo/ZipUtility-ue4 · GitHub

I’ll be taking a deeper look at the memory management of the new async architecture this week. In the meantime I wanted to ask about 7z library.

I noticed that some archives of mine that were created on Linux contain illegal file names for windows. When I unzip these, 7z seems to automatically replace the invalid characters with underscores. The problem is that I use the archive listing functions to generate the archive contents map, so my map contains the illegal characters and I can’t find the files after extraction.

I didn’t see a 7z call that could convert an invalid file name to a valid one. Do you know anything about where this happens? I may need to write some transfer functions if they’re not accessible.

Great, making sure we gc appropriately and don’t have memory leaks would be helpful.

Not sure about the name conversion. The underlying library is found here: GitHub - getnamo/7zip-cpp: Fork of SevenZip++ for modern builds. which links to the raw 7z sources here: GitHub - keithjjones/7z at c8852a6dcaf99ae0fb29de8d97736ffa1b3a180e

You should have plenty of access to modify and add any missing underlying functionality. Note that we use the COM-port approach to interacting with the 7z dll and that there is a UE4 specific branch that has slightly different includes for the lib to hide windows data types.

Update to 0.3.0
-Annoying windows header fixes for 4.15

grab the latest at the usual

Dear, can you add a sample of C ++?QQ图片20170425164152.png
I have a question,How to get a OnProgress Event in C++;

Simple C++:

Let’s say you have a class called UMyClass. You then add the IZipUtilityInterface to it via multiple inheritance e.g.



class UMyClass : public UObject, public IZipUtilityInterface
{
   GENERATED_BODY()
    ...
};

Because the events are BlueprintNativeEvent you add the C++ implementation of the events like so



class UMyClass : public UObject, public IZipUtilityInterface
{
    GENERATED_BODY()
    ...

    //event overrides
    virtual void OnProgress_Implementation(const FString& archive, float percentage, int32 bytes) override;
    virtual void OnDone_Implementation(const FString& archive, EZipUtilityCompletionState CompletionState) override;
    virtual void OnStartProcess_Implementation(const FString& archive, int32 bytes) override;
    virtual void OnFileDone_Implementation(const FString& archive, const FString& file) override;
    virtual void OnFileFound_Implementation(const FString& archive, const FString& file, int32 size) override;
};

and in your c++ file you add the implementation



void UMyClass::OnProgress_Implementation(const FString& archive, float percentage, int32 bytes)
{
    //your code here
}


To call a ziputility function you first get a valid pointer to your class (I leave that up to you) e.g.



UMyClass* MyZipClass = NewObject<UMyClass>(); //or you may already have a valid pointer from allocating elsewhere


then you pass the pointer to your class with the IZipUtilityInterface as your second parameter (and if you use them, any other optional parameters such as compression format)



UZipFileFunctionLibrary::Unzip(FString("C:/path/to/your/zip.7z"), MyZipClass);


and then you should receive your callbacks!

Optional Method using Lambda Expressions:
There is a lambda method I’ve added a while back ZipUtility-ue4/ZULambdaDelegate.h at master · getnamo/ZipUtility-ue4 · GitHub used here: ZipUtility-ue4/ZipFileFunctionLibrary.cpp at 6c30762622e6cbc708da85ee35c75c167c7ea093 · getnamo/ZipUtility-ue4 · GitHub

The signature is


static bool UnzipWithLambda(	const FString& ArchivePath,
							TFunction<void()> OnDoneCallback,
							TFunction<void(float)> OnProgressCallback = nullptr,
							TEnumAsByte<ZipUtilityCompressionFormat> format = COMPRESSION_FORMAT_UNKNOWN);

example using this



UZipFileFunctionLibrary::UnzipWithLambda(FString("C:/path/to/your/zip.7z"),
    ]()
    {
         //Called when done
    },
    ](float Percent)
    {
         //called when progress updates with % done
    });


or



UZipFileFunctionLibrary::UnzipWithLambda(FString("C:/path/to/your/zip.7z"), nullptr, ](float Percent)
    {
         //called when progress updates with % done
    });


if you’re not interested in the done callback.

Let me know if that helps :slight_smile:

Edit:
I’ve added these instructions on the github readme:

very clarity!thanks big god。

@StaticMao 不客气 :slight_smile:

what!你是中国人啊

我不是,但由于技术,世界很小 :slight_smile:

Hi getnamo! I have a need,one by one to unzip the file,i ues Queue,but At the time of the second,Stable there was an error,


But I was called by your way,Have you met?

Hey there, I’m using this for a new project and it’s working great - thanks so much. One thing: I had to change the .uplugin type from “Development” to “Runtime” for it to work in packaged builds (it would package fine, but fail to Zip things with the Development type). The working ZipUtility.uplugin file now looks like:



{
	"FileVersion": 3,
	"Version": 2,
	"VersionName": "0.3.0",
	"FriendlyName": "ZipUtility",
	"Description": "",
	"Category": "Utility",
	"CreatedBy": "Getnamo",
	"CreatedByURL": "http://www.getnamo.com",
	"DocsURL": "https://github.com/getnamo/ZipUtility-ue4",
	"MarketplaceURL": "",
	"SupportURL": "",
	"EnabledByDefault": false,
	"CanContainContent": false,
	"IsBetaVersion": false,
	"Installed": false,
	"Modules": 
		{
			"Name": "ZipUtility",
			"Type": "Runtime",                     // Changed this line
			"LoadingPhase": "Default",
			"WhitelistPlatforms": 
				"Win64",
				"Win32"
			]
		}
	]
}


Cheers!

I haven’t seen this, do you have a log and example C++ code that calls this in a queue?

Ah nice catch on oversight, consider making a pull request to get the change included in the plugin.

Hi,getnamo
I’ve created an official sample programs in the third person,When i execute Unzip of the OnFire(),
code:
f61b9aba823fa4e10e866bc243742c2e30c5ef9f.png

MyClass.h:

#include “UObject/NoExportTypes.h”
#include “ZipFileFunctionLibrary.h”
#include “MyClass.generated.h”
UCLASS()
class UNZIP2_API UMyClass : public UObject, public IZipUtilityInterface
{
GENERATED_BODY()

virtual void OnProgress_Implementation(const FString& archive, float percentage, int32 bytes) override;
virtual void OnDone_Implementation(const FString& archive, EZipUtilityCompletionState CompletionState) override;
virtual void OnStartProcess_Implementation(const FString& archive, int32 bytes) override;
virtual void OnFileDone_Implementation(const FString& archive, const FString& file) override;
virtual void OnFileFound_Implementation(const FString& archive, const FString& file, int32 size) override;

};

MyClass.cpp:

#include “Unzip2.h”
#include “MyClass.h”

void UMyClass::OnProgress_Implementation(const FString& archive, float percentage, int32 bytes)
{

UE_LOG(LogClass, Log, TEXT("OnProgress_Implementation!%lf"), percentage);

}
void UMyClass::OnDone_Implementation(const FString& archive, EZipUtilityCompletionState CompletionState)
{

UE_LOG(LogClass, Log, TEXT("OnDone_Implementation!"));

}
void UMyClass::OnStartProcess_Implementation(const FString& archive, int32 bytes)
{
UE_LOG(LogClass, Log, TEXT(“OnStartProcess_Implementation!”));
}
void UMyClass::OnFileDone_Implementation(const FString& archive, const FString& file)
{

}
void UMyClass::OnFileFound_Implementation(const FString& archive, const FString& file, int32 size)
{
UE_LOG(LogClass, Log, TEXT(“OnFileFound_Implementation!”));
}

The first execute absolutely no problem,I will wait for the complete Unzip,Problems arise when the second or third time,The picture above is wrong,Is there anything else I didn’t do it?

Just sanity checks:

  1. Do you wait for completion before starting the second operation?
  2. Garbage collection usually takes 60 seconds, do any of your unzip operations take longer than that?

Either way I’ve added the issue to github for tracking Multiple sequential unzips using interface in C++ · Issue #12 · getnamo/ZipUtility-ue4 · GitHub, feel free to add to it.

Update to 0.3.3
-compile fixes for 4.17
-runtime plugin

Now ready for your 4.17 drag and drop uses. Available here: Releases · getnamo/ZipUtility-ue4 · GitHub

Hello,

I posted an issue on the GitHub repo but perhaps this is a better place for it…

I’m trying to add the plugin to my project but I keep getting linking errors when compiling that I don’t quite understand:


CompilerResultsLog: [1/1] Link UE4Editor-TestProject-7049.dll
CompilerResultsLog: Error: LINK : fatal error LNK1181: cannot open input file 'C:\Users\prisonerjohn\Desktop\TestProject\Plugins\ZipUtility-ue4\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-ZipUtility.lib'
CompilerResultsLog: ERROR: UBT ERROR: Failed to produce item: C:\Users\prisonerjohn\Desktop\TestProject\Binaries\Win64\UE4Editor-TestProject-7049.dll

I followed the instructions in the README to add the plugin (including adding the module name to the Build.cs file), and tried restarting both Unreal Engine and Visual Studio, but still get the same issue.

I found the following similar issue on the forums, but it didn’t resolve my problem.

Thanks in advance for the help!

I had the same problem when trying to add the plugin to my C++ project (it worked fine in blueprints). Struggled with this for about a day and it is finally working. I think the main problem for me was that “ATL” was missing.

There is a path in the ZipUtility.Build.CS file that reads:
“C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/atlmfc”

But I had no such folder. I solved it by opening the Visual Studio Installer, clicking “more” and “modify”. I then installed the “Desktop development with C++”-package which includes ATL. Now the folder appeared and I could compile.

Excellent find, I’ve added this section in the readme pertaining to it: GitHub - getnamo/ZipUtility-ue4: Event driven 7zip utility plugin for Unreal Engine 4. NB: It should auto-detect the ats.lib since this pull request got merged: Removed hardcoded ATL path, using actual VS installation path instead by Xorboo · Pull Request #26 · getnamo/ZipUtil

Hi getnamo!
I’m using your plugin in ue4.21 and i’m loving it!
In the editor the plug in work, i’m able to extract a zip that i dowloaded with an http request, to install an update of my application.
But when i try to build the application for windows, it fails here:



UATHelper: Packaging (Windows (32-bit)): ********** BUILD COMMAND STARTED **********
UATHelper: Packaging (Windows (32-bit)): Running: C:\Program Files\Epic Games\UE_4.21\Engine\Binaries\DotNET\UnrealBuildTool.exe Test_zip Win32 Development -Project=D:\UnrealProj_generic\Test_zip\Test_zip.uproject  D:\UnrealProj_generic\Test_zip\Test_zip.uproject -NoUBTMakefiles  -remoteini="D:\UnrealProj_generic\Test_zip" -skipdeploy -Manifest=D:\UnrealProj
_generic\Test_zip\Intermediate\Build\Manifest.xml -NoHotReload -log="C:\Users\3DVR\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.21\UBT-Test_zip-Win32-Development.txt"
UATHelper: Packaging (Windows (32-bit)):   Using Visual Studio 2017 14.16.27023 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023) and Windows 10.0.17763.0 SDK (C:\Program Files (x86)\Windows Kits\10).
UATHelper: Packaging (Windows (32-bit)):   ZipUtility: Found VS path in registry: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
UATHelper: Packaging (Windows (32-bit)):   D:\UnrealProj_generic\Test_zip\Plugins\ZipUtility-ue4\Source\ZipUtility\ZipUtility.Build.cs: warning: Referenced directory 'C:\Program Files\Epic Games\UE_4.21\Engine\Source\ZipUtility\Public' does not exist.
PackagingResults: Warning: Referenced directory 'C:\Program Files\Epic Games\UE_4.21\Engine\Source\ZipUtility\Public' does not exist.
UATHelper: Packaging (Windows (32-bit)):   D:\UnrealProj_generic\Test_zip\Plugins\ZipUtility-ue4\Source\WindowsUtility\WindowsFileUtility.Build.cs: warning: Referenced directory 'C:\Program Files\Epic Games\UE_4.21\Engine\Source\WindowsFileUtility\Public' does not exist.
UATHelper: Packaging (Windows (32-bit)):   D:\UnrealProj_generic\Test_zip\Plugins\ZipUtility-ue4\Source\WindowsUtility\WindowsFileUtility.Build.cs: warning: Referenced directory 'D:\UnrealProj_generic\Test_zip\Plugins\ZipUtility-ue4\Source\WindowsFileUtility\Private' does not exist.
PackagingResults: Warning: Referenced directory 'C:\Program Files\Epic Games\UE_4.21\Engine\Source\WindowsFileUtility\Public' does not exist.
PackagingResults: Warning: Referenced directory 'D:\UnrealProj_generic\Test_zip\Plugins\ZipUtility-ue4\Source\WindowsFileUtility\Private' does not exist.
UATHelper: Packaging (Windows (32-bit)):   Parsing headers for Test_zip
UATHelper: Packaging (Windows (32-bit)):     Running UnrealHeaderTool "D:\UnrealProj_generic\Test_zip\Test_zip.uproject" "D:\UnrealProj_generic\Test_zip\Intermediate\Build\Win32\Test_zip\Development\Test_zip.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
UATHelper: Packaging (Windows (32-bit)):   Reflection code generated for Test_zip in 6,2352186 seconds
UATHelper: Packaging (Windows (32-bit)):   Writing manifest to D:\UnrealProj_generic\Test_zip\Intermediate\Build\Manifest.xml
UATHelper: Packaging (Windows (32-bit)):   Building 14 actions with 16 processes...
UATHelper: Packaging (Windows (32-bit)):     [1/14] PCH.ZipUtility.cpp
UATHelper: Packaging (Windows (32-bit)):     [2/14] PCH.WindowsFileUtility.cpp
UATHelper: Packaging (Windows (32-bit)):     [3/14] Module.WindowsFileUtility.gen.cpp
UATHelper: Packaging (Windows (32-bit)):     [4/14] Module.ZipUtility.gen.cpp
UATHelper: Packaging (Windows (32-bit)):     [5/14] Module.WindowsFileUtility.cpp
UATHelper: Packaging (Windows (32-bit)):     [6/14] Module.ZipUtility.cpp
UATHelper: Packaging (Windows (32-bit)):     D:\UnrealProj_generic\Test_zip\Plugins\ZipUtility-ue4\Source\ZipUtility\Private\ZipFileFunctionLibrary.cpp(50): error C4668: '_WIN64' non � definita come macro del preprocessore. Sostituzione con '0' per '#if/#elif'.
UATHelper: Packaging (Windows (32-bit)):     C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\INCLUDE\vcruntime_new.h(71): error C4577: � stato usato 'noexcept' senza specificare la modalit� di gestione delle eccezioni. La terminazione in caso di eccezione non � garantita. Specificare /EHsc
UATHelper: Packaging (Windows (32-bit)):     C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\INCLUDE\vcruntime_new.h(82): error C4577: � stato usato 'noexcept' senza specificare la modalit� di gestione delle eccezioni. La terminazione in caso di eccezione non � garantita. Specificare /EHsc
UATHelper: Packaging (Windows (32-bit)):     [7/14] SharedPCH.Engine.cpp
UATHelper: Packaging (Windows (32-bit)):     [8/14] Test_zip.cpp
UATHelper: Packaging (Windows (32-bit)):     [9/14] Test_zip.init.gen.cpp
UATHelper: Packaging (Windows (32-bit)):     [10/14] Test_zipGameMode.gen.cpp
UATHelper: Packaging (Windows (32-bit)):     [11/14] Test_zipCharacter.gen.cpp
UATHelper: Packaging (Windows (32-bit)):     [12/14] Test_zipGameMode.cpp
UATHelper: Packaging (Windows (32-bit)):     [13/14] Test_zipCharacter.cpp
UATHelper: Packaging (Windows (32-bit)):   ERROR: UBT ERROR: Failed to produce item: D:\UnrealProj_generic\Test_zip\Binaries\Win32\Test_zip.exe
UATHelper: Packaging (Windows (32-bit)):          (see C:\Users\3DVR\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.21\UBT-Test_zip-Win32-Development.txt for full exception trace)
PackagingResults: Error: UBT ERROR: Failed to produce item: D:\UnrealProj_generic\Test_zip\Binaries\Win32\Test_zip.exe
UATHelper: Packaging (Windows (32-bit)):   Total build time: 31,47 seconds (Parallel executor: 0,00 seconds)
UATHelper: Packaging (Windows (32-bit)): Took 31,6678059s to run UnrealBuildTool.exe, ExitCode=5
UATHelper: Packaging (Windows (32-bit)): ERROR: UnrealBuildTool failed. See log for more details. (C:\Users\3DVR\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.21\UBT-Test_zip-Win32-Development.txt)
UATHelper: Packaging (Windows (32-bit)):        (see C:\Users\3DVR\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.21\Log.txt for full exception trace)
PackagingResults: Error: UnrealBuildTool failed. See log for more details. (C:\Users\3DVR\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.21\UBT-Test_zip-Win32-Development.txt)
UATHelper: Packaging (Windows (32-bit)): AutomationTool exiting with ExitCode=5 (5)
UATHelper: Packaging (Windows (32-bit)): BUILD FAILED
PackagingResults: Error: Unknown Error


I installed the plugin as you said in the readme on github, so i just copied the folder in the project folder.
I specify that i’m trying to use it in a clean new template c++ prject.

I’m trying to resolve these warning and errors but if you or someone has seen this error that would be great!

Thanks!