mirror of
https://github.com/get-drexa/drive.git
synced 2025-12-01 05:51:39 +00:00
wip: vfs implementation
This commit is contained in:
22
apps/backend/internal/virtualfs/counting_reader.go
Normal file
22
apps/backend/internal/virtualfs/counting_reader.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package virtualfs
|
||||
|
||||
import "io"
|
||||
|
||||
type CountingReader struct {
|
||||
reader io.Reader
|
||||
count int64
|
||||
}
|
||||
|
||||
func NewCountingReader(reader io.Reader) *CountingReader {
|
||||
return &CountingReader{reader: reader}
|
||||
}
|
||||
|
||||
func (r *CountingReader) Read(p []byte) (n int, err error) {
|
||||
n, err = r.reader.Read(p)
|
||||
r.count += int64(n)
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (r *CountingReader) Count() int64 {
|
||||
return r.count
|
||||
}
|
||||
Reference in New Issue
Block a user