Exemplo n.º 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);
        }
Exemplo n.º 2
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)
            {
                CDNCache.Instance.InvalidateFile(idxInfo != null ? Config.Archives[idxInfo.Index] : key.ToHexString());
                return(OpenFileOnlineInternal(idxInfo, key));
            }

            return(blte);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
             }
     }
 }