From bb6ac970b4a0ce0ca6bf3055c757dd889cac6d27 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Tue, 23 Jan 2024 06:13:32 -0800 Subject: [PATCH] initial commits --- filesize.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 filesize.go 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 +}