public override int ReadDir(ReadOnlySpan <byte> path, ulong offset, ReadDirFlags flags, DirectoryContent content, ref FuseFileInfo fi)
        {
            int error = 0, level = 0;
            var procs = ProcPath(path, ref error, ref level, isADir: true);

            if (error != 0)
            {
                return(-LibC.ENOENT);
            }

            //var sb = new StringBuilder();
            //foreach (var v in procs)
            //{
            //    sb.Append(v.Item2.Name.GetString());
            //    sb.Append("{");
            //    sb.Append(v.Item2._id.ToString());
            //    sb.Append("}/");
            //}


            var last = procs.Pop();


            if (last.Item2 == null)
            {
                return(-last.Item3);                     // No such file
            }
            // Just return everything - someday we need to break into batches

            content.AddEntry(".");
            content.AddEntry("..");

            if (verbosity > 5)
            {
                Console.WriteLine($"ReadDir Path={path.GetString()} offset={offset} flags={flags} ParentId={last.Item2._id}");
            }

            // This could conceivably return millions of records - Once we figure out how to set up batches
            // we can use OpenDir to create a file handle which we can bind an enumerator to (RelaseDir can close it).


            //Console.WriteLine($"Full: {sb}");
            //Console.WriteLine($"Item: Path={path.GetString()} {last.Item2.Name.GetString()} Parent: {last.Item2._id}");


            // ParentId should be indexed (with a hash)
            var filter = Builders <NeoAssets.Mongo.NeoVirtFS> .Filter.Eq(x => x.ParentId, last.Item2._id);

            foreach (var rec in NeoVirtFSCol.FindSync(filter).ToList())
            {
                //Console.WriteLine($"  Contents: {rec._id} - {rec.Name.GetString()}");
                content.AddEntry(rec.Name);

                // For now, also populate the cache with this

                NodeCacheSet(rec, 5);
            }

            return(0);
        }
        public override int ReadDir(ReadOnlySpan <byte> path, ulong offset, ReadDirFlags flags, DirectoryContent content, ref FuseFileInfo fi, Guid fileGuid)
        {
            if (debug)
            {
                Console.WriteLine($"TopLevel::ReadDir({RawDirs.HR(path)},{offset},{flags})");
            }

            try
            {
                content.AddEntry(".");
                content.AddEntry("..");

                foreach (var v in Mountpoints)
                {
                    content.AddEntry(v.Key.AsSpan());
                }

                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"TopLevel::ReadDir() - error {ex.Message}");
                return(-LibC.EACCES);
            }
        }
 public override int ReadDir(ReadOnlySpan <byte> path, ulong offset, ReadDirFlags flags, DirectoryContent content, ref FuseFileInfo fi)
 {
     if (!path.SequenceEqual(RootPath))
     {
         return(-ENOENT);
     }
     content.AddEntry(".");
     content.AddEntry("..");
     content.AddEntry("hello");
     return(0);
 }
        public override int ReadDir(ReadOnlySpan <byte> path, ulong offset, ReadDirFlags flags, DirectoryContent content, ref FuseFileInfo fi)
        {
            Console.WriteLine("ReadDir -> " + Encoding.UTF8.GetString(path));
            string convPath = Encoding.UTF8.GetString(path);

            try
            {
                FileSystemPath fsPath;
                bool           exists = false;
                ICollection <VirtualFileSystemInfo> ents;
                if (convPath == "/")
                {
                    fsPath = FileSystemPath.Parse("/");
                    exists = true;
                    content.AddEntry("stats");
                }
                else
                {
                    fsPath = FileSystemPath.Parse(convPath + "/");
                    exists = fs.Exists(FileSystemPath.Parse(Encoding.UTF8.GetString(path)));
                }

                ents = fs.GetExtendedEntities(fsPath);

                if (ents.Count == 0 && !exists)
                {
                    Console.WriteLine("no files!!!");
                    return(-ENOENT);
                }

                content.AddEntry(".");
                content.AddEntry("..");
                foreach (var e in ents)
                {
                    content.AddEntry(e.Name);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(0);
        }
        public override int ReadDir(ReadOnlySpan <byte> path, ulong offset, ReadDirFlags flags, DirectoryContent content, ref FuseFileInfo fi, Guid fileGuid)
        {
            if (debug)
            {
                Console.WriteLine($"NeoFS::ReadDir({RawDirs.HR(path)},{offset},{flags})");
            }
            path = base.TransformPath(path);

            // We only have the low level calls, so we need to do opendir/readdir ourself

            var dirFd = RawDirs.opendir(RawDirs.ToNullTerm(path.ToArray()));

            if (dirFd == IntPtr.Zero)
            {
                return(0);
            }

            content.AddEntry(".");  // This can eat strings
            content.AddEntry("..");

            while (true)
            {
                var dir = RawDirs.readdir_wrap(dirFd, false);  // Don't remove the null
                if (dir == null)
                {
                    break;
                }

                var d = dir.Value;

                if (debug)
                {
                    Console.WriteLine($"{RawDirs.HR(path)} -> {RawDirs.HR(d.d_name)}");
                }

                content.AddEntry(d.d_name.AsSpan());
            }

            RawDirs.closedir(dirFd);

            return(0);
        }
 public override int ReadDir(ReadOnlySpan <byte> path, ulong offset, ReadDirFlags flags, DirectoryContent content, ref FuseFileInfo fi)
 {
     return(base.ReadDir(path, offset, flags, content, ref fi));
 }
 protected virtual int ReadDir(string path, ulong offset, ReadDirFlags flags, DirectoryContent content, ref FuseFileInfo fi)
 => - ENOSYS;
 public override int ReadDir(ReadOnlySpan <byte> path, ulong offset, ReadDirFlags flags, DirectoryContent content, ref FuseFileInfo fi)
 => ReadDir(ToString(path), offset, flags, content, ref fi);
 public virtual int ReadDir(ReadOnlySpan <byte> path, ulong offset, ReadDirFlags flags, DirectoryContent content, ref FuseFileInfo fi)
 => - ENOSYS;