mirror of
https://github.com/restic/restic.git
synced 2026-11-23 05:42:39 +00:00
Move PreallocateFile to fs package
This commit is contained in:
1 parent
88c63a029c
commit
ffc6b3d887
5 files changed
+11
-11
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package fs
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func PreallocateFile(wr *os.File, size int64) error {
|
||||
if size <= 0 {
|
||||
return nil
|
||||
}
|
||||
// int fallocate(int fd, int mode, off_t offset, off_t len)
|
||||
// use mode = 0 to also change the file size
|
||||
return unix.Fallocate(int(wr.Fd()), 0, 0, size)
|
||||
}
|
||||
Reference in new issue
Block a user