Пример #1
0
        public void runModify(string nSourceDirectory, BundleInfo nBundleInfo, string nDirectory)
        {
            string   source_   = Path.Combine(nSourceDirectory, mSourceFile);
            string   dest_     = Path.Combine(nDirectory, mDestFile);
            FileInfo fileInfo_ = new FileInfo(source_);

            if (!nBundleInfo.mMd5Infos.ContainsKey(mSourceFile))
            {
                File.Copy(fileInfo_.FullName, dest_);
                return;
            }
            Md5Info md5Info_ = nBundleInfo.mMd5Infos[mSourceFile];

            if (md5Info_.mLength != fileInfo_.Length)
            {
                File.Copy(fileInfo_.FullName, dest_);
                return;
            }
            string fileMd5_ = this.genFileMD5(fileInfo_);

            if (md5Info_.mMD5 != fileMd5_)
            {
                File.Copy(fileInfo_.FullName, dest_);
            }
        }
Пример #2
0
        public void runMd5(string nSourceDirectory, BundleInfo nBundleInfo)
        {
            string   path_     = Path.Combine(nSourceDirectory, mSourceFile);
            FileInfo fileInfo_ = new FileInfo(path_);
            Md5Info  md5Info_  = new Md5Info();

            md5Info_.mMD5      = this.genFileMD5(fileInfo_);
            md5Info_.mLength   = fileInfo_.Length;
            md5Info_.mFileName = fileInfo_.Name;
            nBundleInfo.mMd5Infos[mSourceFile] = md5Info_;
        }
Пример #3
0
        bool isFileModify(FileInfo nFileInfo, string nKey, BundleInfo nBundleInfo)
        {
            string key_ = Path.Combine(nKey, nFileInfo.Name);

            if (!nBundleInfo.mMd5Infos.ContainsKey(key_))
            {
                return(true);
            }
            Md5Info md5Info_ = nBundleInfo.mMd5Infos[key_];

            if (md5Info_.mLength != nFileInfo.Length)
            {
                return(true);
            }
            string fileMd5_ = this.genFileMD5(nFileInfo);

            if (md5Info_.mMD5 != fileMd5_)
            {
                return(true);
            }
            return(false);
        }
Пример #4
0
        void runFileMd5(FileInfo nFileInfo, string nKey, BundleInfo nBundleInfo)
        {
            FileStream fileStream_ = new FileStream(nFileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);

            byte[] byteHash_ = mMD5.ComputeHash(fileStream_);
            fileStream_.Close();
            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 0; i < byteHash_.Length; i++)
            {
                stringBuilder.Append(byteHash_[i].ToString("x2"));
            }
            Md5Info md5Info_ = new Md5Info();

            md5Info_.mMD5      = stringBuilder.ToString();
            md5Info_.mLength   = nFileInfo.Length;
            md5Info_.mFileName = nFileInfo.Name;

            string key_ = Path.Combine(nKey, nFileInfo.Name);

            nBundleInfo.mMd5Infos[key_] = md5Info_;
        }