package ioutils

import "github.com/dotcloud/docker/pkg/ioutils"

Index

Functions

func AtomicWriteFile

func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error

AtomicWriteFile atomically writes data to a file named by filename and with the specified permission bits. NOTE: umask is not considered for the file's permissions.

Deprecated: use atomicwriter.WriteFile instead.

func NewAtomicFileWriter

func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, error)

NewAtomicFileWriter returns WriteCloser so that writing to it writes to a temporary file and closing it atomically changes the temporary file to destination path. Writing and closing concurrently is not allowed. NOTE: umask is not considered for the file's permissions.

Deprecated: use atomicwriter.New instead.

func NewAtomicWriteSet

func NewAtomicWriteSet(tmpDir string) (*atomicwriter.WriteSet, error)

NewAtomicWriteSet creates a new atomic write set to atomically create a set of files. The given directory is used as the base directory for storing files before commit. If no temporary directory is given the system default is used.

Deprecated: use atomicwriter.NewWriteSet instead.

func NewCancelReadCloser

func NewCancelReadCloser(ctx context.Context, in io.ReadCloser) io.ReadCloser

NewCancelReadCloser creates a wrapper that closes the ReadCloser when the context is cancelled. The returned io.ReadCloser must be closed when it is no longer needed.

func NewReadCloserWrapper

func NewReadCloserWrapper(r io.Reader, closer func() error) io.ReadCloser

NewReadCloserWrapper wraps an io.Reader, and implements an io.ReadCloser. It calls the given callback function when closed.

func NewWriteCloserWrapper

func NewWriteCloserWrapper(r io.Writer, closer func() error) io.WriteCloser

NewWriteCloserWrapper returns a new io.WriteCloser.

Types

type AtomicWriteSet

type AtomicWriteSet = atomicwriter.WriteSet

AtomicWriteSet is used to atomically write a set of files and ensure they are visible at the same time. Must be committed to a new directory.

Deprecated: use atomicwriter.WriteSet instead.

type WriteFlusher

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

WriteFlusher wraps the Write and Flush operation ensuring that every write is a flush. In addition, the Close method can be called to intercept Read/Write calls if the targets lifecycle has already ended.

func NewWriteFlusher

func NewWriteFlusher(w io.Writer) *WriteFlusher

NewWriteFlusher returns a new WriteFlusher.

func (*WriteFlusher) Close

func (wf *WriteFlusher) Close() error

Close closes the write flusher, disallowing any further writes to the target. After the flusher is closed, all calls to write or flush will result in an error.

func (*WriteFlusher) Flush

func (wf *WriteFlusher) Flush()

Flush the stream immediately.

func (*WriteFlusher) Flushed

func (wf *WriteFlusher) Flushed() bool

Flushed returns the state of flushed. If it's flushed, return true, or else it return false.

func (*WriteFlusher) Write

func (wf *WriteFlusher) Write(b []byte) (n int, err error)

Bugs

Remove this method. Its use is inherently racy. Seems to be used to detect whether or a response code has been issued or not. Another hook should be used instead.

Source Files

fswriters_deprecated.go readers.go writeflusher.go writers.go

Version
v28.0.0-rc.1+incompatible
Published
Feb 6, 2025
Platform
linux/amd64
Imports
8 packages
Last checked
5 minutes ago

Tools for package owners.