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
+13
View File
@@ -74,6 +74,19 @@ func tempDir() string {
return dir
}
// Link creates newname as a hard link to the oldname file.
// If there is an error, it will be of type *LinkError.
func Link(oldname, newname string) error {
e := ignoringEINTR(func() error {
return syscall.Link(oldname, newname)
})
if e != nil {
return &LinkError{"link", oldname, newname, e}
}
return nil
}
// Symlink creates newname as a symbolic link to oldname.
// On Windows, a symlink to a non-existent oldname creates a file symlink;
// if oldname is later created as a directory the symlink will not work.