@appzung/react-native-code-push 9.0.2 → 10.0.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CodePush.js +22 -19
- package/LICENSE.md +1 -1
- package/README.md +159 -298
- package/android/app/.gradle/config.properties +2 -0
- package/android/app/build.gradle +1 -1
- package/android/app/local.properties +8 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +27 -21
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +5 -5
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +5 -5
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +14 -14
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +2 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +1 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +1 -1
- package/android/build.gradle +1 -1
- package/android/codepush.gradle +3 -3
- package/docs/advanced-usage.md +56 -0
- package/docs/api-android.md +12 -75
- package/docs/api-ios.md +5 -17
- package/docs/api-js.md +18 -55
- package/docs/setup-android.md +15 -397
- package/docs/setup-ios.md +24 -198
- package/docs/setup-windows.md +7 -74
- package/ios/CodePush/CodePush.h +4 -4
- package/ios/CodePush/CodePush.m +8 -8
- package/ios/CodePush/CodePushConfig.m +14 -11
- package/ios/CodePush/CodePushPackage.m +60 -60
- package/ios/CodePush/CodePushTelemetryManager.m +13 -13
- package/ios/CodePush.xcodeproj/project.pbxproj +1 -562
- package/package.json +27 -24
- package/react-native.config.js +1 -1
- package/scripts/generateBundledResourcesHash.js +1 -1
- package/scripts/getFilesInFolder.js +1 -1
- package/scripts/recordFilesBeforeBundleCommand.js +1 -1
- package/typings/react-native-code-push.d.ts +22 -22
- package/windows/CodePush/CodePushConfig.cpp +3 -3
- package/windows/CodePush/CodePushConfig.h +3 -3
- package/windows/CodePush/CodePushNativeModule.cpp +27 -27
- package/windows/CodePush/CodePushNativeModule.h +4 -4
- package/windows/CodePush/CodePushTelemetryManager.cpp +12 -12
- package/windows/CodePush/CodePushTelemetryManager.h +1 -1
- package/.azurepipelines/build-rn-code-push-1es.yml +0 -104
- package/.azurepipelines/test-rn-code-push.yml +0 -94
- package/.config/CredScanSuppressions.json +0 -14
- package/SECURITY.md +0 -41
- package/docs/multi-deployment-testing-android.md +0 -148
- package/docs/multi-deployment-testing-ios.md +0 -59
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +0 -34
- package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -252
- package/ios/CodePush/Base64/README.md +0 -47
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -69
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -16
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -51
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -15
- package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -55
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -24
- package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -41
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -28
- package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -205
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -103
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -322
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -37
- package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -145
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -35
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -551
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -23
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -43
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -230
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -31
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -113
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -38
- package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -500
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -18
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -214
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -23
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -29
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -19
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -68
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -18
- package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -72
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -67
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -111
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -119
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -307
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -94
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -619
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -164
- package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -514
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -24
- package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -11
- package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -52
- package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -5
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -28
- package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -70
- package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -22
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -34
- package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -73
- package/ios/CodePush/JWT/LICENSE +0 -19
- package/ios/CodePush/JWT/README.md +0 -489
- package/ios/CodePush/SSZipArchive/Info.plist +0 -26
- package/ios/CodePush/SSZipArchive/README.md +0 -1
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +0 -178
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +0 -1496
- package/ios/CodePush/SSZipArchive/SSZipCommon.h +0 -71
- package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +0 -23
- package/ios/CodePush/SSZipArchive/include/ZipArchive.h +0 -25
- package/ios/CodePush/SSZipArchive/minizip/LICENSE +0 -17
- package/ios/CodePush/SSZipArchive/minizip/mz.h +0 -273
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +0 -1306
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +0 -346
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +0 -187
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +0 -65
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +0 -526
- package/ios/CodePush/SSZipArchive/minizip/mz_os.c +0 -348
- package/ios/CodePush/SSZipArchive/minizip/mz_os.h +0 -176
- package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +0 -350
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +0 -556
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +0 -132
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +0 -383
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +0 -42
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +0 -269
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +0 -48
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +0 -40
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +0 -203
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +0 -334
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +0 -46
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +0 -429
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +0 -43
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +0 -360
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +0 -46
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +0 -389
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +0 -43
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +0 -2782
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +0 -262
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +0 -1942
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +0 -285
- package/scripts/postlink/android/postlink.js +0 -87
- package/scripts/postlink/ios/postlink.js +0 -116
- package/scripts/postlink/run.js +0 -11
- package/scripts/postunlink/android/postunlink.js +0 -74
- package/scripts/postunlink/ios/postunlink.js +0 -87
- package/scripts/postunlink/run.js +0 -11
- package/scripts/tools/linkToolsAndroid.js +0 -57
- package/scripts/tools/linkToolsIos.js +0 -130
- package/windows-legacy/CodePush/CodePush.csproj +0 -128
- package/windows-legacy/CodePush/CodePushUtils.cs +0 -47
- package/windows-legacy/CodePush/FileUtils.cs +0 -40
- package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +0 -29
- package/windows-legacy/CodePush/Properties/CodePush.rd.xml +0 -33
- package/windows-legacy/CodePush/UpdateManager.cs +0 -305
- package/windows-legacy/CodePush/UpdateUtils.cs +0 -46
- package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -28
- package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -106
- package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +0 -103
- package/windows-legacy/CodePush.Net46/CodePushUtils.cs +0 -158
- package/windows-legacy/CodePush.Net46/FileUtils.cs +0 -55
- package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +0 -36
- package/windows-legacy/CodePush.Net46/UpdateManager.cs +0 -330
- package/windows-legacy/CodePush.Net46/UpdateUtils.cs +0 -70
- package/windows-legacy/CodePush.Net46/packages.config +0 -5
- package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +0 -105
- package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +0 -137
- package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +0 -36
- package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +0 -117
- package/windows-legacy/CodePush.Net46.Test/app.config +0 -11
- package/windows-legacy/CodePush.Net46.Test/packages.config +0 -4
- package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +0 -22
- package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +0 -13
- package/windows-legacy/CodePush.Shared/CodePushConstants.cs +0 -35
- package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +0 -329
- package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +0 -235
- package/windows-legacy/CodePush.Shared/CodePushUtils.cs +0 -70
- package/windows-legacy/CodePush.Shared/InstallMode.cs +0 -9
- package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +0 -44
- package/windows-legacy/CodePush.Shared/SettingsManager.cs +0 -148
- package/windows-legacy/CodePush.Shared/TelemetryManager.cs +0 -250
- package/windows-legacy/CodePush.Shared/UpdateState.cs +0 -9
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
/* mz_strm_split.c -- Stream for split files
|
|
2
|
-
part of the minizip-ng project
|
|
3
|
-
|
|
4
|
-
Copyright (C) Nathan Moinvaziri
|
|
5
|
-
https://github.com/zlib-ng/minizip-ng
|
|
6
|
-
|
|
7
|
-
This program is distributed under the terms of the same license as zlib.
|
|
8
|
-
See the accompanying LICENSE file for the full text of the license.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
#include "mz.h"
|
|
12
|
-
#include "mz_os.h"
|
|
13
|
-
#include "mz_strm.h"
|
|
14
|
-
#include "mz_strm_split.h"
|
|
15
|
-
|
|
16
|
-
#include <stdio.h> /* snprintf */
|
|
17
|
-
|
|
18
|
-
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
|
19
|
-
# define snprintf _snprintf
|
|
20
|
-
#endif
|
|
21
|
-
|
|
22
|
-
/***************************************************************************/
|
|
23
|
-
|
|
24
|
-
#define MZ_ZIP_MAGIC_DISKHEADER (0x08074b50)
|
|
25
|
-
|
|
26
|
-
/***************************************************************************/
|
|
27
|
-
|
|
28
|
-
static mz_stream_vtbl mz_stream_split_vtbl = {
|
|
29
|
-
mz_stream_split_open,
|
|
30
|
-
mz_stream_split_is_open,
|
|
31
|
-
mz_stream_split_read,
|
|
32
|
-
mz_stream_split_write,
|
|
33
|
-
mz_stream_split_tell,
|
|
34
|
-
mz_stream_split_seek,
|
|
35
|
-
mz_stream_split_close,
|
|
36
|
-
mz_stream_split_error,
|
|
37
|
-
mz_stream_split_create,
|
|
38
|
-
mz_stream_split_delete,
|
|
39
|
-
mz_stream_split_get_prop_int64,
|
|
40
|
-
mz_stream_split_set_prop_int64
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/***************************************************************************/
|
|
44
|
-
|
|
45
|
-
typedef struct mz_stream_split_s {
|
|
46
|
-
mz_stream stream;
|
|
47
|
-
int32_t is_open;
|
|
48
|
-
int64_t disk_size;
|
|
49
|
-
int64_t total_in;
|
|
50
|
-
int64_t total_in_disk;
|
|
51
|
-
int64_t total_out;
|
|
52
|
-
int64_t total_out_disk;
|
|
53
|
-
int32_t mode;
|
|
54
|
-
char *path_cd;
|
|
55
|
-
char *path_disk;
|
|
56
|
-
uint32_t path_disk_size;
|
|
57
|
-
int32_t number_disk;
|
|
58
|
-
int32_t current_disk;
|
|
59
|
-
int64_t current_disk_size;
|
|
60
|
-
int32_t reached_end;
|
|
61
|
-
} mz_stream_split;
|
|
62
|
-
|
|
63
|
-
/***************************************************************************/
|
|
64
|
-
|
|
65
|
-
#if 0
|
|
66
|
-
# define mz_stream_split_print printf
|
|
67
|
-
#else
|
|
68
|
-
# define mz_stream_split_print(fmt, ...)
|
|
69
|
-
#endif
|
|
70
|
-
|
|
71
|
-
/***************************************************************************/
|
|
72
|
-
|
|
73
|
-
static int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk) {
|
|
74
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
75
|
-
uint32_t magic = 0;
|
|
76
|
-
int64_t position = 0;
|
|
77
|
-
int32_t i = 0;
|
|
78
|
-
int32_t err = MZ_OK;
|
|
79
|
-
int16_t disk_part = 0;
|
|
80
|
-
|
|
81
|
-
/* Check if we are reading or writing a disk part or the cd disk */
|
|
82
|
-
if (number_disk >= 0) {
|
|
83
|
-
if ((split->mode & MZ_OPEN_MODE_WRITE) == 0)
|
|
84
|
-
disk_part = MZ_OPEN_MODE_READ;
|
|
85
|
-
else if (split->disk_size > 0)
|
|
86
|
-
disk_part = MZ_OPEN_MODE_WRITE;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/* Construct disk path */
|
|
90
|
-
if (disk_part > 0) {
|
|
91
|
-
for (i = (int32_t)strlen(split->path_disk) - 1; i >= 0; i -= 1) {
|
|
92
|
-
if (split->path_disk[i] != '.')
|
|
93
|
-
continue;
|
|
94
|
-
snprintf(&split->path_disk[i], split->path_disk_size - (uint32_t)i,
|
|
95
|
-
".z%02" PRId32, number_disk + 1);
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
strncpy(split->path_disk, split->path_cd, split->path_disk_size - 1);
|
|
100
|
-
split->path_disk[split->path_disk_size - 1] = 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
mz_stream_split_print("Split - Goto disk - %s (disk %" PRId32 ")\n", split->path_disk, number_disk);
|
|
104
|
-
|
|
105
|
-
/* If disk part doesn't exist during reading then return MZ_EXIST_ERROR */
|
|
106
|
-
if (disk_part == MZ_OPEN_MODE_READ)
|
|
107
|
-
err = mz_os_file_exists(split->path_disk);
|
|
108
|
-
|
|
109
|
-
if (err == MZ_OK)
|
|
110
|
-
err = mz_stream_open(split->stream.base, split->path_disk, split->mode);
|
|
111
|
-
|
|
112
|
-
if (err == MZ_OK) {
|
|
113
|
-
split->total_in_disk = 0;
|
|
114
|
-
split->total_out_disk = 0;
|
|
115
|
-
split->current_disk = number_disk;
|
|
116
|
-
|
|
117
|
-
if (split->mode & MZ_OPEN_MODE_WRITE) {
|
|
118
|
-
if ((split->current_disk == 0) && (split->disk_size > 0)) {
|
|
119
|
-
err = mz_stream_write_uint32(split->stream.base, MZ_ZIP_MAGIC_DISKHEADER);
|
|
120
|
-
|
|
121
|
-
split->total_out_disk += 4;
|
|
122
|
-
split->total_out += split->total_out_disk;
|
|
123
|
-
}
|
|
124
|
-
} else if (split->mode & MZ_OPEN_MODE_READ) {
|
|
125
|
-
if (split->current_disk == 0) {
|
|
126
|
-
err = mz_stream_read_uint32(split->stream.base, &magic);
|
|
127
|
-
if (magic != MZ_ZIP_MAGIC_DISKHEADER)
|
|
128
|
-
err = MZ_FORMAT_ERROR;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (err == MZ_OK) {
|
|
134
|
-
/* Get the size of the current disk we are on */
|
|
135
|
-
position = mz_stream_tell(split->stream.base);
|
|
136
|
-
mz_stream_seek(split->stream.base, 0, MZ_SEEK_END);
|
|
137
|
-
split->current_disk_size = mz_stream_tell(split->stream.base);
|
|
138
|
-
mz_stream_seek(split->stream.base, position, MZ_SEEK_SET);
|
|
139
|
-
|
|
140
|
-
split->is_open = 1;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return err;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
static int32_t mz_stream_split_close_disk(void *stream) {
|
|
147
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
148
|
-
|
|
149
|
-
if (mz_stream_is_open(split->stream.base) != MZ_OK)
|
|
150
|
-
return MZ_OK;
|
|
151
|
-
|
|
152
|
-
mz_stream_split_print("Split - Close disk\n");
|
|
153
|
-
return mz_stream_close(split->stream.base);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
static int32_t mz_stream_split_goto_disk(void *stream, int32_t number_disk) {
|
|
157
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
158
|
-
int32_t err = MZ_OK;
|
|
159
|
-
int32_t err_is_open = MZ_OK;
|
|
160
|
-
|
|
161
|
-
err_is_open = mz_stream_is_open(split->stream.base);
|
|
162
|
-
|
|
163
|
-
if ((split->disk_size == 0) && (split->mode & MZ_OPEN_MODE_WRITE)) {
|
|
164
|
-
if (err_is_open != MZ_OK)
|
|
165
|
-
err = mz_stream_split_open_disk(stream, number_disk);
|
|
166
|
-
} else if ((number_disk != split->current_disk) || (err_is_open != MZ_OK)) {
|
|
167
|
-
err = mz_stream_split_close_disk(stream);
|
|
168
|
-
if (err == MZ_OK) {
|
|
169
|
-
err = mz_stream_split_open_disk(stream, number_disk);
|
|
170
|
-
if (err == MZ_OK)
|
|
171
|
-
split->number_disk = number_disk;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return err;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
int32_t mz_stream_split_open(void *stream, const char *path, int32_t mode) {
|
|
179
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
180
|
-
int32_t number_disk = 0;
|
|
181
|
-
|
|
182
|
-
split->mode = mode;
|
|
183
|
-
split->path_cd = strdup(path);
|
|
184
|
-
|
|
185
|
-
if (!split->path_cd)
|
|
186
|
-
return MZ_MEM_ERROR;
|
|
187
|
-
|
|
188
|
-
mz_stream_split_print("Split - Open - %s (disk %" PRId32 ")\n", split->path_cd, number_disk);
|
|
189
|
-
|
|
190
|
-
split->path_disk_size = (uint32_t)strlen(path) + 10;
|
|
191
|
-
split->path_disk = (char *)malloc(split->path_disk_size);
|
|
192
|
-
|
|
193
|
-
if (!split->path_disk) {
|
|
194
|
-
free(split->path_cd);
|
|
195
|
-
return MZ_MEM_ERROR;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
strncpy(split->path_disk, path, split->path_disk_size - 1);
|
|
199
|
-
split->path_disk[split->path_disk_size - 1] = 0;
|
|
200
|
-
|
|
201
|
-
if ((mode & MZ_OPEN_MODE_WRITE) && ((mode & MZ_OPEN_MODE_APPEND) == 0)) {
|
|
202
|
-
number_disk = 0;
|
|
203
|
-
split->current_disk = -1;
|
|
204
|
-
} else {
|
|
205
|
-
number_disk = -1;
|
|
206
|
-
split->current_disk = 0;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return mz_stream_split_goto_disk(stream, number_disk);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
int32_t mz_stream_split_is_open(void *stream) {
|
|
213
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
214
|
-
if (split->is_open != 1)
|
|
215
|
-
return MZ_OPEN_ERROR;
|
|
216
|
-
return MZ_OK;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
int32_t mz_stream_split_read(void *stream, void *buf, int32_t size) {
|
|
220
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
221
|
-
int32_t bytes_left = size;
|
|
222
|
-
int32_t read = 0;
|
|
223
|
-
int32_t err = MZ_OK;
|
|
224
|
-
uint8_t *buf_ptr = (uint8_t *)buf;
|
|
225
|
-
|
|
226
|
-
err = mz_stream_split_goto_disk(stream, split->number_disk);
|
|
227
|
-
if (err != MZ_OK)
|
|
228
|
-
return err;
|
|
229
|
-
|
|
230
|
-
while (bytes_left > 0) {
|
|
231
|
-
read = mz_stream_read(split->stream.base, buf_ptr, bytes_left);
|
|
232
|
-
|
|
233
|
-
mz_stream_split_print("Split - Read disk - %" PRId32 "\n", read);
|
|
234
|
-
|
|
235
|
-
if (read < 0)
|
|
236
|
-
return read;
|
|
237
|
-
if (read == 0) {
|
|
238
|
-
if (split->current_disk < 0) /* No more disks to goto */
|
|
239
|
-
break;
|
|
240
|
-
err = mz_stream_split_goto_disk(stream, split->current_disk + 1);
|
|
241
|
-
if (err == MZ_EXIST_ERROR) {
|
|
242
|
-
split->current_disk = -1;
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
if (err != MZ_OK)
|
|
246
|
-
return err;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
bytes_left -= read;
|
|
250
|
-
buf_ptr += read;
|
|
251
|
-
split->total_in += read;
|
|
252
|
-
split->total_in_disk += read;
|
|
253
|
-
}
|
|
254
|
-
return size - bytes_left;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
int32_t mz_stream_split_write(void *stream, const void *buf, int32_t size) {
|
|
258
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
259
|
-
int64_t position = 0;
|
|
260
|
-
int32_t written = 0;
|
|
261
|
-
int32_t bytes_left = size;
|
|
262
|
-
int32_t bytes_to_write = 0;
|
|
263
|
-
int32_t bytes_avail = 0;
|
|
264
|
-
int32_t number_disk = -1;
|
|
265
|
-
int32_t err = MZ_OK;
|
|
266
|
-
const uint8_t *buf_ptr = (const uint8_t *)buf;
|
|
267
|
-
|
|
268
|
-
position = mz_stream_tell(split->stream.base);
|
|
269
|
-
|
|
270
|
-
while (bytes_left > 0) {
|
|
271
|
-
bytes_to_write = bytes_left;
|
|
272
|
-
|
|
273
|
-
if (split->disk_size > 0) {
|
|
274
|
-
if ((split->total_out_disk == split->disk_size && split->total_out > 0) ||
|
|
275
|
-
(split->number_disk == -1 && split->number_disk != split->current_disk)) {
|
|
276
|
-
if (split->number_disk != -1)
|
|
277
|
-
number_disk = split->current_disk + 1;
|
|
278
|
-
|
|
279
|
-
err = mz_stream_split_goto_disk(stream, number_disk);
|
|
280
|
-
if (err != MZ_OK)
|
|
281
|
-
return err;
|
|
282
|
-
|
|
283
|
-
position = 0;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (split->number_disk != -1) {
|
|
287
|
-
bytes_avail = (int32_t)(split->disk_size - split->total_out_disk);
|
|
288
|
-
if (bytes_to_write > bytes_avail)
|
|
289
|
-
bytes_to_write = bytes_avail;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
written = mz_stream_write(split->stream.base, buf_ptr, bytes_to_write);
|
|
294
|
-
if (written != bytes_to_write)
|
|
295
|
-
return MZ_WRITE_ERROR;
|
|
296
|
-
|
|
297
|
-
mz_stream_split_print("Split - Write disk - %" PRId32 "\n", written);
|
|
298
|
-
|
|
299
|
-
bytes_left -= written;
|
|
300
|
-
buf_ptr += written;
|
|
301
|
-
|
|
302
|
-
split->total_out += written;
|
|
303
|
-
split->total_out_disk += written;
|
|
304
|
-
|
|
305
|
-
position += written;
|
|
306
|
-
if (position > split->current_disk_size)
|
|
307
|
-
split->current_disk_size = position;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return size - bytes_left;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
int64_t mz_stream_split_tell(void *stream) {
|
|
314
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
315
|
-
int32_t err = MZ_OK;
|
|
316
|
-
err = mz_stream_split_goto_disk(stream, split->number_disk);
|
|
317
|
-
if (err != MZ_OK)
|
|
318
|
-
return err;
|
|
319
|
-
return mz_stream_tell(split->stream.base);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
int32_t mz_stream_split_seek(void *stream, int64_t offset, int32_t origin) {
|
|
323
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
324
|
-
int64_t disk_left = 0;
|
|
325
|
-
int64_t position = 0;
|
|
326
|
-
int32_t err = MZ_OK;
|
|
327
|
-
|
|
328
|
-
err = mz_stream_split_goto_disk(stream, split->number_disk);
|
|
329
|
-
|
|
330
|
-
if (err != MZ_OK)
|
|
331
|
-
return err;
|
|
332
|
-
|
|
333
|
-
mz_stream_split_print("Split - Seek disk - %" PRId64 " (origin %" PRId32 ")\n", offset, origin);
|
|
334
|
-
|
|
335
|
-
if ((origin == MZ_SEEK_CUR) && (split->number_disk != -1)) {
|
|
336
|
-
position = mz_stream_tell(split->stream.base);
|
|
337
|
-
disk_left = split->current_disk_size - position;
|
|
338
|
-
|
|
339
|
-
while (offset > disk_left) {
|
|
340
|
-
err = mz_stream_split_goto_disk(stream, split->current_disk + 1);
|
|
341
|
-
if (err != MZ_OK)
|
|
342
|
-
return err;
|
|
343
|
-
|
|
344
|
-
offset -= disk_left;
|
|
345
|
-
disk_left = split->current_disk_size;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return mz_stream_seek(split->stream.base, offset, origin);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
int32_t mz_stream_split_close(void *stream) {
|
|
353
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
354
|
-
int32_t err = MZ_OK;
|
|
355
|
-
|
|
356
|
-
err = mz_stream_split_close_disk(stream);
|
|
357
|
-
split->is_open = 0;
|
|
358
|
-
return err;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
int32_t mz_stream_split_error(void *stream) {
|
|
362
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
363
|
-
return mz_stream_error(split->stream.base);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
int32_t mz_stream_split_get_prop_int64(void *stream, int32_t prop, int64_t *value) {
|
|
367
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
368
|
-
switch (prop) {
|
|
369
|
-
case MZ_STREAM_PROP_TOTAL_OUT:
|
|
370
|
-
*value = split->total_out;
|
|
371
|
-
break;
|
|
372
|
-
case MZ_STREAM_PROP_DISK_NUMBER:
|
|
373
|
-
*value = split->number_disk;
|
|
374
|
-
break;
|
|
375
|
-
case MZ_STREAM_PROP_DISK_SIZE:
|
|
376
|
-
*value = split->disk_size;
|
|
377
|
-
break;
|
|
378
|
-
default:
|
|
379
|
-
return MZ_EXIST_ERROR;
|
|
380
|
-
}
|
|
381
|
-
return MZ_OK;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
int32_t mz_stream_split_set_prop_int64(void *stream, int32_t prop, int64_t value) {
|
|
385
|
-
mz_stream_split *split = (mz_stream_split *)stream;
|
|
386
|
-
switch (prop) {
|
|
387
|
-
case MZ_STREAM_PROP_DISK_NUMBER:
|
|
388
|
-
split->number_disk = (int32_t)value;
|
|
389
|
-
break;
|
|
390
|
-
case MZ_STREAM_PROP_DISK_SIZE:
|
|
391
|
-
split->disk_size = value;
|
|
392
|
-
break;
|
|
393
|
-
default:
|
|
394
|
-
return MZ_EXIST_ERROR;
|
|
395
|
-
}
|
|
396
|
-
return MZ_OK;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
void *mz_stream_split_create(void **stream) {
|
|
400
|
-
mz_stream_split *split = NULL;
|
|
401
|
-
|
|
402
|
-
split = (mz_stream_split *)calloc(1, sizeof(mz_stream_split));
|
|
403
|
-
if (split)
|
|
404
|
-
split->stream.vtbl = &mz_stream_split_vtbl;
|
|
405
|
-
if (stream)
|
|
406
|
-
*stream = split;
|
|
407
|
-
|
|
408
|
-
return split;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
void mz_stream_split_delete(void **stream) {
|
|
412
|
-
mz_stream_split *split = NULL;
|
|
413
|
-
if (!stream)
|
|
414
|
-
return;
|
|
415
|
-
split = (mz_stream_split *)*stream;
|
|
416
|
-
if (split) {
|
|
417
|
-
if (split->path_cd)
|
|
418
|
-
free(split->path_cd);
|
|
419
|
-
if (split->path_disk)
|
|
420
|
-
free(split->path_disk);
|
|
421
|
-
|
|
422
|
-
free(split);
|
|
423
|
-
}
|
|
424
|
-
*stream = NULL;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
void *mz_stream_split_get_interface(void) {
|
|
428
|
-
return (void *)&mz_stream_split_vtbl;
|
|
429
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/* mz_strm_split.h -- Stream for split files
|
|
2
|
-
part of the minizip-ng project
|
|
3
|
-
|
|
4
|
-
Copyright (C) Nathan Moinvaziri
|
|
5
|
-
https://github.com/zlib-ng/minizip-ng
|
|
6
|
-
|
|
7
|
-
This program is distributed under the terms of the same license as zlib.
|
|
8
|
-
See the accompanying LICENSE file for the full text of the license.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
#ifndef MZ_STREAM_SPLIT_H
|
|
12
|
-
#define MZ_STREAM_SPLIT_H
|
|
13
|
-
|
|
14
|
-
#ifdef __cplusplus
|
|
15
|
-
extern "C" {
|
|
16
|
-
#endif
|
|
17
|
-
|
|
18
|
-
/***************************************************************************/
|
|
19
|
-
|
|
20
|
-
int32_t mz_stream_split_open(void *stream, const char *filename, int32_t mode);
|
|
21
|
-
int32_t mz_stream_split_is_open(void *stream);
|
|
22
|
-
int32_t mz_stream_split_read(void *stream, void *buf, int32_t size);
|
|
23
|
-
int32_t mz_stream_split_write(void *stream, const void *buf, int32_t size);
|
|
24
|
-
int64_t mz_stream_split_tell(void *stream);
|
|
25
|
-
int32_t mz_stream_split_seek(void *stream, int64_t offset, int32_t origin);
|
|
26
|
-
int32_t mz_stream_split_close(void *stream);
|
|
27
|
-
int32_t mz_stream_split_error(void *stream);
|
|
28
|
-
|
|
29
|
-
int32_t mz_stream_split_get_prop_int64(void *stream, int32_t prop, int64_t *value);
|
|
30
|
-
int32_t mz_stream_split_set_prop_int64(void *stream, int32_t prop, int64_t value);
|
|
31
|
-
|
|
32
|
-
void* mz_stream_split_create(void **stream);
|
|
33
|
-
void mz_stream_split_delete(void **stream);
|
|
34
|
-
|
|
35
|
-
void* mz_stream_split_get_interface(void);
|
|
36
|
-
|
|
37
|
-
/***************************************************************************/
|
|
38
|
-
|
|
39
|
-
#ifdef __cplusplus
|
|
40
|
-
}
|
|
41
|
-
#endif
|
|
42
|
-
|
|
43
|
-
#endif
|