private static void UpdateFileFormat(string originalVoxFile)
        {
            var newFile = Path.ChangeExtension(originalVoxFile, MyVoxelConstants.FILE_EXTENSION);
            if (!File.Exists(originalVoxFile))
            {
                MySandboxGame.Log.WriteLine(string.Format("ERROR: Voxel file '{0}' does not exists!", originalVoxFile));
            }
            if (Path.GetExtension(originalVoxFile) != "vox")
            {
                MySandboxGame.Log.WriteLine(string.Format("ERROR: Unexpected voxel file extensions in path: '{0}'", originalVoxFile));
            }

            using (var decompressFile = new MyCompressionFileLoad(originalVoxFile))
            using (var file = MyFileSystem.OpenWrite(newFile))
            using (var gzip = new GZipStream(file, CompressionMode.Compress))
            using (var buffer = new BufferedStream(gzip))
            {
                buffer.WriteNoAlloc(STORAGE_TYPE_NAME_CELL);

                // File version. New format will store it in 7bit encoded int right after the name of storage.
                buffer.Write7BitEncodedInt(decompressFile.GetInt32());

                // All remaining data is unchanged. Just copy it to new file.
                byte[] tmp = new byte[0x4000];
                int bytesRead = decompressFile.GetBytes(tmp.Length, tmp);
                while (bytesRead != 0)
                {
                    buffer.Write(tmp, 0, bytesRead);
                    bytesRead = decompressFile.GetBytes(tmp.Length, tmp);
                }
            }
        }
        public void Save(out byte[] outCompressedData)
        {
            MyPrecalcComponent.AssertUpdateThread();

            ProfilerShort.Begin("MyStorageBase.Save");
            try
            {
                if (m_compressedData == null)
                {
                    MemoryStream ms;
                    using (ms = new MemoryStream(0x4000))
                    using (GZipStream gz = new GZipStream(ms, CompressionMode.Compress))
                    using (BufferedStream buf = new BufferedStream(gz, 0x4000))
                    {
                        string name;
                        int version;
                        if (GetType() == typeof(MyOctreeStorage))
                        {
                            name = STORAGE_TYPE_NAME_OCTREE;
                            version = STORAGE_TYPE_VERSION_OCTREE;
                        }
                        else
                        {
                            throw new InvalidBranchException();
                        }
                        buf.WriteNoAlloc(name);
                        buf.Write7BitEncodedInt(version);
                        SaveInternal(buf);
                    }
                    m_compressedData = ms.ToArray();
                }

                outCompressedData = m_compressedData;
            }
            finally
            {
                ProfilerShort.End();
            }
        }
        protected void SaveCompressedData(out byte[] compressedData)
        {
            MemoryStream ms;
            using (ms = new MemoryStream(0x4000))
            using (GZipStream gz = new GZipStream(ms, CompressionMode.Compress))
            using (BufferedStream buf = new BufferedStream(gz, 0x4000))
            {
                string name;
                int version;
                if (GetType() == typeof(MyOctreeStorage))
                {
                    name = STORAGE_TYPE_NAME_OCTREE;
                    version = STORAGE_TYPE_VERSION_OCTREE;
                }
                else
                {
                    throw new InvalidBranchException();
                }
                buf.WriteNoAlloc(name);
                buf.Write7BitEncodedInt(version);
                SaveInternal(buf);
            }

            compressedData = ms.ToArray();
        }
        public void Save(out byte[] outCompressedData)
        {
            Profiler.Begin("MyStorageBase.Save");
            try
            {
                if (m_compressedData == null)
                {
                    MemoryStream ms;
                    using (ms = new MemoryStream(0x4000))
                    using (GZipStream gz = new GZipStream(ms, CompressionMode.Compress))
                    using (BufferedStream buf = new BufferedStream(gz, 0x4000))
                    {
                        var attr = m_attributesByType[GetType()];
                        buf.WriteNoAlloc(attr.SerializedTypeName);
                        buf.Write7BitEncodedInt(attr.SerializedVersion);
                        SaveInternal(buf);
                    }
                    m_compressedData = ms.ToArray();
                }

                outCompressedData = m_compressedData;
            }
            finally
            {
                Profiler.End();
            }
        }