add os.Link

Signed-off-by: leongross <leon.gross@9elements.com>
This commit is contained in:
leongross
2024-03-26 13:21:50 +01:00
committed by Ron Evans
parent 9d6e30701b
commit dcee228c4e
3 changed files with 81 additions and 0 deletions
+15
View File
@@ -134,6 +134,16 @@ func Rename(from, to string) (err error) {
return
}
func Link(oldname, newname string) (err error) {
fromdata := cstring(oldname)
todata := cstring(newname)
fail := int(libc_link(&fromdata[0], &todata[0]))
if fail < 0 {
err = getErrno()
}
return
}
func Symlink(from, to string) (err error) {
fromdata := cstring(from)
todata := cstring(to)
@@ -416,6 +426,11 @@ func libc_rename(from, to *byte) int32
//export symlink
func libc_symlink(from, to *byte) int32
// int link(const char *oldname, *newname);
//
//export link
func libc_link(oldname, newname *byte) int32
// int fsync(int fd);
//
//export fsync