Пример #1
0
        public override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            var r = AzureFilePathResolver.ResolvePath(this.Client, path);

            switch (r.PathType)
            {
            case PathType.AzureFileRoot:
                var shares = this.ListItems(path);
                foreach (CloudFileShare s in shares)
                {
                    this.RootProvider.WriteItemObject(s.Name, path, true);
                }
                break;

            case PathType.AzureFileDirectory:
                var items      = r.Directory.ListFilesAndDirectories();
                var parentPath = PathResolver.Combine(r.Parts);
                this.HandleItems(items,
                                 (f) => this.RootProvider.WriteItemObject(f.Name, PathResolver.Root, false),
                                 (d) => this.RootProvider.WriteItemObject(d.Name, PathResolver.Root, true),
                                 (s) => { }
                                 );
                break;

            case PathType.AzureFile:
            default:
                break;
            }
        }
Пример #2
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     using (NewSession())
     {
         base.GetChildNames(path, returnContainers);
     }
 }
Пример #3
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     foreach (var entry in GetProperties(path))
     {
         WriteItemObject(entry.Name, entry.Name, false);
     }
 }
Пример #4
0
 protected virtual void GetChildNames(string path, ReturnContainers returnContainers)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "CmdletProvider_NotSupported", new object[0]);
     }
 }
Пример #5
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            WriteVerbose($"SPOProvider::GetChildNames (Path = ’{path}’)");

            var folder = GetFileOrFolder(path) as Folder;

            if (folder != null)
            {
                var folderAndFiles      = GetFolderItems(folder).ToArray();
                var serverRelaitivePath = GetServerRelativePath(path);
                foreach (var subFolder in folderAndFiles.OfType <Folder>().ToList())
                {
                    string name;
                    if (string.IsNullOrEmpty(subFolder.Name))
                    {
                        var serverRelativeUrl = IsPropertyAvailable(subFolder, "ServerRelativeUrl") ? subFolder.ServerRelativeUrl : subFolder.EnsureProperty(s => s.ServerRelativeUrl);
                        name = serverRelativeUrl.Split(PathSeparator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Last();
                    }
                    else
                    {
                        name = subFolder.Name;
                    }
                    WriteItemObject(name, serverRelaitivePath, true);
                }
                foreach (var file in folderAndFiles.OfType <File>().ToList())
                {
                    WriteItemObject(file.Name, serverRelaitivePath, false);
                }
            }
            else
            {
                WriteErrorInternal("No folder at end of path", path, ErrorCategory.InvalidOperation);
            }
        }
Пример #6
0
        internal void GetNames(string[] path, ReturnContainers returnContainers, bool recurse, ProviderRuntime runtime)
        {
            // the include/exclude filters apply to the results, not to the globbing process. Make this sure
            runtime.IgnoreFiltersForGlobbing = true;
            // compile here, not in every recursive iteration
            var filter = new IncludeExcludeFilter(runtime.Include, runtime.Exclude, false);

            // do the globbing manually, because the behavior depends on it...
            foreach (var p in path)
            {
                CmdletProvider provider;
                var            doGlob = Globber.ShouldGlob(p, runtime);
                // even if we don't actually glob, the next method will return the resolved path & provider
                var resolved     = Globber.GetGlobbedProviderPaths(p, runtime, out provider);
                var contProvider = CmdletProvider.As <ContainerCmdletProvider>(provider);
                foreach (var curPath in resolved)
                {
                    if (!doGlob && filter.CanBeIgnored && !recurse)
                    {
                        contProvider.GetChildNames(curPath, returnContainers, runtime);
                        continue;
                    }
                    if ((recurse || !doGlob) && Item.IsContainer(contProvider, curPath, runtime))
                    {
                        ManuallyGetChildNames(contProvider, curPath, "", returnContainers, recurse, filter, runtime);
                        continue;
                    }
                    var cn = Path.ParseChildName(contProvider, curPath, runtime);
                    if (filter.Accepts(cn))
                    {
                        runtime.WriteObject(cn);
                    }
                }
            }
        }
Пример #7
0
 protected virtual void GetChildNames(string path, ReturnContainers returnContainers)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         throw PSTraceSource.NewNotSupportedException("SessionStateStrings", "CmdletProvider_NotSupported", new object[0]);
     }
 }
Пример #8
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     foreach (var f in Directory.GetFiles(path))
     {
         base.WriteItemObject(Path.GetFileName(f), f, false);
     }
 }
Пример #9
0
        public override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            var r = AzureBlobPathResolver.ResolvePath(this.Client, path);

            switch (r.PathType)
            {
            case PathType.AzureBlobRoot:
                var shares = this.ListItems(path);
                foreach (CloudBlobContainer s in shares)
                {
                    this.RootProvider.WriteItemObject(s.Name, path, true);
                }
                break;

            case PathType.AzureBlobDirectory:
                ListAndHandle(r.Directory,
                              blobAction: b => this.RootProvider.WriteItemObject(b.Name, b.Parent.Uri.ToString(), false),
                              dirAction: d => this.RootProvider.WriteItemObject(d.Prefix, d.Parent.Uri.ToString(), false)
                              );
                break;

            case PathType.AzureBlobBlock:
            default:
                break;
            }
        }
Пример #10
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     Messages.Add("GetChildNames " + path + " " + returnContainers);
     foreach (var c in ChildNames(path))
     {
         WriteItemObject(c, path + _pathSeparator + c, !c.Contains("."));
     }
 }
Пример #11
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     using (SessionStateProviderBase.tracer.TraceMethod(path, new object[0]))
     {
         CommandOrigin origin = this.Context.Origin;
         if (string.IsNullOrEmpty(path))
         {
             IDictionary sessionStateTable;
             try
             {
                 sessionStateTable = this.GetSessionStateTable();
             }
             catch (SecurityException ex)
             {
                 this.WriteError(new ErrorRecord((Exception)ex, "GetChildNamesSecurityException", ErrorCategory.ReadError, (object)path));
                 return;
             }
             foreach (DictionaryEntry dictionaryEntry in sessionStateTable)
             {
                 try
                 {
                     if (SessionState.IsVisible(origin, dictionaryEntry.Value))
                     {
                         this.WriteItemObject(dictionaryEntry.Key, (string)dictionaryEntry.Key, false);
                     }
                 }
                 catch (PSArgumentException ex)
                 {
                     this.WriteError(new ErrorRecord(ex.ErrorRecord, (Exception)ex));
                     break;
                 }
                 catch (SecurityException ex)
                 {
                     this.WriteError(new ErrorRecord((Exception)ex, "GetItemSecurityException", ErrorCategory.PermissionDenied, (object)(string)dictionaryEntry.Key));
                     break;
                 }
             }
         }
         else
         {
             object sessionStateItem;
             try
             {
                 sessionStateItem = this.GetSessionStateItem(path);
             }
             catch (SecurityException ex)
             {
                 this.WriteError(new ErrorRecord((Exception)ex, "GetChildNamesSecurityException", ErrorCategory.ReadError, (object)path));
                 return;
             }
             if (sessionStateItem == null || !SessionState.IsVisible(origin, sessionStateItem))
             {
                 return;
             }
             this.WriteItemObject((object)path, path, false);
         }
     }
 }
Пример #12
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            try
            {
                LogInfo("Executing GetChildNames(string path='{0}', string returnContainers='{1}')", path,
                        returnContainers);
                path = path.Replace("\\", "/");
                if (path.Contains("../"))
                {
                    path = path.Substring(path.LastIndexOf("../", StringComparison.Ordinal) + 2);
                }

                // apply filter
                WildcardPattern wildcard = null;

                if (!string.IsNullOrEmpty(Filter))
                {
                    wildcard = new WildcardPattern(Filter, WildcardOptions.IgnoreCase | WildcardOptions.Compiled);
                }

                var pageRef = GetItemForPath(path);
                if (pageRef != null)
                {
                    var children = pageRef.GetChildren();
                    foreach (Item child in children)
                    {
                        if (returnContainers == ReturnContainers.ReturnAllContainers || wildcard == null ||
                            wildcard.IsMatch(child.Name))
                        {
                            WriteItemObject(child.Name, child.GetProviderPath(), child.HasChildren);
                        }
                        if (Stopping)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    WriteInvalidPathError(path);
                }
            }
            catch (PipelineStoppedException)
            {
                // pipeline stopped e.g. if we did:
                // Get-ChildItem master:\ | Select-Object -First 1
                // we can relax now - no more items needed
                throw;
            }
            catch (Exception ex)
            {
                LogError(ex,
                         "Error while executing GetChildNames(string path='{0}', string returnContainers='{1}')",
                         path, returnContainers);
                throw;
            }
        }
Пример #13
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            RegistryKey key = FindItemByPath(path);

            foreach (var subKeyName in key.GetSubKeyNames())
            {
                WriteItemObject(subKeyName, MakePath(path, subKeyName), true);
            }
        }
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            void writeItemObject(PSObject _, string path, string name, bool isContainer) => this.WriteItemObject(name, path, isContainer);

            this.InvokeContainerNodeOrDefault(
                path: new PathTool().SplitProviderPath(path).path.items,
                invoke: c => this.GetChildItems(parentContainer: c, path, recurse: false, depth: 0, writeItemObject),
                fallback: () => base.GetChildNames(path, returnContainers));
        }
 public Collection<string> GetNames(string[] path, ReturnContainers returnContainers, bool recurse, bool force,
                                    bool literalPath)
 {
     var runtime = new ProviderRuntime(SessionState, force, literalPath);
     GetNames(path, returnContainers, recurse, runtime);
     var packedResults = runtime.ThrowFirstErrorOrReturnResults();
     var results = (from r in packedResults select r.ToString()).ToList();
     return new Collection<string>(results);
 }
Пример #16
0
        /// <summary>
        /// Internal wrapper for the GetChildNames protected method. It is called instead
        /// of the protected method that is overridden by derived classes so that the
        /// context of the command can be set.
        /// </summary>
        /// <param name="path">
        /// The path to the item from which to retrieve the child names.
        /// </param>
        /// <param name="returnContainers">
        /// Determines if all containers should be returned or only those containers that match the
        /// filter(s).
        /// </param>
        /// <param name="context">
        /// The context under which this method is being called.
        /// </param>
        /// <returns>
        /// Nothing is returned, but all names should be written to the Write*Object or
        /// Write*Objects method.
        /// </returns>
        /// <remarks>
        /// The child names are the leaf portion of the path. Example, for the file system
        /// the name for the path c:\windows\system32\foo.dll would be foo.dll or for
        /// the directory c:\windows\system32 would be system32. For Active Directory the
        /// child names would be RDN values of the child objects of the container.
        /// </remarks>
        internal void GetChildNames(
            string path,
            ReturnContainers returnContainers,
            CmdletProviderContext context)
        {
            Context = context;

            // Call virtual method
            GetChildNames(path, returnContainers);
        }
Пример #17
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            using (PscxProviderContext <AssemblyCacheProvider> .Enter(this))
            {
                WriteDebug(String.Format("GetChildNames: {0} ; returnContainers: {1}", path, returnContainers));
                path = NormalizePath(path);

                WritePathItems(path, true);
            }
        }
Пример #18
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            CommandOrigin origin = base.Context.Origin;

            if (string.IsNullOrEmpty(path))
            {
                IDictionary sessionStateTable = null;
                try
                {
                    sessionStateTable = this.GetSessionStateTable();
                }
                catch (SecurityException exception)
                {
                    base.WriteError(new ErrorRecord(exception, "GetChildNamesSecurityException", ErrorCategory.ReadError, path));
                    return;
                }
                foreach (DictionaryEntry entry in sessionStateTable)
                {
                    try
                    {
                        if (SessionState.IsVisible(origin, entry.Value))
                        {
                            base.WriteItemObject(entry.Key, (string)entry.Key, false);
                        }
                    }
                    catch (PSArgumentException exception2)
                    {
                        base.WriteError(new ErrorRecord(exception2.ErrorRecord, exception2));
                        break;
                    }
                    catch (SecurityException exception3)
                    {
                        base.WriteError(new ErrorRecord(exception3, "GetItemSecurityException", ErrorCategory.PermissionDenied, (string)entry.Key));
                        break;
                    }
                }
            }
            else
            {
                object valueToCheck = null;
                try
                {
                    valueToCheck = this.GetSessionStateItem(path);
                }
                catch (SecurityException exception4)
                {
                    base.WriteError(new ErrorRecord(exception4, "GetChildNamesSecurityException", ErrorCategory.ReadError, path));
                    return;
                }
                if ((valueToCheck != null) && SessionState.IsVisible(origin, valueToCheck))
                {
                    base.WriteItemObject(path, path, false);
                }
            }
        }
Пример #19
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            WriteVerbose($"SPOProvider::GetChildNames (Path = ’{path}’)");

            var folder = GetFileOrFolder(path) as Folder;

            if (folder != null)
            {
                //Get current spo-drive
                var spoDrive = GetCurrentDrive(path);
                if (spoDrive == null)
                {
                    return;
                }

                //Save original timeout
                var originalItemTimeout = spoDrive.ItemTimeout;

                //Set timeout temporary to 5 minutes
                spoDrive.ItemTimeout = 1000 * 60 * 5;

                //Get data
                var spoParameters      = DynamicParameters as SPOChildItemsParameters;
                var folderAndFiles     = spoParameters != null && spoParameters.Limit != SPOChildItemsParameters.Limits.Default ? GetFolderItems(folder, false, (int)spoParameters.Limit).ToArray() : GetFolderItems(folder).ToArray();
                var serverRelativePath = GetServerRelativePath(path);

                foreach (var subFolder in folderAndFiles.OfType <Folder>().ToList())
                {
                    string name;
                    if (string.IsNullOrEmpty(subFolder.Name))
                    {
                        var serverRelativeUrl = subFolder.EnsureProperty(s => s.ServerRelativeUrl);
                        name = serverRelativeUrl.Split(PathSeparator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Last();
                    }
                    else
                    {
                        name = subFolder.Name;
                    }
                    WriteItemObject(name, serverRelativePath, true);
                }

                foreach (var file in folderAndFiles.OfType <File>().ToList())
                {
                    WriteItemObject(file.Name, serverRelativePath, false);
                }

                //Restore item cache timeout
                spoDrive.ItemTimeout = originalItemTimeout;
            }
            else
            {
                WriteErrorInternal("No folder at end of path", path, ErrorCategory.InvalidOperation);
            }
        }
Пример #20
0
        public Collection <string> GetNames(string[] path, ReturnContainers returnContainers, bool recurse, bool force,
                                            bool literalPath)
        {
            var runtime = new ProviderRuntime(SessionState, force, literalPath);

            GetNames(path, returnContainers, recurse, runtime);
            var packedResults = runtime.ThrowFirstErrorOrReturnResults();
            var results       = (from r in packedResults select r.ToString()).ToList();

            return(new Collection <string>(results));
        }
Пример #21
0
 internal void GetChildNames(
     string path,
     ReturnContainers returnContainers,
     CmdletProviderContext context)
 {
     using (CmdletProvider.providerBaseTracer.TraceMethod(path, new object[0]))
     {
         this.Context = context;
         this.GetChildNames(path, returnContainers);
     }
 }
Пример #22
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            var nodeFactory = GetNodeFactoryFromPath(path, false);

            if (null == nodeFactory)
            {
                return;
            }

            nodeFactory.ToList().ForEach(f => GetChildNames(path, f, returnContainers));
        }
Пример #23
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     if (TransactionAvailable())
     {
         using (CurrentPSTransaction)
         {
             base.GetChildNames(path, returnContainers);
             return;
         }
     }
     base.GetChildNames(path, returnContainers);
 }
Пример #24
0
 void GetChildNames(string path, INodeFactory nodeFactory, ReturnContainers returnContainers)
 {
     nodeFactory.GetNodeChildren(CreateContext(path)).ToList().ForEach(
         f =>
     {
         var i = f.GetNodeValue();
         if (null == i)
         {
             return;
         }
         WriteItemObject(i.Name, path + "\\" + i.Name, i.IsCollection);
     });
 }
Пример #25
0
        /// <summary>
        /// Gets the child names of the container at the given path.
        /// </summary>
        /// <param name="path">
        /// The path to the item to retrieve. It may be a drive or provider-qualified path and may include
        /// glob characters.
        /// </param>
        /// <param name="returnContainers">
        /// Determines if all containers should be returned or only those containers that match the
        /// filter(s).
        /// </param>
        /// <param name="recurse">
        /// If true, gets all the relative paths of all the children
        /// in all the sub-containers of the specified
        /// container. If false, only gets the immediate child names of the specified
        /// container.
        /// </param>
        /// <returns>
        /// The children of the container at the specified path. The type of the objects returned are
        /// determined by the provider that supports the given path.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="path"/> or <paramref name="propertyToClear"/> is null.
        /// </exception>
        /// <exception cref="ProviderNotFoundException">
        /// If the <paramref name="path"/> refers to a provider that could not be found.
        /// </exception>
        /// <exception cref="DriveNotFoundException">
        /// If the <paramref name="path"/> refers to a drive that could not be found.
        /// </exception>
        /// <exception cref="ItemNotFoundException">
        /// If <paramref name="path"/> does not contain glob characters and
        /// could not be found.
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// If the provider that the <paramref name="path"/> refers to does
        /// not support this operation.
        /// </exception>
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        public Collection <string> GetNames(
            string path,
            ReturnContainers returnContainers,
            bool recurse)
        {
            Dbg.Diagnostics.Assert(
                _sessionState != null,
                "The only constructor for this class should always set the sessionState field");

            // Parameter validation is done in the session state object

            return(_sessionState.GetChildNames(new string[] { path }, returnContainers, recurse, uint.MaxValue, false, false));
        }
Пример #26
0
        /// <summary>
        /// Gets the child names of the container at the given path.
        /// </summary>
        /// <param name="path">
        /// The path(s) to the item(s) to retrieve. They may be drive or provider-qualified paths and may include
        /// glob characters.
        /// </param>
        /// <param name="returnContainers">
        /// Determines if all containers should be returned or only those containers that match the
        /// filter(s).
        /// </param>
        /// <param name="recurse">
        /// If true, gets all the relative paths of all the children
        /// in all the sub-containers of the specified
        /// container. If false, only gets the immediate child names of the specified
        /// container.
        /// </param>
        /// <param name="force">
        /// Passed on to providers to force operations.
        /// </param>
        /// <param name="literalPath">
        /// If true, globbing is not done on paths.
        /// </param>
        /// <returns>
        /// The children of the container at the specified path. The type of the objects returned are
        /// determined by the provider that supports the given path.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="path"/> or <paramref name="propertyToClear"/> is null.
        /// </exception>
        /// <exception cref="ProviderNotFoundException">
        /// If the <paramref name="path"/> refers to a provider that could not be found.
        /// </exception>
        /// <exception cref="DriveNotFoundException">
        /// If the <paramref name="path"/> refers to a drive that could not be found.
        /// </exception>
        /// <exception cref="ItemNotFoundException">
        /// If <paramref name="path"/> does not contain glob characters and
        /// could not be found.
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// If the provider that the <paramref name="path"/> refers to does
        /// not support this operation.
        /// </exception>
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        public Collection <string> GetNames(
            string[] path,
            ReturnContainers returnContainers,
            bool recurse,
            bool force,
            bool literalPath)
        {
            Dbg.Diagnostics.Assert(
                _sessionState != null,
                "The only constructor for this class should always set the sessionState field");

            return(_sessionState.GetChildNames(path, returnContainers, recurse, uint.MaxValue, force, literalPath));
        }
Пример #27
0
        private IEnumerable <IDriveItem> GetChildItems(IDriveItem item, ReturnContainers returnContainers = ReturnContainers.ReturnMatchingContainers)
        {
            IEnumerable <IDriveItem> childItems = ((IContainer)item).GetChildItems(DynamicParameters);
            bool useFilter = !string.IsNullOrEmpty(Filter);

            if (useFilter)
            {
                WildcardPattern pattern             = new WildcardPattern(Filter, WildcardOptions.IgnoreCase);
                bool            returnAllContainers = returnContainers == ReturnContainers.ReturnAllContainers;
                return(childItems.Where(i => (returnAllContainers && i is Container) || pattern.IsMatch(i.Name)));
            }
            return(childItems);
        }
Пример #28
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            Console.WriteLine("GetChildNames() -> getting children for path '{0}'", path);
            var items = PSDriveInfo.Children
                        .Values
                        .Where(i => i.FullName.StartsWith(path, StringComparison.OrdinalIgnoreCase) &&
                               !i.FullName.Equals(path, StringComparison.OrdinalIgnoreCase));

            Console.WriteLine("GetChildNames() -> found {0} child items", items.Count());
            foreach (var item in items)
            {
                WriteItemObject(item, item.FullName, item is AssemblyData || item is NamespaceData);
            }
        }
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            var item = GetTreeItem(path);

            if (item != null)
            {
                foreach (var child in item.Children)
                {
                    var name     = child.NodeName();
                    var nodePath = child.NodePath();
                    WriteItemObject(name, nodePath, true);
                }
            }
        }
Пример #30
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            if (path == String.Empty)
            {
                path = ".";
            }

            var names = GetChildNamesPrivate(path);

            foreach (var name in names)
            {
                ProviderRuntime.WriteObject(name);
            }
        }
Пример #31
0
        /// <summary>
        /// Gets the child names of the container at the given path.
        /// </summary>
        /// <param name="path">
        /// The path to the item to retrieve. It may be a drive or provider-qualified path and may include
        /// glob characters.
        /// </param>
        /// <param name="returnContainers">
        /// Determines if all containers should be returned or only those containers that match the
        /// filter(s).
        /// </param>
        /// <param name="recurse">
        /// If true, gets all the relative paths of all the children
        /// in all the sub-containers of the specified
        /// container. If false, only gets the immediate child names of the specified
        /// container.
        /// </param>
        /// <param name="depth">
        /// Limits the depth of recursion; uint.MaxValue performs full recursion.
        /// </param>
        /// <param name="context">
        /// The context under which the command is running.
        /// </param>
        /// <returns>
        /// Nothing.  The names of the children of the specified container are written to the context.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="path"/> or <paramref name="propertyToClear"/> is null.
        /// </exception>
        /// <exception cref="ProviderNotFoundException">
        /// If the <paramref name="path"/> refers to a provider that could not be found.
        /// </exception>
        /// <exception cref="DriveNotFoundException">
        /// If the <paramref name="path"/> refers to a drive that could not be found.
        /// </exception>
        /// <exception cref="ItemNotFoundException">
        /// If <paramref name="path"/> does not contain glob characters and
        /// could not be found.
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// If the provider that the <paramref name="path"/> refers to does
        /// not support this operation.
        /// </exception>
        /// <exception cref="ProviderInvocationException">
        /// If the provider threw an exception.
        /// </exception>
        internal void GetNames(
            string path,
            ReturnContainers returnContainers,
            bool recurse,
            uint depth,
            CmdletProviderContext context)
        {
            Dbg.Diagnostics.Assert(
                _sessionState != null,
                "The only constructor for this class should always set the sessionState field");

            // Parameter validation is done in the session state object

            _sessionState.GetChildNames(path, returnContainers, recurse, depth, context);
        }
Пример #32
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            // Before calling this GetChildNames(), the PowerShell engine has called ItemExists, IsItemContainer,
            // and HasChildItems. HasChildItem will then call GetNodeChildren() -> GetNodeChildrenInternal().
            // GetNodeChildrenInternal() will call GetChildItems for fetching data.

            if (LastVisisted.NodeObject != null && LastVisisted.Children != null && LastVisisted.Path.EqualsIgnoreCase(path))
            {
                base.GetChildNames(path, LastVisisted.Children);
                return;
            }

            // Go fetching data
            base.GetChildNames(path, returnContainers);
        }
Пример #33
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     path = NormalizePath(path);
     if (path.Length == 0)
     {
         foreach (var key in GetFilteredItems().Keys)
         {
             WriteItemObject(key, key, false);
         }
         return;
     }
     if (ItemExists(path))
     {
         WriteItemObject(path, path, false);
     }
 }
Пример #34
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     if (PathIsDrive(path))
     {
         foreach (var repository in gitConfigManager.GetTrackedRepositories())
         {
             WriteItemObject(repository.Name, path, true);
         }
         return;
     }
     var trackedRepository = gitConfigManager.GetTrackedRepository(path);
     if (trackedRepository != null)
     {
         WriteItemObject("Git repo", path, false);
     }
 }
Пример #35
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            using (new CurrentContextSession(this))
            {
                var children = GetChildNodesOfPath(path);
                if (String.IsNullOrEmpty(path))
                {
                    path = "/";
                }

                foreach (var child in children)
                {
                    WriteItemObject(child.Name, path, child.GetNodeChildren().Any());
                }
            }
        }
Пример #36
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            path = NormalizePath(path);

            // check for a named child
            if (path.Length > 0)
            {
                object item = GetSessionStateItem(path);
                if (item != null)
                {
                    WriteItemObject(path, path, false);
                }
                return;
            }
            // otherwise names of all children
            IDictionary sessionStateTable = GetSessionStateTable();
            foreach (DictionaryEntry entry in sessionStateTable)
            {
                var name = (string)entry.Key;
                WriteItemObject(name, name, false);
            }
        }
 internal void GetNames(string path, ReturnContainers returnContainers, bool recurse, CmdletProviderContext context)
 {
     this.sessionState.GetChildNames(path, returnContainers, recurse, context);
 }
 public Collection<string> GetNames(string[] path, ReturnContainers returnContainers, bool recurse, bool force, bool literalPath)
 {
     return this.sessionState.GetChildNames(path, returnContainers, recurse, force, literalPath);
 }
Пример #39
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     foreach (var childItem in CurrentChildItems.Where(ci => ci.LinkSelf == path))
     {
         WriteItemObject(childItem.Title, path, childItem.IsContainer);
     }
 }
Пример #40
0
 protected override void GetChildNames(Path path, ReturnContainers returnContainers)
 {
     throw new NotImplementedException();
 }
Пример #41
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     foreach (var subItem in this.ZookeeperDriver.Zookeeper.GetChildren(path))
     {
         this.WriteNodeName( path, subItem );
     }
 }
Пример #42
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     if (TransactionAvailable())
     {
         using (CurrentPSTransaction)
         {
             base.GetChildNames(path, returnContainers);
             return;
         }
     }
     base.GetChildNames(path, returnContainers);
 }
Пример #43
0
 //internal object GetChildItemsDynamicParameters(Path path, bool recurse, CmdletProviderContext context);
 internal void GetChildNames(Path path, ReturnContainers returnContainers, ProviderRuntime runtime)
 {
     ProviderRuntime = runtime;
     GetChildNames(path, returnContainers);
 }
Пример #44
0
        private void GetPathItems(DirectoryEntryInfo parent, bool recurse, bool nameOnly, ReturnContainers returnContainers)
        {
            foreach (DirectoryEntryInfo child in parent.GetChildren())
            {
                WriteEntryInfo(child, nameOnly);

                if (recurse)
                {
                    GetPathItems(child, recurse, nameOnly, returnContainers);
                }
            }
        }
Пример #45
0
 private void GetPathItems(string path, bool recurse, bool nameOnly, ReturnContainers returnContainers)
 {
     using (EnterContext(path))
     {
         DirectoryEntryInfo parent = GetEntryInfoFromPSPath(path);
         
         if (parent.IsContainer)
         {
             using (parent)
             {
                 GetPathItems(parent, recurse, nameOnly, returnContainers);
             }
         }
         else
         {
             WriteEntryInfo(parent, nameOnly);
         }
     }
 }
Пример #46
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            try
            {
                LogInfo("Executing GetChildNames(string path='{0}', string returnContainers='{1}')", path,
                    returnContainers);
                path = path.Replace("\\", "/");
                if (path.Contains("../"))
                {
                    path = path.Substring(path.LastIndexOf("../", StringComparison.Ordinal) + 2);
                }

                // apply filter
                WildcardPattern wildcard = null;

                if (!string.IsNullOrEmpty(Filter))
                {
                    wildcard = new WildcardPattern(Filter, WildcardOptions.IgnoreCase | WildcardOptions.Compiled);
                }

                var pageRef = GetItemForPath(path);
                if (pageRef != null)
                {
                    var children = pageRef.GetChildren();
                    foreach (Item child in children)
                    {
                        if (returnContainers == ReturnContainers.ReturnAllContainers || wildcard == null ||
                            wildcard.IsMatch(child.Name))
                        {
                            WriteItemObject(child.Name, child.GetProviderPath(), child.HasChildren);
                        }
                        if (Stopping)
                            return;
                    }
                }
                else
                {
                    Exception exception =
                        new IOException(string.Format("Cannot find path '{0}' because it does not exist.", path));
                    WriteError(new ErrorRecord(exception, "ItemDoesNotExist", ErrorCategory.ObjectNotFound, path));
                }
            }
            catch (Exception ex)
            {
                LogError(ex,
                    "Error while executing GetChildNames(string path='{0}', string returnContainers='{1}')",
                    path, returnContainers);
                throw;
            }
        }
Пример #47
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            WriteVerbose(string.Format("SPOProvider::GetChildNames (Path = ’{0}’)", path));

            var folder = GetFileOrFolder(path) as Folder;
            if (folder != null)
            {
                var folderAndFiles = GetFolderItems(folder).ToArray();
                var serverRelaitivePath = GetServerRelativePath(path);
                foreach (var subFolder in folderAndFiles.OfType<Folder>().ToList())
                {
                    string name;
                    if (string.IsNullOrEmpty(subFolder.Name))
                    {
                        var serverRelativeUrl = IsPropertyAvailable(subFolder, "ServerRelativeUrl") ? subFolder.ServerRelativeUrl : subFolder.EnsureProperty(s => s.ServerRelativeUrl);
                        name = serverRelativeUrl.Split(PathSeparator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Last();
                    }
                    else
                    {
                        name = subFolder.Name;
                    }
                    WriteItemObject(name, serverRelaitivePath, true);
                }
                foreach (var file in folderAndFiles.OfType<File>().ToList())
                {
                    WriteItemObject(file.Name, serverRelaitivePath, false);
                }
            }
            else
            {
                WriteErrorInternal("No folder at end of path", path, ErrorCategory.InvalidOperation);
            }
        }
Пример #48
0
 void GetChildNames( string path, INodeFactory nodeFactory, ReturnContainers returnContainers )
 {
     nodeFactory.GetNodeChildren(CreateContext(path)).ToList().ForEach(
         f =>
             {
                 var i = f.GetNodeValue();
                 if (null == i)
                 {
                     return;
                 }
                 WriteItemObject(i.Name, path + "\\" + i.Name, i.IsCollection);
             });
 }
Пример #49
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     foreach (var entry in GetProperties(path))
     {
         WriteItemObject(entry.Name, entry.Name, false);
     }
 }
Пример #50
0
 /// <summary>
 /// Gets the child names of a given store, or location.
 /// </summary>
 ///
 /// <param name="path">
 /// The full path of the store or location to enumerate.
 /// </param>
 ///
 /// <param name="returnContainers">
 /// Determines if all containers should be returned or only those containers that match the
 /// filter(s).
 /// </param>
 /// 
 /// <exception cref="System.ArgumentNullException">
 /// Path is null or empty.
 /// </exception>
 /// 
 /// <exception cref="System.Security.Cryptography.CryptographicException">
 /// This exception can be thrown if any cryptographic error occurs.
 /// It is not possible to know exactly what went wrong.
 /// This is because of the way CryptographicException is designed.
 /// Possible reasons:
 ///  -- certificate is invalid
 ///  -- certificate has no private key
 ///  -- certificate password mismatch
 ///  -- etc
 /// </exception>
 /// 
 protected override void GetChildNames(
     string path,
     ReturnContainers returnContainers)
 {
     path = NormalizePath(path);
     GetChildItemsOrNames(path, false, returnContainers, true, GetFilter());
 } // GetChildNames
 /// <summary>
 /// Gets names of the children of the specified path.
 /// </summary>
 /// 
 /// <param name="path">
 /// The path to the item from which to retrieve the child names.
 /// </param>
 /// 
 /// <param name="returnAllContainers">
 /// If true, the provider should return all containers, even if they
 /// don't match the filter.  If false, the provider should only return
 /// containers that do match the filter.
 /// </param>
 /// 
 /// <remarks>
 /// Providers override this method to give the user access to the 
 /// provider objects using the get-childitem -name cmdlet.
 /// 
 /// Providers that declare 
 /// <see cref="System.Management.Automation.Provider.ProviderCapabilities"/>
 /// of ExpandWildcards, Filter, Include, or Exclude should ensure that
 /// the path passed meets those requirements by accessing the 
 /// appropriate property from the base class. The exception to this is
 /// if <paramref name="returnAllContainers"/> is true, then any child 
 /// name for a container should be returned even if it doesn't match 
 /// the Filter, Include, or Exclude.
 /// 
 /// By default overrides of this method should not write the names of
 /// objects that are generally hidden from the user unless the Force 
 /// property is set to true. For instance, the FileSystem provider 
 /// should not call WriteItemObject for hidden or system files unless 
 /// the Force property is set to true. 
 /// 
 /// The provider implementation is responsible for preventing infinite 
 /// recursion when there are circular links and the like. An 
 /// appropriate terminating exception should be thrown if this
 /// situation occurs.
 /// 
 /// The child names are the leaf portion of the path. Example, for the
 /// file system the name for the path c:\windows\system32\foo.dll would
 /// be foo.dll or for the directory c:\windows\system32 would be
 /// system32.  For Active Directory the child names would be RDN values
 /// of the child objects of the container.
 /// 
 /// All names should be written to the WriteItemObject method.
 /// </remarks>
 protected override void GetChildNames( string path,
                             ReturnContainers returnAllContainers )
 {
     // Get the names of children at the specified path
     // and writing them
     // WriteItemObject( item, path, isContainer );
 }
Пример #52
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     base.GetChildNames(path, returnContainers);
 }
Пример #53
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     var item = GetTreeItem(path);
     if (item != null)
     {
         foreach (var child in item.Children)
         {
             var name = child.NodeName();
             var nodePath = child.NodePath();
             WriteItemObject(name, nodePath, true);
         }
     }
 }
Пример #54
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     // TODO: returnContainers
     GetChildren(Utilities.NormalizePath(path), false, true);
 }
Пример #55
0
 internal Collection<string> GetChildNames(string path, ReturnContainers returnContainers, bool recurse, ProviderRuntime providerRuntime)
 {
     // MUST: fix
     throw new NotImplementedException();
 }
Пример #56
0
 protected override void GetChildNames(string path, ReturnContainers returnContainers)
 {
     GetPathItems(path, false, true, returnContainers);
 }
 public Collection<string> GetNames(string path, ReturnContainers returnContainers, bool recurse)
 {
     return this.sessionState.GetChildNames(new string[] { path }, returnContainers, recurse, false, false);
 }
        } // GetChildItems

        /// <summary>
        /// Return the names of all child items.
        /// </summary>
        /// <param name="path">The root path.</param>
        /// <param name="returnContainers">Not used.</param>
        protected override void GetChildNames(string path,
                                      ReturnContainers returnContainers)
        {
            // If the path represented is a drive, then the child items are
            // tables. get the names of all the tables in the drive.
            if (PathIsDrive(path))
            {
                foreach (DatabaseTableInfo table in GetTables())
                {
                    WriteItemObject(table.Name, path, true);
                } // foreach (DatabaseTableInfo...
            } // if (PathIsDrive...
            else
            {
                // Get type, table name and row number from path specified
                string tableName;
                int rowNumber;

                PathType type = GetNamesFromPath(path, out tableName, out rowNumber);

                if (type == PathType.Table)
                {
                    // Get all the rows in the table and then write out the 
                    // row numbers.
                    foreach (DatabaseRowInfo row in GetRows(tableName))
                    {
                        WriteItemObject(row.RowNumber, path, false);
                    } // foreach (DatabaseRowInfo...
                }
                else if (type == PathType.Row)
                {
                    // In this case the user has directly specified a row, hence
                    // just give that particular row
                    DatabaseRowInfo row = GetRow(tableName, rowNumber);

                    WriteItemObject(row.RowNumber, path, false);
                }
                else
                {
                    ThrowTerminatingInvalidPathException(path);
                }
            } // else
        } // GetChildNames
Пример #59
0
        protected override void GetChildNames(string path, ReturnContainers returnContainers)
        {
            var nodeFactory = GetNodeFactoryFromPath(path, false);
            if (null == nodeFactory)
            {
                return;
            }

            nodeFactory.ToList().ForEach(f => GetChildNames(path, f, returnContainers));
        }
Пример #60
0
        /// <summary>
        /// Helper function to get store-location/store/cert at
        /// the specified path.
        /// </summary>
        ///
        /// <param name="path"> path to the item  </param>
        ///
        /// <param name="recurse"> whether we need to recursively find all </param>
        ///
        /// <param name="returnContainers">
        /// Determines if all containers should be returned or only those containers that match the
        /// filter(s).
        /// </param>
        ///
        /// <param name="returnNames"> whether we only need the names </param>
        ///
        /// <param name="filter"> filter info </param>
        ///
        /// <returns> Does not return a value </returns>
        ///
        /// <remarks>  </remarks>
        ///
        private void GetChildItemsOrNames(
            string path,
            bool recurse,
            ReturnContainers returnContainers,
            bool returnNames,
            CertificateFilterInfo filter)
        {
            object thingToReturn = null;
            string childPath = null;

            bool returnAllContainers = returnContainers == ReturnContainers.ReturnAllContainers;

            Utils.CheckArgForNull(path, "path");

            //
            // children at the root path are store locations
            //
            if (path.Length == 0)
            {
                foreach (X509StoreLocation l in s_storeLocations)
                {
                    thingToReturn = returnNames ?
                        (object)l.LocationName : (object)l;

                    // 'returnNames' is true only when called from
                    // GetChildNames(), in which case 'recurse' will always be
                    // false.  When the -Path parameter needs to be globbed,
                    // the potential location names should be returned by
                    // calling this method from GetChildNames.

                    // The original code didn't have a "|| returnNames" clause.
                    // Suppose the user types:
                    //     dir cert:\curr* -CodeSigningCert -recurse
                    // We need to do path globbing here to resolve wild cards.
                    // Since -CodeSigningCert is present, 'filter' is not null.
                    // Since this method is called from GetChildNames() when
                    // doing the path globbing, 'returnNames' is true and
                    // 'recurse' is false.
                    // In the original code, nothing was returned by
                    // WriteItemObject(), so the path globbing fails and the
                    // above dir command would not display the certificates
                    // as expected.

                    // Another case is:
                    //     dir cert:\ -CodeSigningCert -Recurse
                    // -Recurse is present, so we need to call
                    // DoManualGetChildItems, and inside DoManualGetChildItems,
                    // this method will be called to get the names.
                    // The original code had the same problem for this case.

                    // With the "|| returnNames" clause, we test if this method
                    // is called from the GetChildNames().  When this method is
                    // called from GetChildNames(), 'recurse' will always be
                    // false.  Then we should return the names whether 'filter'
                    // is null or not.

                    if (filter == null || returnNames)
                    {
                        WriteItemObject(thingToReturn, l.LocationName, true);
                    }
                    childPath = l.LocationName;
                    if (recurse)
                    {
                        GetChildItemsOrNames(
                                        childPath,
                                        recurse,
                                        returnContainers,
                                        returnNames,
                                        filter);
                    }
                }
            }
            else
            {
                string[] pathElements = GetPathElements(path);

                //
                // children at depth 1 are stores
                //
                if (pathElements.Length == 1)
                {
                    GetStoresOrNames(pathElements[0],
                                     recurse,
                                     returnNames,
                                     filter);
                }
                //
                // children at depth 2 are certificates
                //
                else if (pathElements.Length == 2)
                {
                    GetCertificatesOrNames(path,
                                           pathElements,
                                           returnNames,
                                           filter);
                }
                else
                {
                    ThrowItemNotFound(path, CertificateProviderItem.Certificate);
                }
            }
        }