Exemplo n.º 1
0
        private void InnerWriteToBinary(string binFileName)
        {
            using (MemoryStream corruptPreventStream = new MemoryStream())
            {
                BinaryWriterEx bw = new BinaryWriterEx(false, corruptPreventStream);

                bw.WriteASCII("ESD_META", terminate: false);
                bw.WriteInt64(CURRENT_BINARY_VERSION);
                bw.WriteASCII(ESDHash, terminate: true);
                bw.WriteInt32(StateGroupNames.Count);
                foreach (var g in StateGroupNames.Keys)
                {
                    bw.WriteInt64(g);
                    bw.WriteShiftJIS(StateGroupNames[g], terminate: true);
                    bw.WriteInt32(StateMetadatas[g].Count);
                    foreach (var kvp in StateMetadatas[g])
                    {
                        bw.WriteInt64(kvp.Key);
                        bw.WriteShiftJIS(kvp.Value.Name, terminate: true);
                        bw.WriteShiftJIS(kvp.Value.EntryScript, terminate: true);
                        bw.WriteShiftJIS(kvp.Value.ExitScript, terminate: true);
                        bw.WriteShiftJIS(kvp.Value.WhileScript, terminate: true);
                    }
                }
                bw.WriteInt32(ConditionMetadatas.Count);
                foreach (var c in ConditionMetadatas)
                {
                    bw.WriteInt64(c.Key);
                    bw.WriteShiftJIS(c.Value.Name, terminate: true);
                    bw.WriteShiftJIS(c.Value.Evaluator, terminate: true);
                    bw.WriteShiftJIS(c.Value.PassScript, terminate: true);
                }

                corruptPreventStream.Position = 0;

                using (FileStream actualFileStream = File.Create(binFileName))
                {
                    corruptPreventStream.CopyTo(actualFileStream);
                }

                bw.Finish();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes this ESD file to the specified path, saving its metadata to "&lt;ESDFileName&gt;.meta".
        /// </summary>
        public void WriteWithMetadata(string path, bool isBinaryMetadata, EzSembleContext context)
        {
            using (MemoryStream corruptPreventStream = new MemoryStream())
            {
                BinaryWriterEx bw = new BinaryWriterEx(false, corruptPreventStream);
                WriteWithContext(bw, context);

                corruptPreventStream.Position = 0;

                using (FileStream actualFileStream = File.Create(path))
                {
                    corruptPreventStream.CopyTo(actualFileStream);
                }

                bw.Finish();
            }

            SaveMetadataFile(path + ".meta", isBinaryMetadata);
        }