mirror of
https://github.com/kopia/kopia.git
synced 2026-03-27 02:21:59 -04:00
29 lines
671 B
Go
29 lines
671 B
Go
package snapshotfs
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/fs"
|
|
"github.com/kopia/kopia/snapshot"
|
|
)
|
|
|
|
const directoryStreamType = "kopia:directory"
|
|
|
|
// readDirEntries reads all directory entries from the specified reader.
|
|
func readDirEntries(r io.Reader) ([]*snapshot.DirEntry, *fs.DirectorySummary, error) {
|
|
var dir snapshot.DirManifest
|
|
|
|
if err := json.NewDecoder(r).Decode(&dir); err != nil {
|
|
return nil, nil, errors.Wrap(err, "unable to parse directory object")
|
|
}
|
|
|
|
if dir.StreamType != directoryStreamType {
|
|
return nil, nil, errors.Errorf("invalid directory stream type")
|
|
}
|
|
|
|
return dir.Entries, dir.Summary, nil
|
|
}
|