/// <summary>
        /// Распаковывает все текстуры (*.gtatexture) в directoryPath (и подкаталогах).
        /// Распакованные изображения сохраняются рядом в файл с таким же именем и одним из графических расширений.
        /// </summary>
        public static void UnpackAllTextures(string directoryPath)
        {
            int success = 0, fail = 0;
             using (Log.Instance.EnterStage("Unpacking all textures in directory " + directoryPath))
             {
            foreach (var file in Directory.GetFiles(directoryPath, "*.gtatexture", SearchOption.AllDirectories))
            {
               try
               {
                  using (Log.Instance.EnterStage("Unpacking texture: " + file.Substring(directoryPath.Length)))
                  {
                     GTATextureLoader textureLoader = new GTATextureLoader(new BinaryReader(new FileStream(file, FileMode.Open)));
                     Texture2D texture = textureLoader.Load();
                     texture.Save(file.Substring(0, file.LastIndexOf('.')) + ".png", ImageFileFormat.Png);

                     ++success;
                     Log.Instance.Print("success!");
                  }
               }
               catch (Exception er)
               {
                  Log.Instance.Print("Failed to load texture. Exception: " + er.Message, MessageType.Error);
                  ++fail;
               }
            }
             }
             Log.Instance.Print(String.Format("Finished textures processing. Successes: {0}, failes: {1}", success, fail));
        }
        void ReadTexture(int size, SectionType type)
        {
            int position = (int)fin.BaseStream.Position;
             fin.BaseStream.Seek(8, SeekOrigin.Current);

             byte[] diffuseTextureName = new byte[32];
             byte[] alphaTextureName = new byte[32];
             fin.Read(diffuseTextureName, 0, diffuseTextureName.Length);
             fin.Read(alphaTextureName, 0, alphaTextureName.Length);

             var texture = new GTATextureLoader(fin).Load();

             Func<byte[], string> ToFullName = delegate(byte[] name)
             {
            int nilIdx = Array.IndexOf(name, (byte)0);
            int nameLen = nilIdx == -1 ? name.Length : nilIdx;
            return (txdName + "/" + Encoding.ASCII.GetString(name, 0, nameLen) + ".gtatexture").ToLower();
             };

             files[ToFullName(diffuseTextureName)] = texture;

             if (alphaTextureName[0] != 0)
            files[ToFullName(alphaTextureName)] = texture;

             ++processedTextures;
        }