Exemplo n.º 1
0
        public static void BuildTileIndex(string cachePattern)
        {
            TileGuide fullGuide = new TileGuide();
            string    search    = Path.GetDirectoryName(String.Format(cachePattern, '*'));
            string    pattern   = Path.GetFileName(String.Format(cachePattern, '*'));

            try
            {
                foreach (string dir in PathMod.GetModFiles(search, pattern))
                {
                    string file = Path.GetFileNameWithoutExtension(dir);
                    using (FileStream stream = File.OpenRead(dir))
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                        {
                            TileIndexNode guide = TileIndexNode.Load(reader);
                            fullGuide.Nodes[file] = guide;
                        }
                    }
                }

                using (FileStream stream = new FileStream(PathMod.HardMod(search + "/index.idx"), FileMode.Create, FileAccess.Write))
                {
                    using (BinaryWriter writer = new BinaryWriter(stream))
                        fullGuide.Save(writer);
                }
            }
            catch (Exception ex)
            {
                DiagManager.Instance.LogError(new Exception("Error importing index at " + search + "\n", ex));
            }
        }