示例#1
0
        internal void Save(Stream stream, string fileName)
        {
            ExceptionUtilities.HandleRecoverableIOException(
                () =>
            {
                // We don't have anything in particular to correlate this file to,
                // so we are simply creating a unique correlation id that is used as part
                // of the header consistency check.
                FileEnvelopeId correlationId = FileEnvelopeId.Create();
                s_fileEnvelope.WriteHeader(stream, correlationId);

                using (BuildXLWriter writer = new BuildXLWriter(debug: false, stream: stream, leaveOpen: true, logStats: false))
                {
                    m_pathTable.StringTable.Serialize(writer);
                    m_pathTable.Serialize(writer);

                    writer.Write(m_pathMapping.Count);

                    foreach (var kvp in m_pathMapping)
                    {
                        writer.Write(kvp.Key);
                        writer.Write(kvp.Value);
                    }
                }

                s_fileEnvelope.FixUpHeader(stream, correlationId);
                return((object)null);
            },
                ex => { throw new BuildXLException(I($"Failed to write to '{fileName}'"), ex); });
        }