diff options
Diffstat (limited to 'weed/filer2/filechunks.go')
| -rw-r--r-- | weed/filer2/filechunks.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go new file mode 100644 index 000000000..b2f05de3a --- /dev/null +++ b/weed/filer2/filechunks.go @@ -0,0 +1,23 @@ +package filer2 + +type Chunks []FileChunk + +func (chunks Chunks) TotalSize() (size uint64) { + for _, c := range chunks { + t := uint64(c.Offset + int64(c.Size)) + if size < t { + size = t + } + } + return +} + +func (chunks Chunks) Len() int { + return len(chunks) +} +func (chunks Chunks) Swap(i, j int) { + chunks[i], chunks[j] = chunks[j], chunks[i] +} +func (chunks Chunks) Less(i, j int) bool { + return chunks[i].Offset < chunks[j].Offset +} |
