AcManager.Tools.ContentInstallation.SharpCompressExtension.HasAnyEncryptedFiles C# (CSharp) Method

HasAnyEncryptedFiles() public static method

public static HasAnyEncryptedFiles ( this archive ) : bool
archive this
return bool
        public static bool HasAnyEncryptedFiles(this IArchive archive) {
            try {
                using (var entry = archive.Entries
                                          .Where(x => x.IsEncrypted && x.Size > 0 && !x.IsDirectory)
                                          .MinEntryOrDefault(x => x.CompressedSize)?
                                          .OpenEntryStream()) {
                    return entry != null && entry.ReadByte() != -1;
                }
            } catch (CryptographicException) {
                return true;
            } catch (Exception e) {
                Logging.Write("HasAnyEncryptedFiles(): " + e);
                return true;
            }
        }
    }