diff options
Diffstat (limited to 'worker/lib/size.go')
-rw-r--r-- | worker/lib/size.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/worker/lib/size.go b/worker/lib/size.go new file mode 100644 index 00000000..f00437c3 --- /dev/null +++ b/worker/lib/size.go @@ -0,0 +1,15 @@ +package lib + +import ( + "fmt" + "os" +) + +// FileSize returns the size of the file specified by name +func FileSize(name string) (uint32, error) { + fileInfo, err := os.Stat(name) + if err != nil { + return 0, fmt.Errorf("failed to obtain fileinfo: %w", err) + } + return uint32(fileInfo.Size()), nil +} |