Пример #1
0
        public static bool TryGetArchivePath(string path, out string archive, out string file)
        {
            if (path is null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            foreach (var extension in SupportedExtensions)
            {
                var split = path.Split(new[] { extension }, 2, StringSplitOptions.None);
                if (split.Length == 2)
                {
                    archive = split[0] + extension;
                    file    = split[1];
                    while (Path.IsPathRooted(file))
                    {
                        file = file.Substring(1);
                    }

                    lock (Lock)
                    {
                        return(Archives.ContainsKey(archive) ||
                               System.IO.File.Exists(archive));
                    }
                }
            }

            archive = string.Empty;
            file    = string.Empty;
            return(false);
        }
Пример #2
0
 public static bool IsValidArchive(string archive)
 {
     lock (Lock)
     {
         try
         {
             if (!Archives.ContainsKey(archive))
             {
                 GetArchive(archive);
             }
             return(true);
         }
         catch (InvalidOperationException)
         {
             return(false);
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Load a single bundle
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="ispatch"></param>
        public override void LoadArchive(string filename, bool ispatch = false)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }
            var bundle = new Archive(filename);

            foreach (KeyValuePair <ulong, ArchiveItem> item in bundle.Files)
            {
                // add new key if the file isn't already in another bundle
                if (!Items.ContainsKey(item.Key.ToString()))
                {
                    Items.Add(item.Key.ToString(), new List <IGameFile>());
                }
                Items[item.Key.ToString()].Add(item.Value);
            }
            Archives.Add(filename, bundle);
        }
Пример #4
0
        /// <summary>
        ///     Load a single soundcache
        /// </summary>
        /// <param name="filename"></param>
        public void LoadBundle(string filename)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }

            var bundle = new TextureCache(filename);

            foreach (var item in bundle.Files)
            {
                if (!Items.ContainsKey(item.Name))
                {
                    Items.Add(item.Name, new List <IWitcherFile>());
                }

                Items[item.Name].Add(item);
            }

            Archives.Add(filename, bundle);
        }
Пример #5
0
        /// <summary>
        ///     Load a single mod soundcache
        /// </summary>
        /// <param name="filename"></param>
        public void LoadModBundle(string filename)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }

            var bundle = new SoundCache(filename);

            foreach (var item in bundle.Files)
            {
                if (!Items.ContainsKey(GetModFolder(filename) + "\\" + item.Name))
                {
                    Items.Add(GetModFolder(filename) + "\\" + item.Name, new List <IWitcherFile>());
                }

                Items[GetModFolder(filename) + "\\" + item.Name].Add(item);
            }

            Archives.Add(filename, bundle);
        }
Пример #6
0
        /// <summary>
        ///     Load a single mod bundle
        /// </summary>
        /// <param name="filename">
        ///     file to process
        /// </param>
        public override void LoadModArchive(string filename)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }

            var bundle = new Archive(filename);

            foreach (var item in bundle.Files)
            {
                if (!Items.ContainsKey(GetModFolder(filename) + "\\" + item.Key))
                {
                    Items.Add(GetModFolder(filename) + "\\" + item.Key, new List <IGameFile>());
                }

                Items[GetModFolder(filename) + "\\" + item.Key].Add(item.Value);
            }

            Archives.Add(filename, bundle);
        }
Пример #7
0
        /// <summary>
        ///     Load a single soundcache
        /// </summary>
        /// <param name="filename"></param>
        private void LoadBundle(string filename)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }

            var bundle = new SoundCache(filename);

            foreach (var item in bundle.Files)
            {
                if (!Items.ContainsKey(item.Name))
                {
                    Items.Add(item.Name, new List <IGameFile>());
                }

                Items[item.Name].Add(item);
            }

            Archives.Add(filename, bundle);
        }