mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 20:43:40 +00:00
os: add file.Truncate
This commit is contained in:
@@ -432,7 +432,6 @@ func chmod(pathname *byte, mode uint32) int32 {
|
||||
//
|
||||
//export mkdir
|
||||
func mkdir(pathname *byte, mode uint32) int32 {
|
||||
|
||||
path := goString(pathname)
|
||||
dir, relPath := findPreopenForPath(path)
|
||||
if dir.d == cm.ResourceNone {
|
||||
@@ -773,7 +772,6 @@ var libcCWD wasiDir
|
||||
var wasiPreopens map[string]types.Descriptor
|
||||
|
||||
func populatePreopens() {
|
||||
|
||||
var cwd string
|
||||
|
||||
// find CWD
|
||||
@@ -1354,3 +1352,11 @@ func getcwd(buf *byte, size uint) *byte {
|
||||
copy(s, cwd)
|
||||
return buf
|
||||
}
|
||||
|
||||
// int truncate(const char *path, off_t length);
|
||||
//
|
||||
//export truncate
|
||||
func truncate(path *byte, length int64) int32 {
|
||||
libcErrno = ENOSYS
|
||||
return -1
|
||||
}
|
||||
|
||||
@@ -203,6 +203,15 @@ func Execve(pathname string, argv []string, envv []string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Truncate(path string, length int64) (err error) {
|
||||
data := cstring(path)
|
||||
fail := int(libc_truncate(&data[0], length))
|
||||
if fail < 0 {
|
||||
err = getErrno()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||
|
||||
func Kill(pid int, sig Signal) (err error) {
|
||||
@@ -451,3 +460,8 @@ func libc_fork() int32
|
||||
//
|
||||
//export execve
|
||||
func libc_execve(filename *byte, argv **byte, envp **byte) int
|
||||
|
||||
// int truncate(const char *path, off_t length);
|
||||
//
|
||||
//export truncate
|
||||
func libc_truncate(path *byte, length int64) int32
|
||||
|
||||
Reference in New Issue
Block a user