Beispiel #1
0
        void Reset(string path)
        {
            // set location
            if (!string.IsNullOrEmpty(path) && path != ".")
            {
                A.Psf.Engine.SessionState.Path.SetLocation(path);
            }

            // get location
            PathInfoEx location = new PathInfoEx(A.Psf.Engine.SessionState.Path.CurrentLocation);

            if (!My.ProviderInfoEx.IsNavigation(location.Provider))
            {
                throw new RuntimeException("Provider '" + location.Provider + "' does not support navigation.");
            }

            // get root item
            Collection <PSObject> items = A.Psf.Engine.SessionState.InvokeProvider.Item.Get(new string[] { "." }, true, true);

            //! trap Get-Item at Cert:
            if (items.Count == 0)
            {
                throw new RuntimeException(string.Format(null, "Provider '{0}' cannot get '{1}'.", location.Provider, location.Path));
            }
            PSObject data = items[0];

            // reset roots
            RootFiles.Clear();
            var ti = new TreeFile
            {
                Name = location.Path,                 // special case name for the root
                Fill = TheFill,
                Data = data
            };

            RootFiles.Add(ti);
            ti.Expand();

            // panel info
            Location = ti.Path;
        }
Beispiel #2
0
        Queue <FileNode> GetFileRoots(IDictionary <string, FileNode> files, Trimmable trimmable)
        {
            var fileRootQueue = new Queue <FileNode>();

            var trimmedRootFilenames = RootFiles.Select(i => GetFileNameFromItem(i)).Where(f => !trimmable.IsFileTrimmable(f));

            foreach (var rootFilename in trimmedRootFilenames)
            {
                FileNode rootFile;
                if (files.TryGetValue(rootFilename, out rootFile))
                {
                    IncludeNode(fileRootQueue, rootFile);
                }
                else
                {
                    Log.LogMessage($"Root file {rootFilename} was specified but was not found in the file index.");
                }
            }

            return(fileRootQueue);
        }
Beispiel #3
0
 public bool HasId(uint fileid) => RootFiles.Any(x => x.Value.FileDataId == fileid);