Mercurial > projects > mde
diff mde/file/mergetag/Writer.d @ 85:56c0ddd90193
Intermediate commit (not stable). Changes to init system.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 11 Sep 2008 11:33:51 +0100 |
parents | ac1e3fd07275 |
children | 79d816b3e2d2 |
line wrap: on
line diff
--- a/mde/file/mergetag/Writer.d Sun Aug 31 15:59:17 2008 +0100 +++ b/mde/file/mergetag/Writer.d Thu Sep 11 11:33:51 2008 +0100 @@ -36,7 +36,7 @@ // tango imports import tango.core.Exception; -import tango.io.FileConduit; +import tango.io.device.FileConduit; import tango.io.Buffer : Buffer, IBuffer; import tango.io.Print : Print; import convInt = tango.text.convert.Integer; @@ -162,6 +162,8 @@ public this (char[] path, DataSet ds = null) { _path = path; _dataset = ds; + foreach (i,s; _dataset.sec) + debug logger.trace ("sec ID length: {}", i.length); } //END CTOR / DTOR @@ -178,28 +180,38 @@ if (!_dataset) throwMTErr ("write(): no Dataset available to write from!", new MTNoDataSetException ()); try { + debug logger.trace ("W.w: 1"); FileConduit conduit; // actual conduit; don't use directly when there's content in the buffer IBuffer buffer; // write strings directly to this (use opCall(void[]) ) + debug logger.trace ("W.w: 2"); // Open a conduit on the file: conduit = new FileConduit (_path, FileConduit.WriteCreate); scope(exit) conduit.close(); + debug logger.trace ("W.w: 3"); buffer = new Buffer(conduit); // And a buffer scope(exit) buffer.flush(); + debug logger.trace ("W.w: 4"); // Write the header: buffer ("{MT" ~ MTFormatVersion.CurrentString ~ "}" ~ Eol); + debug logger.trace ("W.w: 5"); if (_dataset.header !is null) writeSection (buffer, _dataset.header); + debug logger.trace ("W.w: 6"); // Write the rest: foreach (ID id, IDataSection sec; _dataset.sec) { + debug logger.trace ("W.w: 71"); writeSectionIdentifier (buffer, id); + debug logger.trace ("W.w: 72"); writeSection (buffer, sec); } - + + debug logger.trace ("W.w: 8"); buffer.flush(); + debug logger.trace ("W.w: 9"); } catch (IOException e) { throwMTErr ("Error writing to file: " ~ e.msg, new MTFileIOException); @@ -210,7 +222,14 @@ } private void writeSectionIdentifier (IBuffer buffer, ID id) { - buffer ("{" ~ cast(char[])id ~ "}" ~ Eol); + debug logger.trace ("W.wSI: 0"); + debug logger.trace ("W.wSI: id ({})",id.length); + debug logger.trace ("W.wSI: Eol ({})",Eol.length); + char[] tp = "{" ~ cast(char[])id ~ "}" ~ Eol; + debug logger.trace ("W.wSI: 0.1"); + debug logger.trace ("W.wSI: string ({}): {}",tp.length, tp); + buffer (tp); + debug logger.trace ("W.wSI: 1"); } private void writeSection (IBuffer buffer, IDataSection sec) {