@octane-xplat/lottie 0.9.0 → 0.10.0
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/README.md +36 -16
- package/dist/native/index.js +10 -9
- package/dist/native/octane-client-build.json +1 -1
- package/dist/web/index.js +39 -25
- package/dist/web/octane-client-build.json +1 -1
- package/package.json +25 -3
- package/platforms/macos/LICENSE-EpoxyCore-Apache-2.0.txt +201 -0
- package/platforms/macos/LICENSE-LRUCache-MIT.txt +22 -0
- package/platforms/macos/LICENSE-Lottie-Apache-2.0.txt +201 -0
- package/platforms/macos/LICENSE-ZIPFoundation-MIT.txt +21 -0
- package/platforms/macos/UPSTREAM.md +13 -0
- package/platforms/macos/resources/PrivacyInfo.xcprivacy +23 -0
- package/platforms/macos/resources/THIRD-PARTY-NOTICES.txt +10 -0
- package/platforms/macos/src/XplatAppKitLottie.swift +246 -0
- package/platforms/macos/src/vendor/Lottie/PrivacyInfo.xcprivacy +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CAAnimation+TimingConfiguration.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +476 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +92 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/CustomPathAnimation.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/DropShadowAnimation.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/EllipseAnimation.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/GradientAnimations.swift +287 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/LayerProperty.swift +440 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/OpacityAnimation.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/RectangleAnimation.swift +59 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/ShapeAnimation.swift +246 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StarAnimation.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/StrokeAnimation.swift +96 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/TransformAnimations.swift +380 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Animations/VisibilityAnimation.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CompatibilityTracker.swift +129 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/CoreAnimationLayer.swift +645 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/CALayer+fillBounds.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+combined.swift +345 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Extensions/Keyframes+timeRemapping.swift +46 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/AnimationLayer.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseAnimationLayer.swift +46 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/BaseCompositionLayer.swift +120 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/GradientRenderLayer.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ImageLayer.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/InfiniteOpaqueAnimationLayer.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +59 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/MaskCompositionLayer.swift +139 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/PreCompLayer.swift +107 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/RepeaterLayer.swift +113 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeItemLayer.swift +346 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/ShapeLayer.swift +569 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/SolidLayer.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TextLayer.swift +157 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/Layers/TransformLayer.swift +13 -0
- package/platforms/macos/src/vendor/Lottie/Private/CoreAnimation/ValueProviderStore.swift +157 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Collection+Diff.swift +267 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/Diffable.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/DiffableSection.swift +16 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/IndexChangeset.swift +187 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Diffing/SectionedChangeset.swift +22 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Logging/EpoxyLogger.swift +102 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/CallbackContextEpoxyModeled.swift +8 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelArrayBuilder.swift +48 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelProperty.swift +158 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModelStorage.swift +88 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/EpoxyModeled.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/AnyEpoxyModelProperty.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Internal/ClassReference.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/AnimatedProviding.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DataIDProviding.swift +58 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidDisplayProviding.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidEndDisplayingProviding.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/DidSelectProviding.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ErasedContentProviding.swift +49 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/MakeViewProviding.swift +61 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetBehaviorsProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/SetContentProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/StyleIDProviding.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/TraitCollectionProviding.swift +14 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewDifferentiatorProviding.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/ViewProviding.swift +13 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/Providers/WillDisplayProviding.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Model/ViewEpoxyModeled.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/README.md +30 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUIIntrinsicContentSizeInvalidator.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxySwiftUILayoutMargins.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift +165 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/MeasuringViewRepresentable.swift +127 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/LayoutUtilities/SwiftUIMeasurementContainer.swift +468 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/SwiftUIView.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIView+SwiftUIView.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/SwiftUI/UIViewConfiguringSwiftUIView.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/BehaviorsConfigurableView.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ContentConfigurableView.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/EpoxyableView.swift +5 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/StyledView.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/EpoxyCore/Views/ViewType.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/LRUCache.swift +257 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/LRUCache/README.md +24 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/README.md +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+BackingConfiguration.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Deprecated.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Helpers.swift +361 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+MemoryFile.swift +205 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Progress.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Reading.swift +160 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ReadingDeprecated.swift +50 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+Writing.swift +403 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+WritingDeprecated.swift +95 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive+ZIP64.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Archive.swift +404 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Compression.swift +632 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+CompressionDeprecated.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Data+Serialization.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Date+ZIP.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+Serialization.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry+ZIP64.swift +170 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/Entry.swift +669 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIP.swift +405 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/FileManager+ZIPDeprecated.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/README.md +24 -0
- package/platforms/macos/src/vendor/Lottie/Private/EmbeddedLibraries/ZipFoundation/URL+ZIP.swift +34 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.swift +177 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ImageCompositionLayer.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +191 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/NullCompositionLayer.swift +28 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +137 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.swift +60 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.swift +247 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +321 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CachedImageProvider.swift +56 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/CoreTextRenderLayer.swift +424 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/InvertedMatteLayer.swift +55 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerFontProvider.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerImageProvider.swift +52 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTextProvider.swift +38 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +146 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.swift +62 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.swift +26 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/KeypathSearchable.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/GroupInterpolator.swift +39 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/DropShadowNode.swift +102 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/LayerEffectNodes/LayerEffectNode.swift +25 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/RoundedCornersNode.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +281 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/GroupOutputNode.swift +74 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PathOutputNode.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/FillRenderer.swift +69 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientFillRenderer.swift +253 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/GradientStrokeRenderer.swift +64 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/LegacyGradientFillRenderer.swift +158 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/Renderables/StrokeRenderer.swift +165 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +143 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +173 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +238 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/ShapeNode.swift +73 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +224 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +162 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +88 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +149 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +345 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.swift +197 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/PathNode.swift +20 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/Protocols/RenderNode.swift +60 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeContainerLayer.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/ShapeRenderLayer.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/Asset.swift +51 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/AssetLibrary.swift +75 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/ImageAsset.swift +141 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Assets/PrecompAsset.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DictionaryInitializable.swift +73 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieAnimation.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieImageProvider.swift +89 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieManifest.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/DotLottie/DotLottieUtils.swift +71 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/Bundle.swift +58 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Extensions/KeyedDecodingContainerExtensions.swift +71 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeData.swift +111 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Keyframes/KeyframeGroup.swift +265 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/DropShadowEffect.swift +52 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/ColorEffectValue.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/EffectValue.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/EffectValues/Vector1DEffectValue.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerEffects/LayerEffect.swift +103 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/DropShadowStyle.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/LayerStyles/LayerStyle.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ImageLayerModel.swift +49 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/LayerModel.swift +266 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/PreCompLayerModel.swift +74 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/ShapeLayerModel.swift +50 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/SolidLayerModel.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Layers/TextLayerModel.swift +65 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/DashPattern.swift +42 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Marker.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Mask.swift +80 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Objects/Transform.swift +261 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Ellipse.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Fill.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientFill.swift +142 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/GradientStroke.swift +244 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Group.swift +55 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Merge.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Rectangle.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Repeater.swift +181 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/RoundedCorners.swift +53 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Shape.swift +63 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeItem.swift +171 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/ShapeTransform.swift +202 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Star.swift +136 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Stroke.swift +144 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/ShapeItems/Trim.swift +90 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Font.swift +67 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/Glyph.swift +94 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextAnimator.swift +240 -0
- package/platforms/macos/src/vendor/Lottie/Private/Model/Text/TextDocument.swift +142 -0
- package/platforms/macos/src/vendor/Lottie/Private/RootAnimationLayer.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/AnimatorNodeDebugging.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/LayerDebugging.swift +231 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Debugging/TestHelpers.swift +10 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/AnimationKeypathExtension.swift +303 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/BlendMode+Filter.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGColor+RGB.swift +45 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/CGFloatExtensions.swift +152 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/DataExtension.swift +33 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/MathKit.swift +454 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Extensions/StringExtensions.swift +44 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnimationContext.swift +95 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/AnyEquatable.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/Binding+Map.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Helpers/View+ValueChanged.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/InterpolatableExtensions.swift +143 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeExtensions.swift +47 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Interpolatable/KeyframeInterpolator.swift +250 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/LottieAnimationSource.swift +51 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPath.swift +509 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/BezierPathRoundExtension.swift +163 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CGPointExtension.swift +35 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/ColorExtension.swift +101 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CompoundBezierPath.swift +169 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/CurveVertex.swift +190 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/PathElement.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/UnitBezier.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Private/Utility/Primitives/VectorsExtensions.swift +368 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimation.swift +179 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationHelpers.swift +317 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationLayer.swift +1582 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationView.swift +1090 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieAnimationViewInitializers.swift +226 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottiePlaybackMode.swift +266 -0
- package/platforms/macos/src/vendor/Lottie/Public/Animation/LottieView.swift +643 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/AnimationCacheProvider.swift +21 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/DefaultAnimationCache.swift +67 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LRUAnimationCache.swift +11 -0
- package/platforms/macos/src/vendor/Lottie/Public/AnimationCache/LottieAnimationCache.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/DecodingStrategy.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieConfiguration.swift +54 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/LottieURLSession.swift +31 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/ReducedMotionOption.swift +128 -0
- package/platforms/macos/src/vendor/Lottie/Public/Configuration/RenderingEngineOption.swift +117 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedButton.swift +128 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedControl.swift +248 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/AnimatedSwitch.swift +271 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieButton.swift +119 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieSwitch.swift +144 -0
- package/platforms/macos/src/vendor/Lottie/Public/Controls/LottieViewType.swift +79 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCache.swift +66 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/Cache/DotLottieCacheProvider.swift +21 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieConfiguration.swift +72 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFile.swift +186 -0
- package/platforms/macos/src/vendor/Lottie/Public/DotLottie/DotLottieFileHelpers.swift +386 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnimationKeypath.swift +57 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/AnyValueProvider.swift +132 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +96 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +138 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +81 -0
- package/platforms/macos/src/vendor/Lottie/Public/FontProvider/AnimationFontProvider.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Public/ImageProvider/AnimationImageProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Interpolatable.swift +285 -0
- package/platforms/macos/src/vendor/Lottie/Public/Keyframes/Keyframe.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Public/Logging/LottieLogger.swift +138 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/AnimationTime.swift +15 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/LottieColor.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/Primitives/Vectors.swift +36 -0
- package/platforms/macos/src/vendor/Lottie/Public/TextProvider/AnimationTextProvider.swift +135 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/AnimationSubview.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/BundleImageProvider.swift +98 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationKeypath.swift +33 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleAnimationView.swift +567 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleFontProvider.swift +41 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/Compatibility/CompatibleImageProvider.swift +43 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/FilepathImageProvider.swift +78 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/LottieAnimationViewBase.swift +85 -0
- package/platforms/macos/src/vendor/Lottie/Public/iOS/UIColorExtension.swift +23 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/AnimationSubview.macOS.swift +19 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/BundleImageProvider.macOS.swift +90 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/FilepathImageProvider.macOS.swift +86 -0
- package/platforms/macos/src/vendor/Lottie/Public/macOS/LottieAnimationViewBase.macOS.swift +102 -0
- package/src/Lottie.macos.tsrx +129 -0
- package/src/Lottie.tsrx +3 -2
- package/src/Lottie.web.tsrx +28 -11
- package/src/index.macos.ts +2 -0
- package/src/props.ts +6 -1
- package/types/generated/props.d.ts +5 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Archive+Reading.swift
|
|
3
|
+
// ZIPFoundation
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2017-2025 Thomas Zoechling, https://www.peakstep.com and the ZIP Foundation project authors.
|
|
6
|
+
// Released under the MIT License.
|
|
7
|
+
//
|
|
8
|
+
// See https://github.com/weichsel/ZIPFoundation/blob/master/LICENSE for license information.
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
import Foundation
|
|
12
|
+
|
|
13
|
+
extension Archive {
|
|
14
|
+
/// Read a ZIP `Entry` from the receiver and write it to `url`.
|
|
15
|
+
///
|
|
16
|
+
/// - Parameters:
|
|
17
|
+
/// - entry: The ZIP `Entry` to read.
|
|
18
|
+
/// - url: The destination file URL.
|
|
19
|
+
/// - bufferSize: The maximum size of the read buffer and the decompression buffer (if needed).
|
|
20
|
+
/// - skipCRC32: Optional flag to skip calculation of the CRC32 checksum to improve performance.
|
|
21
|
+
/// - allowUncontainedSymlinks: Optional flag to allow symlinks that point to paths outside the destination.
|
|
22
|
+
/// - progress: A progress object that can be used to track or cancel the extract operation.
|
|
23
|
+
/// - Returns: The checksum of the processed content or 0 if the `skipCRC32` flag was set to `true`.
|
|
24
|
+
/// - Throws: An error if the destination file cannot be written or the entry contains malformed content.
|
|
25
|
+
func extract(
|
|
26
|
+
_ entry: Entry,
|
|
27
|
+
to url: URL,
|
|
28
|
+
bufferSize: Int = defaultReadChunkSize,
|
|
29
|
+
skipCRC32: Bool = false,
|
|
30
|
+
allowUncontainedSymlinks: Bool = false,
|
|
31
|
+
progress: Progress? = nil
|
|
32
|
+
) throws -> CRC32 {
|
|
33
|
+
guard bufferSize > 0 else {
|
|
34
|
+
throw ArchiveError.invalidBufferSize
|
|
35
|
+
}
|
|
36
|
+
let fileManager = FileManager()
|
|
37
|
+
var checksum = CRC32(0)
|
|
38
|
+
switch entry.type {
|
|
39
|
+
case .file:
|
|
40
|
+
guard fileManager.itemExists(at: url) == false else {
|
|
41
|
+
throw CocoaError(.fileWriteFileExists, userInfo: [NSFilePathErrorKey: url.path])
|
|
42
|
+
}
|
|
43
|
+
try fileManager.createParentDirectoryStructure(for: url)
|
|
44
|
+
let destinationRepresentation = fileManager.fileSystemRepresentation(withPath: url.path)
|
|
45
|
+
guard let destinationFile: FILEPointer = fopen(destinationRepresentation, "wb+") else {
|
|
46
|
+
throw POSIXError(errno, path: url.path)
|
|
47
|
+
}
|
|
48
|
+
defer { fclose(destinationFile) }
|
|
49
|
+
let consumer = { _ = try Data.write(chunk: $0, to: destinationFile) }
|
|
50
|
+
checksum = try extract(
|
|
51
|
+
entry,
|
|
52
|
+
bufferSize: bufferSize,
|
|
53
|
+
skipCRC32: skipCRC32,
|
|
54
|
+
progress: progress,
|
|
55
|
+
consumer: consumer
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
case .directory:
|
|
59
|
+
let consumer = { (_: Data) in
|
|
60
|
+
try fileManager.createDirectory(at: url, withIntermediateDirectories: true, attributes: nil)
|
|
61
|
+
}
|
|
62
|
+
checksum = try extract(
|
|
63
|
+
entry,
|
|
64
|
+
bufferSize: bufferSize,
|
|
65
|
+
skipCRC32: skipCRC32,
|
|
66
|
+
progress: progress,
|
|
67
|
+
consumer: consumer
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
case .symlink:
|
|
71
|
+
guard fileManager.itemExists(at: url) == false else {
|
|
72
|
+
throw CocoaError(.fileWriteFileExists, userInfo: [NSFilePathErrorKey: url.path])
|
|
73
|
+
}
|
|
74
|
+
let consumer = { (data: Data) in
|
|
75
|
+
guard let linkPath = String(data: data, encoding: .utf8) else { throw ArchiveError.invalidEntryPath }
|
|
76
|
+
|
|
77
|
+
let parentURL = url.deletingLastPathComponent()
|
|
78
|
+
let isAbsolutePath = (linkPath as NSString).isAbsolutePath
|
|
79
|
+
let linkURL = URL(fileURLWithPath: linkPath, relativeTo: isAbsolutePath ? nil : parentURL)
|
|
80
|
+
let isContained = allowUncontainedSymlinks || linkURL.isContained(in: parentURL)
|
|
81
|
+
guard isContained else { throw ArchiveError.uncontainedSymlink }
|
|
82
|
+
|
|
83
|
+
try fileManager.createParentDirectoryStructure(for: url)
|
|
84
|
+
try fileManager.createSymbolicLink(atPath: url.path, withDestinationPath: linkPath)
|
|
85
|
+
}
|
|
86
|
+
checksum = try extract(
|
|
87
|
+
entry,
|
|
88
|
+
bufferSize: bufferSize,
|
|
89
|
+
skipCRC32: skipCRC32,
|
|
90
|
+
progress: progress,
|
|
91
|
+
consumer: consumer
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
try fileManager.transferAttributes(from: entry, toItemAtURL: url)
|
|
95
|
+
return checksum
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/// Read a ZIP `Entry` from the receiver and forward its contents to a `Consumer` closure.
|
|
99
|
+
///
|
|
100
|
+
/// - Parameters:
|
|
101
|
+
/// - entry: The ZIP `Entry` to read.
|
|
102
|
+
/// - bufferSize: The maximum size of the read buffer and the decompression buffer (if needed).
|
|
103
|
+
/// - skipCRC32: Optional flag to skip calculation of the CRC32 checksum to improve performance.
|
|
104
|
+
/// - progress: A progress object that can be used to track or cancel the extract operation.
|
|
105
|
+
/// - consumer: A closure that consumes contents of `Entry` as `Data` chunks.
|
|
106
|
+
/// - Returns: The checksum of the processed content or 0 if the `skipCRC32` flag was set to `true`..
|
|
107
|
+
/// - Throws: An error if the destination file cannot be written or the entry contains malformed content.
|
|
108
|
+
func extract(
|
|
109
|
+
_ entry: Entry,
|
|
110
|
+
bufferSize: Int = defaultReadChunkSize,
|
|
111
|
+
skipCRC32: Bool = false,
|
|
112
|
+
progress: Progress? = nil,
|
|
113
|
+
consumer: Consumer
|
|
114
|
+
) throws -> CRC32 {
|
|
115
|
+
guard bufferSize > 0 else {
|
|
116
|
+
throw ArchiveError.invalidBufferSize
|
|
117
|
+
}
|
|
118
|
+
var checksum = CRC32(0)
|
|
119
|
+
let localFileHeader = entry.localFileHeader
|
|
120
|
+
guard entry.dataOffset <= .max else { throw ArchiveError.invalidLocalHeaderDataOffset }
|
|
121
|
+
fseeko(archiveFile, off_t(entry.dataOffset), SEEK_SET)
|
|
122
|
+
progress?.totalUnitCount = totalUnitCountForReading(entry)
|
|
123
|
+
switch entry.type {
|
|
124
|
+
case .file:
|
|
125
|
+
guard let compressionMethod = CompressionMethod(rawValue: localFileHeader.compressionMethod) else {
|
|
126
|
+
throw ArchiveError.invalidCompressionMethod
|
|
127
|
+
}
|
|
128
|
+
switch compressionMethod {
|
|
129
|
+
case .none: checksum = try readUncompressed(
|
|
130
|
+
entry: entry,
|
|
131
|
+
bufferSize: bufferSize,
|
|
132
|
+
skipCRC32: skipCRC32,
|
|
133
|
+
progress: progress,
|
|
134
|
+
with: consumer
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
case .deflate: checksum = try readCompressed(
|
|
138
|
+
entry: entry,
|
|
139
|
+
bufferSize: bufferSize,
|
|
140
|
+
skipCRC32: skipCRC32,
|
|
141
|
+
progress: progress,
|
|
142
|
+
with: consumer
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
case .directory:
|
|
147
|
+
try consumer(Data())
|
|
148
|
+
progress?.completedUnitCount = totalUnitCountForReading(entry)
|
|
149
|
+
|
|
150
|
+
case .symlink:
|
|
151
|
+
let localFileHeader = entry.localFileHeader
|
|
152
|
+
let size = Int(localFileHeader.compressedSize)
|
|
153
|
+
let data = try Data.readChunk(of: size, from: archiveFile)
|
|
154
|
+
checksum = data.crc32(checksum: 0)
|
|
155
|
+
try consumer(data)
|
|
156
|
+
progress?.completedUnitCount = totalUnitCountForReading(entry)
|
|
157
|
+
}
|
|
158
|
+
return checksum
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Archive+ReadingDeprecated.swift
|
|
3
|
+
// ZIPFoundation
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2017-2025 Thomas Zoechling, https://www.peakstep.com and the ZIP Foundation project authors.
|
|
6
|
+
// Released under the MIT License.
|
|
7
|
+
//
|
|
8
|
+
// See https://github.com/weichsel/ZIPFoundation/blob/master/LICENSE for license information.
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
import Foundation
|
|
12
|
+
|
|
13
|
+
extension Archive {
|
|
14
|
+
|
|
15
|
+
@available(
|
|
16
|
+
*,
|
|
17
|
+
deprecated,
|
|
18
|
+
message: "Please use `Int` for `bufferSize`."
|
|
19
|
+
)
|
|
20
|
+
func extract(
|
|
21
|
+
_ entry: Entry,
|
|
22
|
+
to url: URL,
|
|
23
|
+
bufferSize: UInt32,
|
|
24
|
+
skipCRC32: Bool = false,
|
|
25
|
+
progress: Progress? = nil
|
|
26
|
+
) throws -> CRC32 {
|
|
27
|
+
try extract(entry, to: url, bufferSize: Int(bufferSize), skipCRC32: skipCRC32, progress: progress)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@available(
|
|
31
|
+
*,
|
|
32
|
+
deprecated,
|
|
33
|
+
message: "Please use `Int` for `bufferSize`."
|
|
34
|
+
)
|
|
35
|
+
func extract(
|
|
36
|
+
_ entry: Entry,
|
|
37
|
+
bufferSize: UInt32,
|
|
38
|
+
skipCRC32: Bool = false,
|
|
39
|
+
progress: Progress? = nil,
|
|
40
|
+
consumer: Consumer
|
|
41
|
+
) throws -> CRC32 {
|
|
42
|
+
try extract(
|
|
43
|
+
entry,
|
|
44
|
+
bufferSize: Int(bufferSize),
|
|
45
|
+
skipCRC32: skipCRC32,
|
|
46
|
+
progress: progress,
|
|
47
|
+
consumer: consumer
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Archive+Writing.swift
|
|
3
|
+
// ZIPFoundation
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2017-2025 Thomas Zoechling, https://www.peakstep.com and the ZIP Foundation project authors.
|
|
6
|
+
// Released under the MIT License.
|
|
7
|
+
//
|
|
8
|
+
// See https://github.com/weichsel/ZIPFoundation/blob/master/LICENSE for license information.
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
import Foundation
|
|
12
|
+
|
|
13
|
+
extension Archive {
|
|
14
|
+
enum ModifyOperation: Int {
|
|
15
|
+
case remove = -1
|
|
16
|
+
case add = 1
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
typealias EndOfCentralDirectoryStructure = (EndOfCentralDirectoryRecord, ZIP64EndOfCentralDirectory?)
|
|
20
|
+
|
|
21
|
+
/// Write files, directories or symlinks to the receiver.
|
|
22
|
+
///
|
|
23
|
+
/// - Parameters:
|
|
24
|
+
/// - path: The path that is used to identify an `Entry` within the `Archive` file.
|
|
25
|
+
/// - baseURL: The base URL of the resource to add.
|
|
26
|
+
/// The `baseURL` combined with `path` must form a fully qualified file URL.
|
|
27
|
+
/// - compressionMethod: Indicates the `CompressionMethod` that should be applied to `Entry`.
|
|
28
|
+
/// By default, no compression will be applied.
|
|
29
|
+
/// - bufferSize: The maximum size of the write buffer and the compression buffer (if needed).
|
|
30
|
+
/// - progress: A progress object that can be used to track or cancel the add operation.
|
|
31
|
+
/// - Throws: An error if the source file cannot be read or the receiver is not writable.
|
|
32
|
+
func addEntry(
|
|
33
|
+
with path: String,
|
|
34
|
+
relativeTo baseURL: URL,
|
|
35
|
+
compressionMethod: CompressionMethod = .none,
|
|
36
|
+
bufferSize: Int = defaultWriteChunkSize,
|
|
37
|
+
progress: Progress? = nil
|
|
38
|
+
) throws {
|
|
39
|
+
let fileURL = baseURL.appendingPathComponent(path)
|
|
40
|
+
|
|
41
|
+
try addEntry(
|
|
42
|
+
with: path,
|
|
43
|
+
fileURL: fileURL,
|
|
44
|
+
compressionMethod: compressionMethod,
|
|
45
|
+
bufferSize: bufferSize,
|
|
46
|
+
progress: progress
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// Write files, directories or symlinks to the receiver.
|
|
51
|
+
///
|
|
52
|
+
/// - Parameters:
|
|
53
|
+
/// - path: The path that is used to identify an `Entry` within the `Archive` file.
|
|
54
|
+
/// - fileURL: An absolute file URL referring to the resource to add.
|
|
55
|
+
/// - compressionMethod: Indicates the `CompressionMethod` that should be applied to `Entry`.
|
|
56
|
+
/// By default, no compression will be applied.
|
|
57
|
+
/// - bufferSize: The maximum size of the write buffer and the compression buffer (if needed).
|
|
58
|
+
/// - progress: A progress object that can be used to track or cancel the add operation.
|
|
59
|
+
/// - Throws: An error if the source file cannot be read or the receiver is not writable.
|
|
60
|
+
func addEntry(
|
|
61
|
+
with path: String,
|
|
62
|
+
fileURL: URL,
|
|
63
|
+
compressionMethod: CompressionMethod = .none,
|
|
64
|
+
bufferSize: Int = defaultWriteChunkSize,
|
|
65
|
+
progress: Progress? = nil
|
|
66
|
+
) throws {
|
|
67
|
+
let fileManager = FileManager()
|
|
68
|
+
guard fileManager.itemExists(at: fileURL) else {
|
|
69
|
+
throw CocoaError(.fileReadNoSuchFile, userInfo: [NSFilePathErrorKey: fileURL.path])
|
|
70
|
+
}
|
|
71
|
+
let type = try FileManager.typeForItem(at: fileURL)
|
|
72
|
+
// symlinks do not need to be readable
|
|
73
|
+
guard type == .symlink || fileManager.isReadableFile(atPath: fileURL.path) else {
|
|
74
|
+
throw CocoaError(.fileReadNoPermission, userInfo: [NSFilePathErrorKey: fileURL.path])
|
|
75
|
+
}
|
|
76
|
+
let modDate = try FileManager.fileModificationDateTimeForItem(at: fileURL)
|
|
77
|
+
let uncompressedSize = type == .directory ? 0 : try FileManager.fileSizeForItem(at: fileURL)
|
|
78
|
+
let permissions = try FileManager.permissionsForItem(at: fileURL)
|
|
79
|
+
var provider: Provider
|
|
80
|
+
switch type {
|
|
81
|
+
case .file:
|
|
82
|
+
let entryFileSystemRepresentation = fileManager.fileSystemRepresentation(withPath: fileURL.path)
|
|
83
|
+
guard let entryFile: FILEPointer = fopen(entryFileSystemRepresentation, "rb") else {
|
|
84
|
+
throw POSIXError(errno, path: url.path)
|
|
85
|
+
}
|
|
86
|
+
defer { fclose(entryFile) }
|
|
87
|
+
provider = { _, _ in try Data.readChunk(of: bufferSize, from: entryFile) }
|
|
88
|
+
try addEntry(
|
|
89
|
+
with: path,
|
|
90
|
+
type: type,
|
|
91
|
+
uncompressedSize: uncompressedSize,
|
|
92
|
+
modificationDate: modDate,
|
|
93
|
+
permissions: permissions,
|
|
94
|
+
compressionMethod: compressionMethod,
|
|
95
|
+
bufferSize: bufferSize,
|
|
96
|
+
progress: progress,
|
|
97
|
+
provider: provider
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
case .directory:
|
|
101
|
+
provider = { _, _ in Data() }
|
|
102
|
+
try addEntry(
|
|
103
|
+
with: path.hasSuffix("/") ? path : path + "/",
|
|
104
|
+
type: type,
|
|
105
|
+
uncompressedSize: uncompressedSize,
|
|
106
|
+
modificationDate: modDate,
|
|
107
|
+
permissions: permissions,
|
|
108
|
+
compressionMethod: compressionMethod,
|
|
109
|
+
bufferSize: bufferSize,
|
|
110
|
+
progress: progress,
|
|
111
|
+
provider: provider
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
case .symlink:
|
|
115
|
+
provider = { _, _ -> Data in
|
|
116
|
+
let linkDestination = try fileManager.destinationOfSymbolicLink(atPath: fileURL.path)
|
|
117
|
+
let linkFileSystemRepresentation = fileManager.fileSystemRepresentation(withPath: linkDestination)
|
|
118
|
+
let linkLength = Int(strlen(linkFileSystemRepresentation))
|
|
119
|
+
let linkBuffer = UnsafeBufferPointer(start: linkFileSystemRepresentation, count: linkLength)
|
|
120
|
+
return Data(buffer: linkBuffer)
|
|
121
|
+
}
|
|
122
|
+
try addEntry(
|
|
123
|
+
with: path,
|
|
124
|
+
type: type,
|
|
125
|
+
uncompressedSize: uncompressedSize,
|
|
126
|
+
modificationDate: modDate,
|
|
127
|
+
permissions: permissions,
|
|
128
|
+
compressionMethod: compressionMethod,
|
|
129
|
+
bufferSize: bufferSize,
|
|
130
|
+
progress: progress,
|
|
131
|
+
provider: provider
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/// Write files, directories or symlinks to the receiver.
|
|
137
|
+
///
|
|
138
|
+
/// - Parameters:
|
|
139
|
+
/// - path: The path that is used to identify an `Entry` within the `Archive` file.
|
|
140
|
+
/// - type: Indicates the `Entry.EntryType` of the added content.
|
|
141
|
+
/// - uncompressedSize: The uncompressed size of the data that is going to be added with `provider`.
|
|
142
|
+
/// - modificationDate: A `Date` describing the file modification date of the `Entry`.
|
|
143
|
+
/// Default is the current `Date`.
|
|
144
|
+
/// - permissions: POSIX file permissions for the `Entry`.
|
|
145
|
+
/// Default is `0`o`644` for files and symlinks and `0`o`755` for directories.
|
|
146
|
+
/// - compressionMethod: Indicates the `CompressionMethod` that should be applied to `Entry`.
|
|
147
|
+
/// By default, no compression will be applied.
|
|
148
|
+
/// - bufferSize: The maximum size of the write buffer and the compression buffer (if needed).
|
|
149
|
+
/// - progress: A progress object that can be used to track or cancel the add operation.
|
|
150
|
+
/// - provider: A closure that accepts a position and a chunk size. Returns a `Data` chunk.
|
|
151
|
+
/// - Throws: An error if the source data is invalid or the receiver is not writable.
|
|
152
|
+
func addEntry(
|
|
153
|
+
with path: String,
|
|
154
|
+
type: Entry.EntryType,
|
|
155
|
+
uncompressedSize: Int64,
|
|
156
|
+
modificationDate: Date = Date(),
|
|
157
|
+
permissions: UInt16? = nil,
|
|
158
|
+
compressionMethod: CompressionMethod = .none,
|
|
159
|
+
bufferSize: Int = defaultWriteChunkSize,
|
|
160
|
+
progress: Progress? = nil,
|
|
161
|
+
provider: Provider
|
|
162
|
+
) throws {
|
|
163
|
+
guard accessMode != .read else { throw ArchiveError.unwritableArchive }
|
|
164
|
+
// Directories and symlinks cannot be compressed
|
|
165
|
+
let compressionMethod = type == .file ? compressionMethod : .none
|
|
166
|
+
progress?.totalUnitCount = type == .directory ? defaultDirectoryUnitCount : uncompressedSize
|
|
167
|
+
let eocdRecord = endOfCentralDirectoryRecord
|
|
168
|
+
let zip64EOCD = zip64EndOfCentralDirectory
|
|
169
|
+
guard offsetToStartOfCentralDirectory <= .max else { throw ArchiveError.invalidCentralDirectoryOffset }
|
|
170
|
+
var startOfCD = Int64(offsetToStartOfCentralDirectory)
|
|
171
|
+
fseeko(archiveFile, off_t(startOfCD), SEEK_SET)
|
|
172
|
+
let existingSize = sizeOfCentralDirectory
|
|
173
|
+
let existingData = try Data.readChunk(of: Int(existingSize), from: archiveFile)
|
|
174
|
+
fseeko(archiveFile, off_t(startOfCD), SEEK_SET)
|
|
175
|
+
let fileHeaderStart = Int64(ftello(archiveFile))
|
|
176
|
+
guard fileHeaderStart >= 0 else { throw ArchiveError.unwritableArchive }
|
|
177
|
+
|
|
178
|
+
let modDateTime = modificationDate.fileModificationDateTime
|
|
179
|
+
defer { fflush(self.archiveFile) }
|
|
180
|
+
do {
|
|
181
|
+
// Local File Header
|
|
182
|
+
var localFileHeader = try writeLocalFileHeader(
|
|
183
|
+
path: path,
|
|
184
|
+
compressionMethod: compressionMethod,
|
|
185
|
+
size: (UInt64(uncompressedSize), 0),
|
|
186
|
+
checksum: 0,
|
|
187
|
+
modificationDateTime: modDateTime
|
|
188
|
+
)
|
|
189
|
+
// File Data
|
|
190
|
+
let (written, checksum) = try writeEntry(
|
|
191
|
+
uncompressedSize: uncompressedSize,
|
|
192
|
+
type: type,
|
|
193
|
+
compressionMethod: compressionMethod,
|
|
194
|
+
bufferSize: bufferSize,
|
|
195
|
+
progress: progress,
|
|
196
|
+
provider: provider
|
|
197
|
+
)
|
|
198
|
+
startOfCD = Int64(ftello(archiveFile))
|
|
199
|
+
guard startOfCD >= 0 else { throw ArchiveError.unwritableArchive }
|
|
200
|
+
|
|
201
|
+
// Write the local file header a second time. Now with compressedSize (if applicable) and a valid checksum.
|
|
202
|
+
fseeko(archiveFile, off_t(fileHeaderStart), SEEK_SET)
|
|
203
|
+
localFileHeader = try writeLocalFileHeader(
|
|
204
|
+
path: path,
|
|
205
|
+
compressionMethod: compressionMethod,
|
|
206
|
+
size: (UInt64(uncompressedSize), UInt64(written)),
|
|
207
|
+
checksum: checksum,
|
|
208
|
+
modificationDateTime: modDateTime
|
|
209
|
+
)
|
|
210
|
+
// Central Directory
|
|
211
|
+
fseeko(archiveFile, off_t(startOfCD), SEEK_SET)
|
|
212
|
+
_ = try Data.writeLargeChunk(existingData, size: existingSize, bufferSize: bufferSize, to: archiveFile)
|
|
213
|
+
let permissions = permissions ?? (type == .directory ? defaultDirectoryPermissions : defaultFilePermissions)
|
|
214
|
+
let externalAttributes = FileManager.externalFileAttributesForEntry(of: type, permissions: permissions)
|
|
215
|
+
let centralDir = try writeCentralDirectoryStructure(
|
|
216
|
+
localFileHeader: localFileHeader,
|
|
217
|
+
relativeOffset: UInt64(fileHeaderStart),
|
|
218
|
+
externalFileAttributes: externalAttributes
|
|
219
|
+
)
|
|
220
|
+
// End of Central Directory Record (including ZIP64 End of Central Directory Record/Locator)
|
|
221
|
+
let startOfEOCD = Int64(ftello(archiveFile))
|
|
222
|
+
guard startOfEOCD >= 0 else { throw ArchiveError.unwritableArchive }
|
|
223
|
+
|
|
224
|
+
let eocd = try
|
|
225
|
+
writeEndOfCentralDirectory(
|
|
226
|
+
centralDirectoryStructure: centralDir,
|
|
227
|
+
startOfCentralDirectory: UInt64(startOfCD),
|
|
228
|
+
startOfEndOfCentralDirectory: UInt64(startOfEOCD),
|
|
229
|
+
operation: .add
|
|
230
|
+
)
|
|
231
|
+
(endOfCentralDirectoryRecord, zip64EndOfCentralDirectory) = eocd
|
|
232
|
+
} catch ArchiveError.cancelledOperation {
|
|
233
|
+
try rollback(UInt64(fileHeaderStart), (existingData, existingSize), bufferSize, eocdRecord, zip64EOCD)
|
|
234
|
+
throw ArchiveError.cancelledOperation
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/// Remove a ZIP `Entry` from the receiver.
|
|
239
|
+
///
|
|
240
|
+
/// - Parameters:
|
|
241
|
+
/// - entry: The `Entry` to remove.
|
|
242
|
+
/// - bufferSize: The maximum size for the read and write buffers used during removal.
|
|
243
|
+
/// - progress: A progress object that can be used to track or cancel the remove operation.
|
|
244
|
+
/// - Throws: An error if the `Entry` is malformed or the receiver is not writable.
|
|
245
|
+
func remove(_ entry: Entry, bufferSize: Int = defaultReadChunkSize, progress: Progress? = nil) throws {
|
|
246
|
+
guard accessMode != .read else { throw ArchiveError.unwritableArchive }
|
|
247
|
+
let (tempArchive, tempDir) = try makeTempArchive()
|
|
248
|
+
defer { tempDir.map { try? FileManager().removeItem(at: $0) } }
|
|
249
|
+
progress?.totalUnitCount = totalUnitCountForRemoving(entry)
|
|
250
|
+
var centralDirectoryData = Data()
|
|
251
|
+
var offset: UInt64 = 0
|
|
252
|
+
for currentEntry in self {
|
|
253
|
+
let cds = currentEntry.centralDirectoryStructure
|
|
254
|
+
if currentEntry != entry {
|
|
255
|
+
let entryStart = cds.effectiveRelativeOffsetOfLocalHeader
|
|
256
|
+
fseeko(archiveFile, off_t(entryStart), SEEK_SET)
|
|
257
|
+
let provider: Provider = { _, chunkSize -> Data in
|
|
258
|
+
return try Data.readChunk(of: chunkSize, from: self.archiveFile)
|
|
259
|
+
}
|
|
260
|
+
let consumer: Consumer = {
|
|
261
|
+
if progress?.isCancelled == true { throw ArchiveError.cancelledOperation }
|
|
262
|
+
_ = try Data.write(chunk: $0, to: tempArchive.archiveFile)
|
|
263
|
+
progress?.completedUnitCount += Int64($0.count)
|
|
264
|
+
}
|
|
265
|
+
guard currentEntry.localSize <= .max else { throw ArchiveError.invalidLocalHeaderSize }
|
|
266
|
+
_ = try Data.consumePart(
|
|
267
|
+
of: Int64(currentEntry.localSize),
|
|
268
|
+
chunkSize: bufferSize,
|
|
269
|
+
provider: provider,
|
|
270
|
+
consumer: consumer
|
|
271
|
+
)
|
|
272
|
+
let updatedCentralDirectory = updateOffsetInCentralDirectory(
|
|
273
|
+
centralDirectoryStructure: cds,
|
|
274
|
+
updatedOffset: entryStart - offset
|
|
275
|
+
)
|
|
276
|
+
centralDirectoryData.append(updatedCentralDirectory.data)
|
|
277
|
+
} else { offset = currentEntry.localSize }
|
|
278
|
+
}
|
|
279
|
+
let startOfCentralDirectory = Int64(ftello(tempArchive.archiveFile))
|
|
280
|
+
guard startOfCentralDirectory >= 0 else { throw ArchiveError.unwritableArchive }
|
|
281
|
+
|
|
282
|
+
_ = try Data.write(chunk: centralDirectoryData, to: tempArchive.archiveFile)
|
|
283
|
+
let startOfEndOfCentralDirectory = Int64(ftello(tempArchive.archiveFile))
|
|
284
|
+
guard startOfEndOfCentralDirectory >= 0 else { throw ArchiveError.unwritableArchive }
|
|
285
|
+
|
|
286
|
+
tempArchive.endOfCentralDirectoryRecord = endOfCentralDirectoryRecord
|
|
287
|
+
tempArchive.zip64EndOfCentralDirectory = zip64EndOfCentralDirectory
|
|
288
|
+
let ecodStructure = try
|
|
289
|
+
tempArchive.writeEndOfCentralDirectory(
|
|
290
|
+
centralDirectoryStructure: entry.centralDirectoryStructure,
|
|
291
|
+
startOfCentralDirectory: UInt64(startOfCentralDirectory),
|
|
292
|
+
startOfEndOfCentralDirectory: UInt64(startOfEndOfCentralDirectory),
|
|
293
|
+
operation: .remove
|
|
294
|
+
)
|
|
295
|
+
(tempArchive.endOfCentralDirectoryRecord, tempArchive.zip64EndOfCentralDirectory) = ecodStructure
|
|
296
|
+
(endOfCentralDirectoryRecord, zip64EndOfCentralDirectory) = ecodStructure
|
|
297
|
+
fflush(tempArchive.archiveFile)
|
|
298
|
+
try replaceCurrentArchive(with: tempArchive)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
func replaceCurrentArchive(with archive: Archive) throws {
|
|
302
|
+
if isMemoryArchive {
|
|
303
|
+
#if swift(>=5.0)
|
|
304
|
+
guard let data = archive.data else {
|
|
305
|
+
throw ArchiveError.unwritableArchive
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
let config = try Archive.makeBackingConfiguration(for: data, mode: .update)
|
|
309
|
+
archiveFile = config.file
|
|
310
|
+
memoryFile = config.memoryFile
|
|
311
|
+
endOfCentralDirectoryRecord = config.endOfCentralDirectoryRecord
|
|
312
|
+
zip64EndOfCentralDirectory = config.zip64EndOfCentralDirectory
|
|
313
|
+
#endif
|
|
314
|
+
} else {
|
|
315
|
+
let fileManager = FileManager()
|
|
316
|
+
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS)
|
|
317
|
+
do {
|
|
318
|
+
_ = try fileManager.replaceItemAt(url, withItemAt: archive.url)
|
|
319
|
+
} catch {
|
|
320
|
+
_ = try fileManager.removeItem(at: url)
|
|
321
|
+
_ = try fileManager.moveItem(at: archive.url, to: url)
|
|
322
|
+
}
|
|
323
|
+
#else
|
|
324
|
+
_ = try fileManager.removeItem(at: url)
|
|
325
|
+
_ = try fileManager.moveItem(at: archive.url, to: url)
|
|
326
|
+
#endif
|
|
327
|
+
let fileSystemRepresentation = fileManager.fileSystemRepresentation(withPath: url.path)
|
|
328
|
+
guard let file = fopen(fileSystemRepresentation, "rb+") else { throw ArchiveError.unreadableArchive }
|
|
329
|
+
|
|
330
|
+
archiveFile = file
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// MARK: - Private
|
|
336
|
+
|
|
337
|
+
extension Archive {
|
|
338
|
+
|
|
339
|
+
private func updateOffsetInCentralDirectory(
|
|
340
|
+
centralDirectoryStructure: CentralDirectoryStructure,
|
|
341
|
+
updatedOffset: UInt64
|
|
342
|
+
) -> CentralDirectoryStructure {
|
|
343
|
+
let zip64ExtendedInformation = Entry.ZIP64ExtendedInformation(
|
|
344
|
+
zip64ExtendedInformation: centralDirectoryStructure.zip64ExtendedInformation,
|
|
345
|
+
offset: updatedOffset
|
|
346
|
+
)
|
|
347
|
+
let offsetInCD = updatedOffset < maxOffsetOfLocalFileHeader ? UInt32(updatedOffset) : UInt32.max
|
|
348
|
+
return CentralDirectoryStructure(
|
|
349
|
+
centralDirectoryStructure: centralDirectoryStructure,
|
|
350
|
+
zip64ExtendedInformation: zip64ExtendedInformation,
|
|
351
|
+
relativeOffset: offsetInCD
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private func rollback(
|
|
356
|
+
_ localFileHeaderStart: UInt64,
|
|
357
|
+
_ existingCentralDirectory: (data: Data, size: UInt64),
|
|
358
|
+
_ bufferSize: Int,
|
|
359
|
+
_ endOfCentralDirRecord: EndOfCentralDirectoryRecord,
|
|
360
|
+
_ zip64EndOfCentralDirectory: ZIP64EndOfCentralDirectory?
|
|
361
|
+
) throws {
|
|
362
|
+
fflush(archiveFile)
|
|
363
|
+
ftruncate(fileno(archiveFile), off_t(localFileHeaderStart))
|
|
364
|
+
fseeko(archiveFile, off_t(localFileHeaderStart), SEEK_SET)
|
|
365
|
+
_ = try Data.writeLargeChunk(
|
|
366
|
+
existingCentralDirectory.data,
|
|
367
|
+
size: existingCentralDirectory.size,
|
|
368
|
+
bufferSize: bufferSize,
|
|
369
|
+
to: archiveFile
|
|
370
|
+
)
|
|
371
|
+
_ = try Data.write(chunk: existingCentralDirectory.data, to: archiveFile)
|
|
372
|
+
if let zip64EOCD = zip64EndOfCentralDirectory {
|
|
373
|
+
_ = try Data.write(chunk: zip64EOCD.data, to: archiveFile)
|
|
374
|
+
}
|
|
375
|
+
_ = try Data.write(chunk: endOfCentralDirRecord.data, to: archiveFile)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
private func makeTempArchive() throws -> (Archive, URL?) {
|
|
379
|
+
var archive: Archive
|
|
380
|
+
var url: URL?
|
|
381
|
+
if isMemoryArchive {
|
|
382
|
+
#if swift(>=5.0)
|
|
383
|
+
archive = try Archive(
|
|
384
|
+
data: Data(),
|
|
385
|
+
accessMode: .create,
|
|
386
|
+
pathEncoding: pathEncoding
|
|
387
|
+
)
|
|
388
|
+
#else
|
|
389
|
+
fatalError("Memory archives are unsupported.")
|
|
390
|
+
#endif
|
|
391
|
+
} else {
|
|
392
|
+
let manager = FileManager()
|
|
393
|
+
let tempDir = URL.temporaryReplacementDirectoryURL(for: self)
|
|
394
|
+
let uniqueString = ProcessInfo.processInfo.globallyUniqueString
|
|
395
|
+
let tempArchiveURL = tempDir.appendingPathComponent(uniqueString)
|
|
396
|
+
try manager.createParentDirectoryStructure(for: tempArchiveURL)
|
|
397
|
+
let tempArchive = try Archive(url: tempArchiveURL, accessMode: .create)
|
|
398
|
+
archive = tempArchive
|
|
399
|
+
url = tempDir
|
|
400
|
+
}
|
|
401
|
+
return (archive, url)
|
|
402
|
+
}
|
|
403
|
+
}
|