mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 03:27:48 +00:00
feat: Implement Lchown function for changing file ownership (#5161)
* feat: Implement Lchown function for changing file ownership - Added Lchown function to change the numeric uid and gid of a file or symbolic link. - Included error handling to return *PathError for failed operations. - Added unit tests for Lchown to verify behavior on different error scenarios. * fix: fix chmod tests
This commit is contained in:
@@ -172,6 +172,15 @@ func Chown(path string, uid, gid int) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Lchown(path string, uid, gid int) (err error) {
|
||||
data := cstring(path)
|
||||
fail := int(libc_lchown(&data[0], uid, gid))
|
||||
if fail < 0 {
|
||||
err = getErrno()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Fork() (err error) {
|
||||
fail := int(libc_fork())
|
||||
if fail < 0 {
|
||||
@@ -368,6 +377,11 @@ func libc_chmod(pathname *byte, mode uint32) int32
|
||||
//export chown
|
||||
func libc_chown(pathname *byte, owner, group int) int32
|
||||
|
||||
// int lchown(const char *pathname, uid_t owner, gid_t group);
|
||||
//
|
||||
//export lchown
|
||||
func libc_lchown(pathname *byte, owner, group int) int32
|
||||
|
||||
// int mkdir(const char *pathname, mode_t mode);
|
||||
//
|
||||
//export mkdir
|
||||
|
||||
Reference in New Issue
Block a user