archive

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Copyright (C) 2023 by Posit Software, PBC

Copyright (C) 2023 by Posit Software, PBC

Index

Constants

View Source
const (
	DescriptionRepository = "Repository: RSPM"
	DescriptionEncoding   = "Encoding: %s"
)

Variables

This section is empty.

Functions

func PreferredReadme

func PreferredReadme(oldName, newName string) bool

Types

type LenWriter

type LenWriter struct {
	// contains filtered or unexported fields
}

func (*LenWriter) Write

func (w *LenWriter) Write(p []byte) (nn int, err error)

type RPackageArchive

type RPackageArchive struct {
	// contains filtered or unexported fields
}

RPackageArchive supports rewriting .tar.gz source packages and binaries in a single data stream while (a) calculating the source and destination SHA256 checksums, (b) calculating the source and destination file sizes, (c) rewriting the `DESCRIPTION` file to include the correct `Repository` field, and (d) rewriting the `MD5` file with any corrections required for the updated DESCRIPTION.

IMPORTANT: If you make improvements to `RPackageArchive`, please also update `RPackageZipArchive` in `archive_zip.go`. We decided to maintain the code separately since there are some substantial differences in reading ZIP vs. TAR archives.

func NewRPackageArchive

func NewRPackageArchive(bufferSize, gzipLevel int) *RPackageArchive

func (*RPackageArchive) GetReadme

func (a *RPackageArchive) GetReadme(stream io.Reader, wReadme io.Writer) (bool, error)

func (*RPackageArchive) RewriteBinary

func (a *RPackageArchive) RewriteBinary(r io.Reader, w io.Writer) (results *Results, err error)

func (*RPackageArchive) RewriteWithReadme

func (a *RPackageArchive) RewriteWithReadme(r io.Reader, w, wReadme io.Writer) (results *Results, err error)

type RPackageZipArchive

type RPackageZipArchive struct {
	// contains filtered or unexported fields
}

RPackageZipArchive is very similar to RPackageArchive (see `archive.go`). However, ZIP reading requires random access (io.ReaderAt), so we had to create a separate util. Instead of passing a stream as `r`, instead save the ZIP archive to a temporary file and then pass an `*os.File` as `r`. The file will be scanned twice: once to calculate the original checksum and size, and once to rewrite to the destination.

IMPORTANT: If you make improvements to `RPackageZipArchive`, please also update `RPackageArchive` in `archive.go`.

func NewRPackageZipArchive

func NewRPackageZipArchive(bufferSize int) *RPackageZipArchive

func (*RPackageZipArchive) RewriteBinary

func (a *RPackageZipArchive) RewriteBinary(r *os.File, w io.Writer) (results *Results, err error)

type Results

type Results struct {
	OriginalSize      int64
	RewrittenSize     int64
	OriginalChecksum  string
	RewrittenChecksum string
	Description       string
	ReadmeMarkdown    bool
}

type RewriteResults

type RewriteResults struct {
	Results
	RewrittenPath       string
	ExtractedReadmePath string
}

Jump to

Keyboard shortcuts

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