예제 #1
0
 /// <summary>
 /// Open a file from Content Key
 /// </summary>
 /// <param name="key">Content Key of the file</param>
 /// <returns>Loaded file</returns>
 public Stream OpenCKey(CKey key)
 {
     if (EncodingHandler != null && EncodingHandler.TryGetEncodingEntry(key, out EncodingHandler.CKeyEntry entry))
     {
         return(OpenEKey(entry.EKey));
     }
     if (CreateArgs.Online)
     {
         return(new BLTEStream(this, NetHandle.OpenData(key)));
     }
     Debugger.Log(0, "ContainerHandler", $"Missing encoding entry for CKey {key.ToHexString()}\n");
     return(null);
 }
예제 #2
0
        /// <summary>
        /// Open a file from Content Key
        /// </summary>
        /// <param name="key">Content Key of the file</param>
        /// <returns>Loaded file</returns>
        public Stream?OpenCKey(CKey key)
        {
            // todo: EncodingHandler can't be null after constructor has finished, but can be during init
            if (EncodingHandler != null && EncodingHandler.TryGetEncodingEntry(key, out var entry))
            {
                return(OpenEKey(entry.EKey));
            }

            if (CreateArgs.Online)
            {
                return(new BLTEStream(this, NetHandle !.OpenData(key)));
            }

            Debugger.Log(0, "ContainerHandler", $"Missing encoding entry for CKey {key.ToHexString()}\n");
            return(null);
        }
예제 #3
0
        /// <summary>
        /// Open a file from Encoding Key
        /// </summary>
        /// <param name="key">The Long Encoding Key</param>
        /// <returns>Loaded file</returns>
        public Stream?OpenEKey(CKey key)     // ekey = value of ckey in encoding table
        {
            if (ContainerHandler != null)
            {
                try {
                    var cascBlte = OpenEKey(key.AsEKey());
                    if (cascBlte != null)
                    {
                        return(cascBlte);
                    }
                } catch (Exception e) {
                    if (!CreateArgs.Online)
                    {
                        throw;
                    }
                    Logger.Warn("CASC", $"Unable to open {key.ToHexString()} from CASC. Will try to download. Exception: {e}");
                }
            }

            if (!CreateArgs.Online)
            {
                return(null);
            }

            Stream?netMemStream = null;

            if (m_cdnIdx !.CDNIndexData.TryGetValue(key, out var cdnIdx))
            {
                netMemStream = m_cdnIdx.OpenDataFile(cdnIdx);
            }

            if (netMemStream == null)
            {
                netMemStream = NetHandle !.OpenData(key);
            }

            if (netMemStream == null)
            {
                return(null);
            }
            return(new BLTEStream(this, netMemStream));
        }
예제 #4
0
 /// <summary>
 /// Open a file from Content Key
 /// </summary>
 /// <param name="key">Content Key of the file</param>
 /// <returns>Loaded file</returns>
 public Stream OpenCKey(CKey key)
 {
     if (EncodingHandler != null && EncodingHandler.TryGetEncodingEntry(key, out EncodingHandler.CKeyEntry entry))
     {
         return(OpenEKey(entry.EKey));
     }
     if (CreateArgs.Online)
     {
         using (var stream = NetHandle.OpenData(key)) {
             if (stream != null)
             {
                 var ms = new MemoryStream();
                 stream.CopyTo(ms);
                 ms.Position = 0;
                 return(new BLTEStream(this, ms));
             }
         }
     }
     Debugger.Log(0, "ContainerHandler", $"Missing encoding entry for CKey {key.ToHexString()}\n");
     return(null);
 }
예제 #5
0
 public Stream?OpenData(CKey key)
 {
     // todo: caching
     return(FetchCDN("data", key.ToHexString()));
 }