- value
- no.Unix.Native.FilePermissions to convert.
A Unix permission string.
A "Unix permission string" is the 9 or 10 character string commonly seen in the output of ls -l, e.g. "-rwxr-x---".
Both 9 and 10 character representations are encoded, the difference being the file type. If a file type is specified, a 10 character string is returned, with the file type encoded in the first character. Otherwise a 9 character string is returned.
C# Example
using System;
using Mono.Unix.Native;
class Test
{
public static void Main(string[] args)
{
foreach (string file in args) {
Stat stat;
if (Syscall.stat (file, out stat) == 0) {
Console.WriteLine (" File: `{0}'", file);
Console.WriteLine ("Access: ({0}/{1})",
NativeConvert.ToOctalPermissionString (stat.st_mode),
NativeConvert.ToUnixPermissionString (stat.st_mode))
}
else {
Console.WriteLine ("Cannot stat `{0}': {1}", file,
Stdlib.strerror (Stdlib.GetLastError ()));
}
}
}
}