/// <include file='Doc/Wrappers.xml' path='docs/method[@name="Listing"]/*'/>
        public override string[] Listing(string path, StreamListingOptions options, StreamContext context)
        {
            Debug.Assert(path != null);
            Debug.Assert(Path.IsPathRooted(path));

            try
            {
                string[] listing = Directory.GetFileSystemEntries(path);
                bool     root    = Path.GetPathRoot(path) == path;
                int      index   = root ? 0 : 2;
                string[] rv      = new string[listing.Length + index];

                // Remove the absolute path information (PHP returns only filenames)
                int pathLength = path.Length;
                if (path[pathLength - 1] != Path.DirectorySeparatorChar)
                {
                    pathLength++;
                }

                // Check for the '.' and '..'; they should be present
                if (!root)
                {
                    rv[0] = ".";
                    rv[1] = "..";
                }
                for (int i = 0; i < listing.Length; i++)
                {
                    rv[index++] = listing[i].Substring(pathLength);
                }
                return(rv);
            }
            catch (DirectoryNotFoundException)
            {
                PhpException.Throw(PhpError.Warning, CoreResources.GetString("stream_bad_directory",
                                                                             FileSystemUtils.StripPassword(path)));
            }
            catch (UnauthorizedAccessException)
            {
                PhpException.Throw(PhpError.Warning, CoreResources.GetString("stream_file_access_denied",
                                                                             FileSystemUtils.StripPassword(path)));
            }
            catch (Exception e)
            {
                PhpException.Throw(PhpError.Warning, CoreResources.GetString("stream_error",
                                                                             FileSystemUtils.StripPassword(path), e.Message));
            }
            return(null);
        }
Beispiel #2
0
 public virtual string[] Listing(string path, StreamListingOptions options, StreamContext context)
 {
     // php_stream *(*dir_opener)(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
     PhpException.Throw(PhpError.Warning, ErrResources.wrapper_op_unsupported, "Opendir");
     return(null);
 }
Beispiel #3
0
        public override string[] Listing(string path, StreamListingOptions options, StreamContext context)
        {
            Debug.Assert(path != null);
            Debug.Assert(Path.IsPathRooted(path));

            try
            {
                string[] listing = Directory.GetFileSystemEntries(path);
                bool root = Path.GetPathRoot(path) == path;
                int index = root ? 0 : 2;
                string[] rv = new string[listing.Length + index];

                // Remove the absolute path information (PHP returns only filenames)
                int pathLength = path.Length;
                if (path[pathLength - 1] != Path.DirectorySeparatorChar) pathLength++;

                // Check for the '.' and '..'; they should be present
                if (!root)
                {
                    rv[0] = ".";
                    rv[1] = "..";
                }
                for (int i = 0; i < listing.Length; i++)
                {
                    rv[index++] = listing[i].Substring(pathLength);
                }
                return rv;
            }
            catch (DirectoryNotFoundException)
            {
                PhpException.Throw(PhpError.Warning, ErrResources.stream_bad_directory, FileSystemUtils.StripPassword(path));
            }
            catch (UnauthorizedAccessException)
            {
                PhpException.Throw(PhpError.Warning, ErrResources.stream_file_access_denied, FileSystemUtils.StripPassword(path));
            }
            catch (System.Exception e)
            {
                PhpException.Throw(PhpError.Warning, ErrResources.stream_error, FileSystemUtils.StripPassword(path), e.Message);
            }
            return null;
        }
Beispiel #4
0
 /// <include file='Doc/Wrappers.xml' path='docs/method[@name="Listing"]/*'/>
 public override string[] Listing(string path, StreamListingOptions options, StreamContext context)
 {
     return(proxy.Listing(path, (int)options, null));
 }
Beispiel #5
0
 public virtual string[] Listing(string path, StreamListingOptions options, StreamContext context)
 {
     // php_stream *(*dir_opener)(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
     PhpException.Throw(PhpError.Warning, ErrResources.wrapper_op_unsupported, "Opendir");
     return null;
 }