static void Main(string[] args) { var inputFile = args[0]; var outputFile = args[1]; // Parse the input file RawFlatFile rff; using (var stream = new FileStream(inputFile, FileMode.Open)) rff = new RawFlatFile(stream); // Write the compressed output file using (var stream = new FileStream(outputFile, FileMode.Create)) using (var writer = new BinaryWriter(stream)) writer.Write(rff); }
/// <summary> Writes a raw flat-file to the output. </summary> /// <remarks> /// Assumes that <see cref="RawFlatFile.ThrowIfInconsistent"/> does not /// throw on <paramref name="rff"/>. /// </remarks> public static void Write(this BinaryWriter writer, RawFlatFile rff) { // Header: version & size information writer.Write(VersionNumber); writer.Write((ushort)rff.Columns); writer.Write((uint)rff.Cells.Count); writer.Write((uint)rff.Content.Count); // Cell data: integer references to indices in 'content' foreach (var cell in rff.Cells) { WriteInt(writer, cell); } // Content data: byte arrays of specific sizes. foreach (var bytes in rff.Content) { WriteInt(writer, bytes.Length); writer.Write(bytes); } }