示例#1
0
        protected Stream OpenFileOnlineInternal(IndexEntry idxInfo, MD5Hash key)
        {
            Stream s;

            if (idxInfo != null)
            {
                s = CDNIndex.OpenDataFile(idxInfo);
            }
            else
            {
                s = CDNIndex.OpenDataFileDirect(key);
            }

            BLTEStream blte;

            try
            {
                blte = new BLTEStream(s, key);
            }
            catch (BLTEDecoderException exc) when(exc.ErrorCode == 0)
            {
                return(OpenFileOnlineInternal(idxInfo, key));
            }

            return(blte);
        }
        protected Stream OpenFileOnlineInternal(IndexEntry idxInfo, MD5Hash key)
        {
            Stream s;

            if (idxInfo != null)
            {
                s = CDNIndex.OpenDataFile(idxInfo);
            }
            else
            {
                s = CDNIndex.OpenDataFileDirect(key);
            }

            BLTEStream blte;

            try
            {
                blte = new BLTEStream(s, key);
            }
            catch (BLTEDecoderException exc) when(exc.ErrorCode == 0)
            {
                CDNCache.Instance.InvalidateFile(idxInfo != null ? Config.Archives[idxInfo.Index] : key.ToHexString());
                return(OpenFileOnlineInternal(idxInfo, key));
            }

            return(blte);
        }
示例#3
0
        private void ExtractFileLocal(MD5Hash key, string path, string name)
        {
            Stream stream = GetLocalDataStream(key);

            using (BLTEStream blte = new BLTEStream(stream, key))
            {
                blte.ExtractToFile(path, name);
            }
        }
示例#4
0
 protected void ExtractFileOnlineInternal(IndexEntry idxInfo, MD5Hash key, string path, string name)
 {
     if (idxInfo != null)
     {
         using (Stream s = CDNIndex.OpenDataFile(idxInfo))
             using (BLTEStream blte = new BLTEStream(s, key))
             {
                 blte.ExtractToFile(path, name);
             }
     }
     else
     {
         using (Stream s = CDNIndex.OpenDataFileDirect(key))
             using (BLTEStream blte = new BLTEStream(s, key))
             {
                 blte.ExtractToFile(path, name);
             }
     }
 }