Documentation ¶
Overview ¶
Package checksumfile can be used to persist data to a file so that it is never corrupted. It only works on unix* systems as it writes data to a temp file and uses rename syscall to move the file atomically. An example is:
func main() { data := []byte{"Hello World!"} filename := "var/lib/kronos/nodeInfo" // directory in which file is // stored should exist beforehand and have w and x permissions for user, // otherwise write will fail. if err := checksumfile.Write(filename, data) { panic(err) } read, err := checksumfile.Read(filename) if err != nil { panic(err) } fmt.Println(read) } Package checksumfile is a generated protocol buffer package. It is generated from these files: kronos/checksumfile/fileextent.proto It has these top-level messages: FileExtent
Index ¶
- Variables
- func Read(filename string) ([]byte, error)
- func Write(filename string, p []byte) error
- type FileExtent
- func (*FileExtent) Descriptor() ([]byte, []int)
- func (m *FileExtent) Marshal() (dAtA []byte, err error)
- func (m *FileExtent) MarshalTo(dAtA []byte) (int, error)
- func (*FileExtent) ProtoMessage()
- func (m *FileExtent) Reset()
- func (m *FileExtent) Size() (n int)
- func (m *FileExtent) String() string
- func (m *FileExtent) Unmarshal(dAtA []byte) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidLengthFileextent = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowFileextent = fmt.Errorf("proto: integer overflow") )
View Source
var ErrChecksumMismatch = errors.New("checksum and data don't match")
ErrChecksumMismatch is returned when checksum and data don't match for a file
Functions ¶
Types ¶
type FileExtent ¶
type FileExtent struct { Checksum []byte `protobuf:"bytes,1,opt,name=Checksum,proto3" json:"Checksum,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"` }
func (*FileExtent) Descriptor ¶
func (*FileExtent) Descriptor() ([]byte, []int)
func (*FileExtent) Marshal ¶
func (m *FileExtent) Marshal() (dAtA []byte, err error)
func (*FileExtent) ProtoMessage ¶
func (*FileExtent) ProtoMessage()
func (*FileExtent) Reset ¶
func (m *FileExtent) Reset()
func (*FileExtent) Size ¶
func (m *FileExtent) Size() (n int)
func (*FileExtent) String ¶
func (m *FileExtent) String() string
func (*FileExtent) Unmarshal ¶
func (m *FileExtent) Unmarshal(dAtA []byte) error
Click to show internal directories.
Click to hide internal directories.