zipfsrw

package
v1.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

README

zipfsrw

zipfsrw is a wrapper for reading and writing ZIP files using the writefs.FullFS interface.

Features

  • ZIP Management: Efficiently handles reading from and writing to ZIP archives.
  • Write Operations: Supports Create, Append, and Copy. Note that many ZIP write operations require rewriting the archive.
  • On-Close Writing: Changes are often buffered and finalized when Close() is called.
  • Transparent Access: Presents the contents of a ZIP file as a regular filesystem.

Usage

import (
	"os"
	"github.com/je4/filesystem/v3/pkg/zipfsrw"
)

// Open a ZIP file for writing
f, _ := os.Create("archive.zip")
zfsrw, err := zipfsrw.NewFS(
    f, 
    rawZipFS, 
    false, // compression
    "archive.zip", 
    false, // read-only
    logger,
)

// Write a file into the ZIP
w, _ := zfsrw.Create("in-zip.txt")
w.Write([]byte("Hello inside ZIP!"))
w.Close()

// Finalize and close the ZIP
zfsrw.Close()

Documentation

Overview

Package zipfsrw provides a functionality to create and update content of a zip file

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCreateFSChecksumFunc

func NewCreateFSChecksumFunc(noCompression bool, algs []checksum.DigestAlgorithm, logger zLogger.ZLogger) writefs.CreateFSFunc

func NewCreateFSEncryptedChecksumFunc

func NewCreateFSEncryptedChecksumFunc(noCompression bool, algs []checksum.DigestAlgorithm, keyUri string, logger zLogger.ZLogger) writefs.CreateFSFunc

func NewCreateFSFunc

func NewCreateFSFunc(noCompression bool, logger zLogger.ZLogger) writefs.CreateFSFunc

func NewFS

func NewFS(writer io.Writer, zipFS zipfs.OpenRawZipFS, noCompression bool, name string, readOnly bool, logger zLogger.ZLogger) (*zipFSRW, error)

func NewFSFile

func NewFSFile(baseFS fs.FS, path string, noCompression, readOnly bool, logger zLogger.ZLogger, writers ...io.Writer) (fs.FS, error)

NewZipFSRW creates a new ReadWriteFS If the file does not exist, it will be created on the first write operation. If the file exists, it will be opened and read. Changes will be written to an additional file and then renamed to the original file. additional writers will added via io.MultiWriter additional writers will not be closed

func NewFSFileChecksums

func NewFSFileChecksums(baseFS fs.FS, path string, noCompression bool, algs []checksum.DigestAlgorithm, readOnly bool, logger zLogger.ZLogger, writers ...io.Writer) (fs.FS, error)

NewZipFSRW creates a new ReadWriteFS If the file does not exist, it will be created on the first write operation. If the file exists, it will be opened and read. Changes will be written to an additional file and then renamed to the original file.

func NewFSFileEncryptedChecksums

func NewFSFileEncryptedChecksums(baseFS fs.FS, path string, noCompression bool, algs []checksum.DigestAlgorithm, keyUri string, logger zLogger.ZLogger) (*fsFileEncryptedChecksums, error)

NewFSFileEncryptedChecksums creates a new ReadWriteFS If the file does not exist, it will be created on the first write operation. If the file exists, it will be opened and read. Changes will be written to an additional file and then renamed to the original file.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL