Пример #1
0
 /// <summary>
 /// Initializes a new instance of the Entry class
 /// </summary>
 /// <param name="parent">The owner Archive</param>
 /// <param name="ze">the ZipEntry to wrap</param>
 internal Entry(Archive parent, ZipEntry ze)
 {
     this.zipEntry = ze;
     this.parent = parent;
 }
Пример #2
0
        /// <summary>
        /// Reads info about the mod (file hashes, etc)
        /// </summary>
        public void AnalyzeMod()
        {
            if (!this.IsDownloaded)
            {
                throw new InvalidOperationException("Cannot analyze the Mod if it's not downloaded");
            }

            var archive = new Archive(this.FullPath);

            using (var dbConn = Database.GetConnection())
            using (var tx = dbConn.BeginTransaction())
            {
                foreach (var entry in archive.ClassEntries)
                {
                    string hash;
                    using (var s = entry.OpenToRead())
                    {
                        hash = MD5.Hash(s);
                    }

                    dbConn.Execute(@"REPLACE INTO modclass(modid, version, file, hash) VALUES (@Modid, @Version, @File, @Hash)", new { Modid = this.ParentId.ToString(), Version = this.Ver, File = entry.Name, Hash = hash }, tx);
                }

                tx.Commit();
            }
        }