예제 #1
0
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
}
예제 #2
0
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
}