Example #1
0
        /// <summary>
        /// Updates the file.
        /// </summary>
        /// <param name="baseDirectory">The base directory.</param>
        /// <param name="verifyData">The verify data.</param>
        public static void UpdateFile(string baseDirectory, IUpdatableVerifiableFile verifyData)
        {
            if (string.IsNullOrEmpty(baseDirectory))
            {
                throw new ArgumentNullException("baseDirectory");
            }
            else if (verifyData == null)
            {
                throw new ArgumentNullException("verifyData");
            }

            UpdateFile(baseDirectory, verifyData, QQnCryptoHelpers.DefaultHashType | HashType.PlusType);
        }
Example #2
0
        /// <summary>
        /// Updates the file.
        /// </summary>
        /// <param name="baseDirectory">The base directory.</param>
        /// <param name="verifyData">The verify data.</param>
        /// <param name="hashType">Type of the hash.</param>
        public static void UpdateFile(string baseDirectory, IUpdatableVerifiableFile verifyData, HashType hashType)
        {
            if (string.IsNullOrEmpty(baseDirectory))
            {
                throw new ArgumentNullException("baseDirectory");
            }
            else if (verifyData == null)
            {
                throw new ArgumentNullException("verifyData");
            }

            FileInfo fif = new FileInfo(QQnPath.Combine(baseDirectory, verifyData.Filename));

            if (!fif.Exists)
            {
                return;
            }

            long     size = fif.Length;
            string   hash = QQnCryptoHelpers.CalculateFileHash(fif.FullName, hashType);
            DateTime dt   = fif.LastWriteTimeUtc;

            verifyData.UpdateVerifyData(hash, size, dt);
        }