Skip to content

Commit

Permalink
fix: add wrapper for osfile.Truncate function to restore ability to b…
Browse files Browse the repository at this point in the history
…uild wazero bare metal using TinyGo 0.33

Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Aug 22, 2024
1 parent dbc4b62 commit 483bc44
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/sysfs/osfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (f *osFile) Pwrite(buf []byte, off int64) (n int, errno experimentalsys.Err

// Truncate implements the same method as documented on sys.File
func (f *osFile) Truncate(size int64) (errno experimentalsys.Errno) {
if errno = experimentalsys.UnwrapOSError(f.file.Truncate(size)); errno != 0 {
if errno = experimentalsys.UnwrapOSError(truncate(f.file, size)); errno != 0 {
// Defer validation overhead until we've already had an error.
errno = fileError(f, f.closed, errno)
}
Expand Down
9 changes: 9 additions & 0 deletions internal/sysfs/truncate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !tinygo

package sysfs

import "os"

func truncate(file *os.File, size int64) error {
return file.Truncate(size)
}
9 changes: 9 additions & 0 deletions internal/sysfs/truncate_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build tinygo

package sysfs

import "os"

func truncate(file *os.File, size int64) error {
return nil
}

0 comments on commit 483bc44

Please sign in to comment.