diff --git a/filesize.go b/filesize.go new file mode 100644 index 0000000..350b753 --- /dev/null +++ b/filesize.go @@ -0,0 +1,25 @@ +package raft + +import ( + "io/fs" +) + +// fileSize returns the file-size of an fs.File. +func fileSize(file fs.File) (int64, error) { + + if nil == file { + return 0, errNilFile + } + + var fileinfo fs.FileInfo + { + var err error + + fileinfo, err = fileInfo(file) + if nil != err { + return 0, err + } + } + + return fileinfo.Size(), nil +}