public static PhpResource opendir(Context ctx, string directory)
        {
            var dirctx = PhpDirectoryContext.GetContext(ctx);

            if (PhpStream.ResolvePath(ctx, ref directory, out var wrapper, CheckAccessMode.Directory, CheckAccessOptions.Empty))
            {
                var listing = wrapper.Listing(ctx.RootPath, directory, StreamListingOptions.Empty, null);
                if (listing != null)
                {
                    return(dirctx.LastDirHandle = new DirectoryListing(dirctx, listing));
                }
            }

            //
            dirctx.LastDirHandle = null;
            return(null);
        }
        public static PhpResource opendir(Context ctx, string directory)
        {
            var dirctx = PhpDirectoryContext.GetContext(ctx);

            StreamWrapper wrapper;

            if (PhpStream.ResolvePath(ctx, ref directory, out wrapper, CheckAccessMode.Directory, CheckAccessOptions.Empty))
            {
                string[] listing = wrapper.Listing(directory, 0, null);
                if (listing != null)
                {
                    var res = dirctx.LastDirHandle = new DirectoryListing(ctx, listing);
                    return(res);
                }
            }

            //
            dirctx.LastDirHandle = null;
            return(null);
        }
 /// <summary>
 /// Closes a directory handle. Uses last handle opened by <c>opendir</c>.
 /// </summary>
 public static void closedir(Context ctx)
 {
     closedir(PhpDirectoryContext.GetContext(ctx).LastDirHandle);
 }
 /// <summary>
 /// Rewinds a directory handle. Uses last handle opened by <c>opendir</c>.
 /// </summary>
 public static void rewinddir(Context ctx)
 {
     rewinddir(PhpDirectoryContext.GetContext(ctx).LastDirHandle);
 }
 public static string readdir(Context ctx)
 {
     return(readdir(PhpDirectoryContext.GetContext(ctx).LastDirHandle));
 }