23 using Mono.Unix.Native;
25 namespace Ntp.Common.IO
32 if (Environment.OSVersion.Platform != PlatformID.Unix)
35 var permissions = NativeConvert.FromOctalPermissionString(mode.ToString());
36 return Syscall.chmod(file, permissions) == 0;
42 if (Environment.OSVersion.Platform != PlatformID.Unix)
45 return Syscall.chown(file, user, group ?? unchecked((uint) -1)) == 0;
51 if (Environment.OSVersion.Platform != PlatformID.Unix)
54 var gr = Syscall.getgrnam(groupName);
61 if (Environment.OSVersion.Platform != PlatformID.Unix)
64 var pw = Syscall.getpwnam(userName);
71 if (Environment.OSVersion.Platform != PlatformID.Unix)
76 Syscall.setuid(userId);
static uint GetGroupId(string groupName)
static bool ChangeFileMode(string file, uint mode)
static uint GetUserId(string userName)
static bool SetUserId(uint userId)
static bool ChangeFileOwner(string file, uint user, uint?group)