home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 July / VPR0207A.ISO / OLS / IRVINE0_4_1A / irvine0_4_1a.lzh / scripts / listcrccheck.dms < prev    next >
Text File  |  2002-01-14  |  2KB  |  72 lines

  1. /*
  2. スクリプト初期化イベント
  3. guid={0B73E922-238E-47CA-8537-E47B39A0C265}
  4. caption=CRC,MD5チェック
  5. version=1
  6. hint=選択アイテムのCRC,MD5をチェックします
  7. event=OnListMenuClick
  8. match=
  9. author=Wolfy
  10. */
  11.  
  12. function OnListMenuClick(irvine,action){
  13. //リストメニューのクリックイベント
  14.   item = new IrvineItem;
  15.   crc = new CRC;
  16.   md5 = new MD5;
  17.   file = new File;
  18.  
  19.   flag = false;
  20.   irvine.BeginProgressBar(irvine.SelectedItemCount);
  21.   try{
  22.     for(i = 0; i < irvine.ItemCount; i++){
  23.       if (irvine.GetItemSelected(i)){
  24.         irvine.ProgressBarStepBy(1);
  25.         
  26.         item.data = irvine.GetItemData(i);
  27.         len = item.check.length;
  28.         if(len == 0)
  29.           continue;
  30.  
  31.         file.filename = irvine.GetItemFilename(i);
  32.         if(file.exists()){
  33.           if(len == 4){
  34.             crc.calcFile(file.filename);
  35.             item.success = (crc.CRC16.toString(16).substr(4,4).toLowerCase() == item.check.toLowerCase());
  36.             item.error = (! item.success);
  37.           }
  38.           else if(len == 8){
  39.             crc.calcFile(file.filename);
  40.             item.success = (crc.CRC32.toString(16).toLowerCase() == item.check.toLowerCase());
  41.             item.error = (! item.success);
  42.           }
  43.           else if(len == 32){
  44.             item.success = (md5.calcFile(file.filename).toLowerCase() == item.check.toLowerCase());
  45.             item.error = (! item.success);
  46.           }
  47.           else{
  48.             item.error = true;
  49.           }
  50.         }
  51.         else{
  52.           item.success = false;
  53.           item.error = false;
  54.         }
  55.  
  56.         irvine.SetItemData(i,item.data);
  57.         flag = true;
  58.       }
  59.     }
  60.   }
  61.   finally{
  62.     irvine.EndProgressBar();
  63.     if(flag)
  64.       irvine.Invalidate();
  65.   }
  66. }
  67.  
  68. function OnMenuUpdate(irvine,action){
  69. //メニューの更新イベント
  70.   action.enabled = (irvine.SelectedItemCount > 0);
  71. }
  72.