-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preallocate: use custom preallocate directives where possible
Updates #4
- Loading branch information
Showing
4 changed files
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
// +build !linux | ||
|
||
package sync | ||
|
||
import "os" | ||
|
||
func fallocate(f *os.File, size int64) error { | ||
func Preallocate(f *os.File, size int64) error { | ||
err := preallocate(f, size) | ||
if err == nil { | ||
return nil | ||
} | ||
|
||
// use default truncation if platform specific allocation fails | ||
return f.Truncate(size) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// +build !linux,!darwin | ||
|
||
package sync | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func preallocate(f *os.File, size int64) error { | ||
return fmt.Errorf("Operation not supported on this platform") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters