mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 04:23:41 +00:00
os: pull in os.Rename and some of its tests from upstream
Skip part of the test on Windows because of https://github.com/tinygo-org/tinygo/issues/2480 TODO: fix 2480 and unskip test TODO: pull in rest of upstream tests, fix problems they find Requested in https://github.com/tinygo-org/tinygo/issues/2109
This commit is contained in:
@@ -95,6 +95,16 @@ func Rmdir(path string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Rename(from, to string) (err error) {
|
||||
fromdata := cstring(from)
|
||||
todata := cstring(to)
|
||||
fail := int(libc_rename(&fromdata[0], &todata[0]))
|
||||
if fail < 0 {
|
||||
err = getErrno()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Unlink(path string) (err error) {
|
||||
data := cstring(path)
|
||||
fail := int(libc_unlink(&data[0]))
|
||||
@@ -270,6 +280,10 @@ func libc_mkdir(pathname *byte, mode uint32) int32
|
||||
//export rmdir
|
||||
func libc_rmdir(pathname *byte) int32
|
||||
|
||||
// int rename(const char *from, *to);
|
||||
//export rename
|
||||
func libc_rename(from, too *byte) int32
|
||||
|
||||
// int unlink(const char *pathname);
|
||||
//export unlink
|
||||
func libc_unlink(pathname *byte) int32
|
||||
|
||||
Reference in New Issue
Block a user