??
This commit is contained in:
20
server/sys/fs.go
Normal file
20
server/sys/fs.go
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user