safe

package
v0.0.0-...-63c65b4 Latest Latest
Warning

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

Go to latest
Published: May 25, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package safe provides safe file write semantics by leveraging Rename's() safeity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	*os.File
	// contains filtered or unexported fields
}

File provides for safe file writes.

func CreateFile

func CreateFile(filePath string) (*File, error)

CreateFile creates a new file at filePath for safe writes, it also creates parent directories if they don't exist.

func CreateFileWithPrefix

func CreateFileWithPrefix(filePath string, prefix string) (*File, error)

CreateFileWithPrefix creates a new file at filePath for safe writes, it also creates parent directories if they don't exist. prefix specifies the prefix of the temporary files so that cleaning stale temp files is easy.

func CreateFileWithSuffix

func CreateFileWithSuffix(filePath string, suffix string) (*File, error)

CreateFileWithSuffix is similar to CreateFileWithPrefix, but the second argument is treated as suffix for the temporary files.

func (*File) Close

func (f *File) Close() error

Close the file, returns an error if any

func (*File) CloseAndRemove

func (f *File) CloseAndRemove() error

CloseAndRemove closes the temp file, and safely removes it. Returns error if any.

func (*File) SyncClose

func (f *File) SyncClose() error

SyncClose sync file to disk and close, returns an error if any

type Vault

type Vault interface {
	io.ReadWriteCloser
	SyncClose() error
	CloseAndRemove() error
}

Vault - vault is an interface for different implementations of safe i/o semantics.

Jump to

Keyboard shortcuts

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