static unsafe void Main(string[] args) { Console.WriteLine("Emulate opendir()"); //var buf = new byte[65536]; //var fd = LibC.open(toNullTerm(Encoding.UTF8.GetBytes("/tmp")), LibC.O_DIRECTORY|LibC.O_RDONLY); //Console.WriteLine($"Open fd={fd} errno={LibC.errno}"); //LibC.fcntl(fd, LibC.F_SETFD, LibC.FD_CLOEXEC); //Console.WriteLine($"Fcntl fd={fd} errno={LibC.errno}"); //var dh = Mono.Unix.Native.Syscall.opendir("/tmp"); //while (true) //{ // var rd = Mono.Unix.Native.Syscall.readdir(dh); // if (rd == null) break; // Console.WriteLine($"{rd.d_name}"); //} //fixed (byte* p = buf) //{ // var count = LibC.read(fd, p, 65536); // Console.WriteLine($"Read {(int) count}"); // dumpBytes(buf, (int) count); //} //var dh = RawDirs.opendir(toNullTerm(Encoding.UTF8.GetBytes("/tmp"))); //while (true) //{ // var dir = RawDirs.readdir_wrap(dh); // if (dir == null) break; // var d = dir.Value; // var name = Encoding.UTF8.GetString(d.d_name); // Console.WriteLine($"{name}"); //} //RawDirs.closedir(dh); var mt = new StringTrie <string>(); mt.Add("/a/b/", "ab#"); mt.Add("/a/c/", "ac#"); mt.Add("/b/b/", "bb#"); var a = mt.FindPredecessor("/a/b/c"); Console.WriteLine($"/a/b/c {a.Value}"); //a = mt.FindPredecessor("/a/b"); //Console.WriteLine($"/a/b {a.Value}"); }