filesystem

package
v0.0.0-...-9e33677 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package filesystem provides various interfaces and types for working with Binary Large Object's (BLOBs) based on a FileSystem.

When working with BLOBs through this package, the main interaction point will be the Blob.

Additionally, the package provides convenience implementations of typical blob scenarios:

  • GetBlobFromOSPath
  • CopyBlobToOSPath

Index

Constants

View Source
const DefaultFileIOBufferSize = 1 << 20 // 1 MiB

Variables

View Source
var ErrReadOnly = fmt.Errorf("read only file system")

Functions

func CopyBlobToOSPath

func CopyBlobToOSPath(blob blob.ReadOnlyBlob, path string) error

CopyBlobToOSPath copies the content of a blob.ReadOnlyBlob to a local path on the operating system's filesystem. It opens the file in os.O_APPEND mode. If the file does not exist, it will be created (os.O_CREATE). The function also handles named pipes by setting the appropriate file mode (os.ModeNamedPipe). It uses a buffered I/O operation to improve performance, leveraing the internal ioBufPool.

Types

type Blob

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

Blob is a blob.Blob that is stored in a fs.FS. It delegates all meta operations to the underlying filesystem.

func GetBlobFromOSPath

func GetBlobFromOSPath(path string) (*Blob, error)

GetBlobFromOSPath returns a blob that reads from the operating system file system. It creates a new virtual FileSystem instance based on the directory of the provided path. The blob is created using the NewFileBlob function, see Blob for details.

func NewFileBlob

func NewFileBlob(fs FileSystem, path string) *Blob

func (*Blob) Digest

func (f *Blob) Digest() (string, bool)

func (*Blob) ReadCloser

func (f *Blob) ReadCloser() (io.ReadCloser, error)

func (*Blob) Size

func (f *Blob) Size() int64

func (*Blob) WriteCloser

func (f *Blob) WriteCloser() (io.WriteCloser, error)

type File

type File interface {
	fs.File
	io.Writer
}

File is an interface that needs to be fulfilled by any file implementation to be usable within the OCM Bindings. The File is a typical file implementation that is also writeable.

type FileSystem

type FileSystem interface {
	Base() string
	Open(name string) (fs.File, error)
	OpenFile(name string, flag int, perm os.FileMode) (fs.File, error)
	MkdirAll(name string, perm os.FileMode) error
	Remove(name string) error
	ReadDir(name string) ([]fs.DirEntry, error)
	RemoveAll(path string) error
	Stat(name string) (fs.FileInfo, error)
	ReadOnly() bool
	ForceReadOnly()
}

FileSystem is an interface that needs to be fulfilled by any filesystem implementation to be usable within the OCM Bindings. The ComponentVersionReference Implementation is the osFileSystem which is backed by the os package.

func NewFS

func NewFS(base string, flag int) (FileSystem, error)

Jump to

Keyboard shortcuts

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