zipfsw

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: 17 Imported by: 0

README

zipfsrw

zipfsrw is a wrapper for linear writing of ZIP files using the writefs.FullFS interface.

Features

  • Linear Writing: Supports only linear write operations (Create).
  • Write-Only: Does not support reading from the ZIP file during the write process.
  • On-Close Finalization: The ZIP structure is finalized when Close() is called.

Usage

import (
	"os"
	"github.com/je4/filesystem/v4/pkg/zipfsw"
)

// Open a ZIP file for writing
f, _ := os.Create("archive.zip")
zfsrw, err := zipfsw.NewFS(
    f, 
    false, // no-compression
    "archive.zip", 
    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 zipfsw 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, closeWriter bool, noCompression bool, name string, algs []checksum.DigestAlgorithm, csFunc ChecksumFunc, logger zLogger.ZLogger) (fs.FS, error)

NewFS creates a new zip file system. The writer is used to write the zip file. If closeWriter is true and writer implements io.WriteCloser, the writer will be closed when the file system is closed. If noCompression is true, the files will be stored without compression. The name is used for identification (e.g. in Equal). The logger is used for logging errors.

func NewFSFile

func NewFSFile(baseFS fs.FS, path string, noCompression 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, 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

type ChecksumFunc

type ChecksumFunc func(css map[checksum.DigestAlgorithm]string) error

Jump to

Keyboard shortcuts

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