Files
yt-dlp-webui/server/sys/fs.go
2023-01-10 19:10:20 +01:00

21 lines
387 B
Go

package sys
import (
"os"
"golang.org/x/sys/unix"
)
// package containing fs related operation (unix only)
// FreeSpace gets the available Bytes writable to download directory
func FreeSpace() (uint64, error) {
var stat unix.Statfs_t
wd, err := os.Getwd()
if err != nil {
return 0, err
}
unix.Statfs(wd+"/downloads", &stat)
return (stat.Bavail * uint64(stat.Bsize)), nil
}