Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.3.9] - 2024-12-18

### Changed
* package: remove contributors from package.json
* package: set the minimum Unity version to 2021.3.45
* api: change the accessor of test classes to internal
* doc: improve the API documentation of ZipUtility
* doc: update example APIs in the manual documentation
* refactor: rename editor test assembly to Unity.SharpZipLib.Editor.Tests
  • Loading branch information
Unity Technologies committed Dec 18, 2024
1 parent 7628720 commit 7d02af3
Show file tree
Hide file tree
Showing 32 changed files with 2,864 additions and 2,773 deletions.
1 change: 1 addition & 0 deletions .signature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"timestamp":1734595553,"signature":"iKGqWl3fJyULiSStmzV0yYzOiMslJCdk2fzAEqiIjhvnhXSfUn9lAx8gYp+T6U/0ASEurlt2LCPhyp/Z4xDk+4xSb0Y2GCr9nuO7pOmLvYLo9G3i3J3lJmaXm3x85TdBX9U6Tytp/x6eP3bPcStltqZ4NKAbuN9XjuwjUKp/QE2Yf1lGBnUr/KviReQLwKjt9go8yMeO+UhaYRVaxlw2GMqeo8b1cmOinhDFAb8h1j9W7RemQIDuwKfSA3pDbPsKqH2D+kCGuNBN6540H271y+ziTGc/myOWaR5q32kfi9DSa/3uIbm0Kkm7pgdeV1d3ol0cptpySd7v0iLjxIhUxWlmQPka8r4baAQTE8xRgmpqWlDh3Gg/XEpewA4Uvu26XEf+iuMShVPobKGcA2FNKGcigVduxXGcy2wuoZdr9s5KHz8QnZfgZz1/BtOIJxgTWK0M2YA/uwa0GeBdXQEqpSbI8ZRQrDiSGSclTzuTlEX2Mu2WuME3vFIY/fQsmRqn","publicKey":"LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQm9qQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FZOEFNSUlCaWdLQ0FZRUFzdUhXYUhsZ0I1cVF4ZEJjTlJKSAordHR4SmoxcVY1NTdvMlZaRE1XaXhYRVBkRTBEMVFkT1JIRXNSS1RscmplUXlERU83ZlNQS0ZwZ1A3MU5TTnJCCkFHM2NFSU45aHNQVDhOVmllZmdWem5QTkVMenFkVmdEbFhpb2VpUnV6OERKWFgvblpmU1JWKytwbk9ySTRibG4KS0twelJlNW14OTc1SjhxZ1FvRktKT0NNRlpHdkJMR2MxSzZZaEIzOHJFODZCZzgzbUovWjBEYkVmQjBxZm13cgo2ZDVFUXFsd0E5Y3JZT1YyV1VpWXprSnBLNmJZNzRZNmM1TmpBcEFKeGNiaTFOaDlRVEhUcU44N0ZtMDF0R1ZwCjVNd1pXSWZuYVRUemEvTGZLelR5U0pka0tldEZMVGdkYXpMYlpzUEE2aHBSK0FJRTJhc0tLTi84UUk1N3UzU2cKL2xyMnZKS1IvU2l5eEN1Q20vQWJkYnJMbXk0WjlSdm1jMGdpclA4T0lLQWxBRWZ2TzV5Z2hSKy8vd1RpTFlzUQp1SllDM0V2UE16ZGdKUzdGR2FscnFLZzlPTCsxVzROY05yNWdveVdSUUJ0cktKaWlTZEJVWmVxb0RvSUY5NHpCCndGbzJJT1JFdXFqcU51M3diMWZIM3p1dGdtalFra3IxVjJhd3hmcExLWlROQWdNQkFBRT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg"}
17 changes: 14 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [1.3.9] - 2024-12-18

### Changed
* package: remove contributors from package.json
* package: set the minimum Unity version to 2021.3.45
* api: change the accessor of test classes to internal
* doc: improve the API documentation of ZipUtility
* doc: update example APIs in the manual documentation
* refactor: rename editor test assembly to Unity.SharpZipLib.Editor.Tests


## [1.3.8] - 2024-04-26

### Added
Expand All @@ -22,7 +33,7 @@
* fix-test: use Unity's temporary path to create temp files

### Changed
* test: rename test assembly to Unity.SharpZipLib.*
* test: rename test assembly to Unity.SharpZipLib.*
* test: move test code copied from source to Tests/Runtime/Src

## [1.3.6-preview] - 2024-02-28
Expand Down Expand Up @@ -62,7 +73,7 @@
### Changed

* feat: use SharpZipLib 1.3.1
* chore: increase minimum Unity requirement to 2019.4
* chore: increase minimum Unity requirement to 2019.4
* change: the namespace of all code (including DLL) to Unity.SharpZipLib (breaking change)

## [1.2.2-preview.2] - 2021-10-19
Expand Down Expand Up @@ -93,6 +104,6 @@
## [1.2.0-preview] - 2019-10-02

### Added
* The first release of *SharpZipLib \<com.unity.sharp-zip-lib\>*, which was built using
* The first release of *SharpZipLib \<com.unity.sharp-zip-lib\>*, which was built using
[SharpZipLib v1.2.0](https://github.com/icsharpcode/SharpZipLib/archive/v1.2.0.zip).

2 changes: 1 addition & 1 deletion Documentation~/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Based on the used Unity version, please fellow the following steps to install `c
![](images/PackageManager.png)

1. Type in `com.unity.sharp-zip-lib` and click the **Add** button.
1. Type in `com.unity.sharp-zip-lib` and click the **Add** button.
We can also specify a particular version by appending `@<version>`, for example: `[email protected]`

45 changes: 21 additions & 24 deletions Documentation~/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,53 @@
`com.unity.sharp-zip-lib` is a package that wraps [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) to be used inside Unity,
and provides various compression/uncompression utility functions.

Currently, this package uses [SharpZipLib v1.3.3](https://github.com/icsharpcode/SharpZipLib/releases/tag/v1.3.3).
Currently, this package uses [SharpZipLib v1.3.3](https://github.com/icsharpcode/SharpZipLib/releases/tag/v1.3.3).
Please refer to the [installation](Installation.md) page to install this package.
> The version numbering of this package itself and the version of SharpZipLib used in the package may look similar,

> The version numbering of this package itself and the version of SharpZipLib used in the package may look similar,
but they are not related.


## How to Use

* All [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) APIs are available under `Unity.SharpZipLib` namespace. For example:
* All [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) APIs are available under `Unity.SharpZipLib` namespace. For example:
```csharp
using System.IO;
using Unity.SharpZipLib.GZip;

...
public void Foo() {

public void UseSharpZipLibAPIs() {
MemoryStream ms = new MemoryStream();
GZipOutputStream outStream = new GZipOutputStream(ms);
...
}

```

Please refer to the API documentation of the [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) version used
Please refer to the API documentation of the [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) version used
in this package for more details.

* In addition, `com.unity.sharp-zip-lib` also provides additional utility APIs:
* `ZipUtility.CompressFolderToZip()`: Compresses the files in the nominated folder, and creates a zip file on disk.
* `ZipUtility.CompressFolderToZip()`: Creates a zip file on disk containing the contents of the nominated folder.
* `ZipUtility.UncompressFromZip()`: Uncompress the contents of a zip file into the specified folder.

As an example:
```csharp

[Test]
public void Foo() {
//Compress
string tempZipPath = FileUtil.GetUniqueTempPathInProject();
string folderToCompress ="Bar";
ZipUtility.CompressFolderToZip(tempZipPath,null, folderToCompress);

static void CompressAndUncompress() {
//Compress
string folderToCompress = "Assets";
string zipPath = Path.Combine(Application.temporaryCachePath, "UnityAssets.zip");
ZipUtility.CompressFolderToZip(zipPath,null, folderToCompress);
Debug.Log($"{folderToCompress} folder compressed to: " + zipPath);

//Uncompress
string tempExtractPath = FileUtil.GetUniqueTempPathInProject();
Directory.CreateDirectory(tempExtractPath);
ZipUtility.UncompressFromZip(tempZipPath, null, tempExtractPath);

string extractPath = Path.Combine(Application.temporaryCachePath, "UnityAssetsExtracted");
ZipUtility.UncompressFromZip(zipPath, null, extractPath);
Debug.Log($"Uncompressed to: " + extractPath);
}
```


## Supported Unity Versions

* Unity `2018.4.36` or higher.
* Unity `2021.3.45` or higher.
2 changes: 1 addition & 1 deletion Editor/Analytics/AnalyticsEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class AnalyticsEventData {
}

internal abstract class AnalyticsEvent {

internal abstract string eventName { get; }
internal virtual int version => 1;
internal virtual int maxEventPerHour => 10000;
Expand Down
12 changes: 6 additions & 6 deletions Editor/Analytics/AnalyticsSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private struct EventDetail {
public string packageName;
public string packageVersion;
}

internal static void SendEventInEditor(AnalyticsEvent analyticsEvent) {
if (!EditorAnalytics.enabled) {
return;
Expand All @@ -45,7 +45,7 @@ internal static void SendEventInEditor(AnalyticsEvent analyticsEvent) {
DateTime now = DateTime.Now;
m_lastSentDateTime[analyticsEvent.eventName] = now;
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
private static bool IsEventRegistered(AnalyticsEvent analyticsEvent) {
return m_registeredEvents.ContainsKey(analyticsEvent.eventName);
Expand Down Expand Up @@ -75,7 +75,7 @@ private static bool RegisterEvent(AnalyticsEvent analyticsEvent, Assembly assemb
var eventDetails = new EventDetail {
assemblyInfo = assembly.FullName,
};

var packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(assembly);
if (packageInfo != null) {
eventDetails.packageName = packageInfo.name;
Expand All @@ -86,8 +86,8 @@ private static bool RegisterEvent(AnalyticsEvent analyticsEvent, Assembly assemb
return true;
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------------------------------

private const string VENDOR_KEY = "unity.sharp-zip-lib";

private static readonly Dictionary<string, EventDetail> m_registeredEvents = new Dictionary<string, EventDetail>();
Expand All @@ -99,6 +99,6 @@ internal static void SendEventInEditor(AnalyticsEvent analyticsEvent) { }


#endif //UNITY_EDITOR

}
} //end namespace
6 changes: 3 additions & 3 deletions Editor/Analytics/SharpZipLibAnalytics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using UnityEditor;
using UnityEditor;

namespace Unity.SharpZipLib.Editor {
internal static class SharpZipLibAnalytics {
Expand All @@ -9,8 +9,8 @@ private class LoadEvent : AnalyticsEvent {
internal LoadEvent() : base(new AnalyticsEventData()) {
}
}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------------------------------------------------------------------------------

[InitializeOnLoadMethod]
private static void OnLoad() {
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SharpZipLib copyright © 2024 Unity Technologies ApS

Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).

Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions.
66 changes: 31 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,66 @@

# Latest official docs
- [English](https://docs.unity3d.com/Packages/com.unity.sharp-zip-lib@latest)

[![](https://badge-proxy.cds.internal.unity3d.com/78081939-b2a0-4fc9-bebf-901b49fd954c)](https://badges.cds.internal.unity3d.com/packages/com.unity.sharp-zip-lib/build-info?branch=master&testWorkflow=package-isolation)
[![](https://badge-proxy.cds.internal.unity3d.com/faf61743-4d21-479c-b01c-ab63561e27d9)](https://badges.cds.internal.unity3d.com/packages/com.unity.sharp-zip-lib/dependencies-info?branch=master&testWorkflow=updated-dependencies)
[![](https://badge-proxy.cds.internal.unity3d.com/e5917bce-0357-4f49-a9c3-c356b9de832c)](https://badges.cds.internal.unity3d.com/packages/com.unity.sharp-zip-lib/dependants-info)
[![](https://badge-proxy.cds.internal.unity3d.com/f2066c51-3423-424d-a58f-24a64683cf57)](https://badges.cds.internal.unity3d.com/packages/com.unity.sharp-zip-lib/warnings-info?branch=master)

![ReleaseBadge](https://badge-proxy.cds.internal.unity3d.com/3b04c8fe-9005-4b46-848e-cb0199e49a2e)
![ReleaseBadge](https://badge-proxy.cds.internal.unity3d.com/9a481f99-fa9b-4716-8409-69bb63fedbd7)
# com.unity.sharp-zip-lib

`com.unity.sharp-zip-lib` is a package that wraps [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) to be used inside Unity,
and provides various compression/uncompression utility functions.

Currently, this package uses [SharpZipLib v1.3.3](https://github.com/icsharpcode/SharpZipLib/releases/tag/v1.3.3).
Currently, this package uses [SharpZipLib v1.3.3](https://github.com/icsharpcode/SharpZipLib/releases/tag/v1.3.3).
Please refer to the [installation](Documentation~/Installation.md) page to install this package.
> The version numbering of this package itself and the version of SharpZipLib used in the package may look similar,

> The version numbering of this package itself and the version of SharpZipLib used in the package may look similar,
but they are not related.


## How to Use

* All [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) APIs are available under `Unity.SharpZipLib` namespace. For example:
* All [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) APIs are available under `Unity.SharpZipLib` namespace. For example:
```csharp
using System.IO;
using Unity.SharpZipLib.GZip;

...
public void Foo() {

public void UseSharpZipLibAPIs() {
MemoryStream ms = new MemoryStream();
GZipOutputStream outStream = new GZipOutputStream(ms);
...
}

```

Please refer to the API documentation of the [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) version used
Please refer to the API documentation of the [SharpZipLib](https://github.com/icsharpcode/SharpZipLib) version used
in this package for more details.

* In addition, `com.unity.sharp-zip-lib` also provides additional utility APIs:
* `ZipUtility.CompressFolderToZip()`: Compresses the files in the nominated folder, and creates a zip file on disk.
* `ZipUtility.CompressFolderToZip()`: Creates a zip file on disk containing the contents of the nominated folder.
* `ZipUtility.UncompressFromZip()`: Uncompress the contents of a zip file into the specified folder.

As an example:
```csharp

[Test]
public void Foo() {
//Compress
string tempZipPath = FileUtil.GetUniqueTempPathInProject();
string folderToCompress ="Bar";
ZipUtility.CompressFolderToZip(tempZipPath,null, folderToCompress);

static void CompressAndUncompress() {
//Compress
string folderToCompress = "Assets";
string zipPath = Path.Combine(Application.temporaryCachePath, "UnityAssets.zip");
ZipUtility.CompressFolderToZip(zipPath,null, folderToCompress);
Debug.Log($"{folderToCompress} folder compressed to: " + zipPath);

//Uncompress
string tempExtractPath = FileUtil.GetUniqueTempPathInProject();
Directory.CreateDirectory(tempExtractPath);
ZipUtility.UncompressFromZip(tempZipPath, null, tempExtractPath);

string extractPath = Path.Combine(Application.temporaryCachePath, "UnityAssetsExtracted");
ZipUtility.UncompressFromZip(zipPath, null, extractPath);
Debug.Log($"Uncompressed to: " + extractPath);
}
```


## Supported Unity Versions

* Unity `2018.4.36` or higher.
* Unity `2021.3.45` or higher.
## Steps to update SharpZipLib

### Windows
Expand All @@ -83,14 +77,16 @@ but they are not related.
1. Download the source from https://github.com/icsharpcode/SharpZipLib/releases
1. Extract the source into a folder, e.g: `Src/SharpZipLib-1.3.3`
1. Open "Developer Command Prompt for VS 2022"
1. Execute `update_sharp-zip-lib.cmd [src_folder]`
* E.g: `update_sharp-zip-lib.cmd Src/SharpZipLib-1.3.3`
* Executing `update_sharp-zip-lib.cmd` without arguments will print the list of acceptable arguments
1. Execute `update_sharp-zip-lib.cmd [src_folder]`
* E.g: `update_sharp-zip-lib.cmd Src/SharpZipLib-1.3.3`
* Executing `update_sharp-zip-lib.cmd` without arguments will print the list of acceptable arguments
1. Open SharpZipLib~ test project, ensure everything compiles and the tests are successful.
* We may need to fix/remove some tests that were copied from the source.
For example: [async tests](https://docs.unity3d.com/Packages/[email protected]/manual/reference-async-tests.html)
which are not supported in Unity 2018 and earlier.
* We may need to fix/remove some tests that were copied from the source.
For example: [async tests](https://docs.unity3d.com/Packages/[email protected]/manual/reference-async-tests.html)
which are not supported in Unity 2018 and earlier.
1. Open a shell / Git Bash / terminal
1. Execute `sh Scripts~/clean_up_cs.sh` to clean up cs source code.



*Auto-generated on Wed Feb 28 05:29:40 UTC 2024*
*Auto-generated on Thu Dec 19 08:01:25 UTC 2024*
Loading

0 comments on commit 7d02af3

Please sign in to comment.