filebuf

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2022 Hal Canary Use of this program is governed by the file LICENSE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileBuf

type FileBuf struct {
	Path string
	// contains filtered or unexported fields
}

Implements `io.Writer`, `io.StringWriter`, `io.WriteCloser`. When `Close()` is called, writes buffer to `Path`, if it differs from the contents of the file at `Path` or there is no file at `Path`. `Path` must be populated by the caller.

func (FileBuf) Changed

func (b FileBuf) Changed() bool

After `Close` is called, this will return `true` if the file changed.

func (*FileBuf) Close

func (b *FileBuf) Close() error

Close writes buffer to `Path`, if it differs from the contents of the file at `Path` or there is no file at `Path`.

func (*FileBuf) Len

func (b *FileBuf) Len() int

Len returns the number of bytes in the buffer.

func (*FileBuf) Reset

func (b *FileBuf) Reset() error

Reset returns the internal buffer to empty.

func (*FileBuf) Write

func (b *FileBuf) Write(p []byte) (int, error)

Write implements the standard Write interface

func (*FileBuf) WriteString

func (b *FileBuf) WriteString(s string) (int, error)

WriteString writes the contents of s.

Jump to

Keyboard shortcuts

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