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 ¶
const DefaultFileIOBufferSize = 1 << 20 // 1 MiB
Variables ¶
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 ¶
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) ReadCloser ¶
func (f *Blob) ReadCloser() (io.ReadCloser, error)
func (*Blob) WriteCloser ¶
func (f *Blob) WriteCloser() (io.WriteCloser, error)
type File ¶
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.