Beispiel #1
0
        private bool IsFile(string name)
        {
            var files = FindFiles(name);

            if (files.Any())
            {
                foreach (var f in files)
                {
                    if (_files.ContainsKey(f))
                    {
                        // if we've got this file already by another parameter, just update it to
                        // keep track that we've somehow got it twice.
                        _files[f].Item1.Add(name);
                    }
                    else
                    {
                        // otherwise, lets' grab the first chunk of this file so we can check what providers
                        // can handle it (later)
                        DictionaryExtensions.Add(_files, f, new List <string> {
                            name
                        }, FilesystemExtensions.ReadBytes(f, 1024));
                    }
                }

                return(true);
            }
            return(false);
        }
Beispiel #2
0
 private MutableEnumerable <string> FindFiles(string path)
 {
     if (FilesystemExtensions.LooksLikeAFilename(path))
     {
         ProviderInfo providerInfo;
         var          paths = GetResolvedProviderPathFromPSPath(path, out providerInfo).ReEnumerable();
         return
             (paths.SelectMany(
                  each => FilesystemExtensions.FileExists(each) ? CollectionExtensions.SingleItemAsEnumerable(each) : FilesystemExtensions.DirectoryExists(each) ? Directory.GetFiles(each) : Microsoft.PackageManagement.Internal.Constants.Empty)
              .ReEnumerable());
     }
     return(Microsoft.PackageManagement.Internal.Constants.Empty.ReEnumerable());
 }