示例#1
0
        public IEnumerator <IFileInfo> GetEnumerator()
        {
            // Only enumerate directories, and files with matching
            // .encrypted and .keyname extensions.
            var keynameFiles   = new Dictionary <String, IFileInfo>();
            var encryptedFiles = new List <IFileInfo>();

            foreach (var fileInfo in innerDirectoryContents)
            {
                if (fileInfo.IsDirectory)
                {
                    yield return(fileInfo);
                }
                else
                {
                    string extension = Path.GetExtension(fileInfo.Name);
                    if (extension == ".encrypted")
                    {
                        encryptedFiles.Add(fileInfo);
                    }
                    else if (extension == ".keyname")
                    {
                        keynameFiles[fileInfo.Name] = fileInfo;
                    }
                }
            }
            foreach (IFileInfo fileInfo in encryptedFiles)
            {
                IFileInfo keynameFile = keynameFiles.GetValueOrDefault(
                    Path.ChangeExtension(fileInfo.Name, ".keyname"));
                if (keynameFile != null)
                {
                    yield return(EncryptedFileInfo.FromFileInfo(kms, fileInfo,
                                                                keynameFile));
                }
            }
        }
示例#2
0
 public IFileInfo GetFileInfo(string subpath)
 {
     return(EncryptedFileInfo.FromFileInfo(kms,
                                           innerProvider.GetFileInfo(subpath),
                                           innerProvider.GetFileInfo(Path.ChangeExtension(subpath, ".keyname"))));
 }