func LoadDPs(r *resource.Resource, part string) (*DirPage, error) { m, e := r.Open(part + "inf") if e != nil { return nil, e } f := new(DirPage) defer m.Close() dec := gob.NewDecoder(io.NewSectionReader(m, 0, MB64)) e = dec.Decode(f) return f, e }
func LoadParts(r *resource.Resource) (*FileParts, error) { m, e := r.Open("parts") if e != nil { return nil, e } f := new(FileParts) defer m.Close() dec := gob.NewDecoder(io.NewSectionReader(m, 0, MB64)) e = dec.Decode(f) return f, e }
func LoadMeta(r *resource.Resource) (*FileMetadata, error) { m, e := r.Open("meta") if e != nil { return nil, e } f := new(FileMetadata) defer m.Close() dec := gob.NewDecoder(io.NewSectionReader(m, 0, MB64)) e = dec.Decode(f) return f, e }
func SaveDPs(r *resource.Resource, f *DirPage, part string) error { if f == nil { return errors.New("BARF!") } m, e := r.Create(part + "inf") if e != nil { return e } defer m.Close() b := new(bytes.Buffer) enc := gob.NewEncoder(b) e = enc.Encode(f) if e != nil { return e } _, e = m.WriteAt(b.Bytes(), 0) return e }
func SaveParts(r *resource.Resource, f *FileParts) error { if f == nil { return errors.New("BARF!") } m, e := r.Create("parts") if e != nil { return e } defer m.Close() b := new(bytes.Buffer) enc := gob.NewEncoder(b) e = enc.Encode(f) if e != nil { return e } _, e = m.WriteAt(b.Bytes(), 0) return e }