Пример #1
0
    private void FindNativeLibrarySearchPaths(string ldConfigPath)
    {
        string line;

        if (!File.Exists(ldConfigPath))
        {
            return;
        }

        using (var reader = new StreamReader(ldConfigPath)) {
            while ((line = reader.ReadLine()) != null)
            {
                line = line.Trim();
                if (line.StartsWith("include "))
                {
                    var expr = line.Substring(8);
                    var dir  = Path.GetDirectoryName(expr);
                    expr = expr.Substring(expr.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                    foreach (var path in Directory.GetFiles(dir, expr))
                    {
                        FindNativeLibrarySearchPaths(path);
                    }
                }
                else
                {
                    SearchPaths.Add(line);
                }
            }
        }
    }
Пример #2
0
        public void AddSearchPath(string path)
        {
            // Invalidate the cache
            expandedPCorePaths = null;

            // Add the search path
            SearchPaths.Add(path);
        }
Пример #3
0
 /// <summary>
 /// Initializes search path from the value of the environment variable "PATH".
 /// </summary>
 public void InitializeSearchPathFromCurrentEnvironment()
 {
     char[] sep = new char[] { ';' };
     foreach (string s in Environment.GetEnvironmentVariable("PATH").Split(sep, StringSplitOptions.RemoveEmptyEntries))
     {
         if (Directory.Exists(s))
         {
             SearchPaths.Add(s);
         }
     }
 }
 protected override OptionSet OnCreateOptions() => new OptionSet
 {
     { "cache=", "The package cache directory", v => PackageCache = v },
     { "group-ids", "Group the output by package ID", v => GroupByPackageId = true },
     { "group-versions", "Group the output by version", v => GroupByVersion = true },
     { "latest", "Compare against the latest", v => Latest = true },
     { "output=", "The output directory", v => OutputDirectory = v },
     { "prerelease", "Include preprelease packages", v => PrePrelease = true },
     { "ignore-unchanged", "Ignore unchanged packages and assemblies", v => IgnoreUnchanged = true },
     { "search-path=", "A search path directory", v => SearchPaths.Add(v) },
     { "source=", "The NuGet URL source", v => SourceUrl = v },
     { "version=", "The version of the package to compare", v => Version = v },
 };
Пример #5
0
    private void FindNativeLibrarySearchPaths()
    {
        foreach (var var in new [] { "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH" })
        {
            var value = Environment.GetEnvironmentVariable(var);
            if (!String.IsNullOrEmpty(value))
            {
                foreach (var path in value.Split(':'))
                {
                    SearchPaths.Add(path);
                }
            }
        }

        FindNativeLibrarySearchPaths("/etc/ld.so.conf");
    }
Пример #6
0
 public FileExports GetFileExports(string filename, bool addDirectoryToSearchPaths = false)
 {
     if (addDirectoryToSearchPaths &&
         Path.IsPathRooted(filename) &&
         File.Exists(filename))
     {
         SearchPaths.Add(Path.GetDirectoryName(filename));
     }
     List<string> candidates = ResolveFilename(filename);
     FileExports firstResult = null;
     foreach (string candidate in candidates)
     {
         var fileInfo = new FileInfo(candidate);
         var fullName = fileInfo.FullName;
         if (AllFileExports.ContainsKey(fullName))
         {
             return AllFileExports[fullName];
         }
         var records = DumpBinProcessor_Obsolete.GetExports_Obsolete(fullName);
         var fileExports = new FileExports()
         {
             StartingFilePath = fullName
         };
         foreach (var record in records)
         {
             fileExports.Records.Add(record);
             if (!string.IsNullOrEmpty(record.Prototype) &&
                 !fileExports.LookupByPrototype.ContainsKey(record.Prototype))
             {
                 fileExports.LookupByPrototype.Add(record.Prototype, record);
             }
             if (!string.IsNullOrEmpty(record.DecoratedName) &&
                 !fileExports.LookupByDecoratedName.ContainsKey(record.DecoratedName))
             {
                 fileExports.LookupByDecoratedName.Add(record.DecoratedName, record);
             }
         }
         AllFileExports.Add(fullName, fileExports);
         if (firstResult == null)
         {
             firstResult = fileExports;
         }
     }
     return firstResult;
 }
Пример #7
0
        public override void Execute(object parameter)
        {
            var selectedFileTreeItem = GetSelectedFileTreeItem();

            if (selectedFileTreeItem == null)
            {
                return;
            }

            var itemPath = selectedFileTreeItem.ItemPath;

            if (!CanAddPath(itemPath))
            {
                return;
            }
            SearchPaths.Add(new SearchPath(itemPath, InclusionType.Include));
            Enabled = false;
        }
Пример #8
0
 /// <summary>
 /// <para>
 /// Returns the list of dependent binary files for the given binary file.
 /// </para>
 /// <para>
 /// This function has to distinct modes of operation. If the input filename is a
 /// complete path, that file alone is inspected. If it is not a complete path,
 /// a list of candidate binary files are located among the search paths, and each of 
 /// these will have their dependents enumerated.
 /// </para>
 /// <para>
 /// Inspection results for each binary file are cached, to prevent endless loop of
 /// recalculations.
 /// </para>
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="addDirectoryToSearchPaths"></param>
 /// <returns>
 /// The list of dependent files. This list contains the pathless file names.
 /// To translate into full paths, see <see cref="AllFileCandidates"/>.
 /// </returns>
 public List<string> GetDependents(string filename, bool addDirectoryToSearchPaths = false)
 {
     if (addDirectoryToSearchPaths &&
         Path.IsPathRooted(filename) && 
         File.Exists(filename))
     {
         SearchPaths.Add(Path.GetDirectoryName(filename));
     }
     List<string> candidates = ResolveFilename(filename);
     HashSet<string> pathlessDependents = new HashSet<string>(new FilenameKeyComparer());
     foreach (string candidate in candidates)
     {
         var fileInfo = new FileInfo(candidate);
         var fullName = fileInfo.FullName;
         if (DependenceRecords.ContainsKey(fullName))
         {
             foreach (string dependent in DependenceRecords[fullName].Dependents)
             {
                 pathlessDependents.Add(dependent);
             }
             continue;
         }
         var results = DumpBinProcessor.GetDependents(fullName);
         var record = new DependenceRecord()
         {
             StartingFilePath = fullName,
             Dependents = results
         };
         DependenceRecords.Add(fullName, record);
         foreach (string result in results)
         {
             pathlessDependents.Add(result);
         }
     }
     return new List<string>(pathlessDependents);
 }
Пример #9
0
        public void ListOperations()
        {
            var sp = new SearchPaths();
            AssertEx.Equal(Array.Empty<string>(), sp.List.GetNewContent());
            Assert.Equal(0, sp.List.Version);

            sp.Add("foo");
            AssertEx.Equal(new[] { "foo" }, sp.List.GetNewContent());
            Assert.Equal(1, sp.List.Version);

            sp.AddRange(new[] { "bar" });
            AssertEx.Equal(new[] { "foo", "bar" }, sp.List.GetNewContent());
            Assert.Equal(2, sp.List.Version);

            sp.AddRange(new[] { "baz" });
            AssertEx.Equal(new[] { "foo", "bar", "baz" }, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            Assert.True(sp.Contains("bar"));
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            var a = new string[sp.Count + 2];
            Assert.Equal(3, sp.List.Version);
            AssertEx.Equal(null, sp.List.GetNewContent());

            sp.CopyTo(a, 1);
            AssertEx.Equal(new[] { null, "foo", "bar", "baz", null }, a);
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            AssertEx.Equal(new[] { "foo", "bar", "baz" }, sp);
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            Assert.Equal(2, sp.IndexOf("baz"));
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            sp.Insert(1, "goo");
            AssertEx.Equal(new[] { "foo", "goo", "bar", "baz" }, sp);
            AssertEx.Equal(new[] { "foo", "goo", "bar", "baz" }, sp.List.GetNewContent());
            Assert.Equal(4, sp.List.Version);

            Assert.False(sp.IsReadOnly);
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(4, sp.List.Version);

            Assert.True(sp.Remove("bar"));
            Assert.Equal(5, sp.List.Version);
            AssertEx.Equal(new[] { "foo", "goo", "baz" }, sp);
            AssertEx.Equal(new[] { "foo", "goo", "baz" }, sp.List.GetNewContent());

            Assert.False(sp.Remove("___"));
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(5, sp.List.Version);

            sp.RemoveAt(1);
            AssertEx.Equal(new[] { "foo", "baz" }, sp);
            AssertEx.Equal(new[] { "foo", "baz" }, sp.List.GetNewContent());
            Assert.Equal(6, sp.List.Version);

            sp.Clear();
            AssertEx.Equal(Array.Empty<string>(), sp.List.GetNewContent());
            Assert.Equal(7, sp.List.Version);

            sp.Clear();
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(7, sp.List.Version);
        }
Пример #10
0
 /// <summary>
 /// Add a directory to the list of paths searched when attempting to locate a view.
 /// </summary>
 public SimpleFileSystemViewOptions <TContext, TRequest, TResponse> AddSearchPath(string path)
 {
     SearchPaths.Add(Path.GetFullPath(path));
     return(this);
 }
Пример #11
0
        public void ListOperations()
        {
            var sp = new SearchPaths();

            AssertEx.Equal(new string[0], sp.List.GetNewContent());
            Assert.Equal(0, sp.List.Version);

            sp.Add("foo");
            AssertEx.Equal(new[] { "foo" }, sp.List.GetNewContent());
            Assert.Equal(1, sp.List.Version);

            sp.AddRange(new[] { "bar" });
            AssertEx.Equal(new[] { "foo", "bar" }, sp.List.GetNewContent());
            Assert.Equal(2, sp.List.Version);

            sp.AddRange(new[] { "baz" });
            AssertEx.Equal(new[] { "foo", "bar", "baz" }, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            Assert.True(sp.Contains("bar"));
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            var a = new string[sp.Count + 2];

            Assert.Equal(3, sp.List.Version);
            AssertEx.Equal(null, sp.List.GetNewContent());

            sp.CopyTo(a, 1);
            AssertEx.Equal(new[] { null, "foo", "bar", "baz", null }, a);
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            AssertEx.Equal(new[] { "foo", "bar", "baz" }, sp);
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            Assert.Equal(2, sp.IndexOf("baz"));
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(3, sp.List.Version);

            sp.Insert(1, "goo");
            AssertEx.Equal(new[] { "foo", "goo", "bar", "baz" }, sp);
            AssertEx.Equal(new[] { "foo", "goo", "bar", "baz" }, sp.List.GetNewContent());
            Assert.Equal(4, sp.List.Version);

            Assert.False(sp.IsReadOnly);
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(4, sp.List.Version);

            Assert.True(sp.Remove("bar"));
            Assert.Equal(5, sp.List.Version);
            AssertEx.Equal(new[] { "foo", "goo", "baz" }, sp);
            AssertEx.Equal(new[] { "foo", "goo", "baz" }, sp.List.GetNewContent());

            Assert.False(sp.Remove("___"));
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(5, sp.List.Version);

            sp.RemoveAt(1);
            AssertEx.Equal(new[] { "foo", "baz" }, sp);
            AssertEx.Equal(new[] { "foo", "baz" }, sp.List.GetNewContent());
            Assert.Equal(6, sp.List.Version);

            sp.Clear();
            AssertEx.Equal(new string[0], sp.List.GetNewContent());
            Assert.Equal(7, sp.List.Version);

            sp.Clear();
            AssertEx.Equal(null, sp.List.GetNewContent());
            Assert.Equal(7, sp.List.Version);
        }