public void Read() { SAUCE.Record record = new SAUCE.Record(); record.Read( (string) resources[ "W7-R666.ANS" ] ); Assert.AreEqual( "SAUCE", record.ID ); Assert.AreEqual( "00", record.Version ); Assert.AreEqual( "Route 666", record.Title ); Assert.AreEqual( "White Trash", record.Author ); Assert.AreEqual( "ACiD Productions", record.Group ); Assert.AreEqual( "19970401", record.Date ); Assert.AreEqual( 42990, record.Filesize ); Assert.AreEqual( 1, record.DatatypeID ); Assert.AreEqual( 1, record.FiletypeID ); Assert.AreEqual( 80, record.Tinfo1 ); Assert.AreEqual( 180, record.Tinfo2 ); Assert.AreEqual( 0, record.Tinfo3 ); Assert.AreEqual( 0, record.Tinfo4 ); Assert.AreEqual( 4, record.CommentCount ); Assert.AreEqual( 0, record.Flags ); Assert.AreEqual( "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", record.Filler ); Assert.AreEqual( new string[4] { "To purchase your white trash ansi: send cash/check to", "keith nadolny / 41 loretto drive / cheektowaga, ny / 14225", "make checks payable to keith nadolny/us funds only", "5 dollars = 100 lines - 10 dollars = 200 lines" }, record.Comments ); }
public void Remove() { string filename = (string) resources[ "W7-R666.ANS" ]; FileInfo info = new FileInfo( filename ); long filesize_before = info.Length; SAUCE.Record record = new SAUCE.Record(); record.Remove( filename ); info.Refresh(); Assert.AreEqual( filesize_before - 1 - 128 - 5 - (4 * 64), info.Length ); }
public void Write( string filename ) { SAUCE.Record record = new SAUCE.Record(); try { record.Read( filename ); } catch { } if( record.ID == "SAUCE" ) { this.Remove( filename ); } FileStream fs = new FileStream( filename, FileMode.Open ); BinaryWriter writer = new BinaryWriter( fs ); writer.Write( "\x26".ToCharArray() ); if( this.Comments.Length > 0 ) { writer.Write( COMNT_ID.ToCharArray() ); foreach( string comment in this.Comments ) { writer.Write( comment.PadRight( 64 ).ToCharArray() ); } } writer.Write( SAUCE_ID.ToCharArray() ); writer.Write( this.Version.ToCharArray() ); writer.Write( this.Title.PadRight( 35 ).ToCharArray() ); writer.Write( this.Author.PadRight( 20 ).ToCharArray() ); writer.Write( this.Group.PadRight( 20 ).ToCharArray() ); writer.Write( this.Date.ToCharArray() ); writer.Write( (UInt32) this.Filesize ); writer.Write( this.DatatypeID ); writer.Write( this.FiletypeID ); writer.Write( (UInt16) this.Tinfo1 ); writer.Write( (UInt16) this.Tinfo2 ); writer.Write( (UInt16) this.Tinfo3 ); writer.Write( (UInt16) this.Tinfo4 ); writer.Write( (Byte) this.Comments.Length ); writer.Write( this.Flags ); writer.Write( this.Filler.ToCharArray() ); writer.Close(); }
public void Remove( string filename ) { SAUCE.Record record = new SAUCE.Record(); record.Read( filename ); if( record.ID != "SAUCE" ) { return; } BinaryWriter writer = new BinaryWriter( new FileStream( filename, FileMode.Open ) ); writer.BaseStream.SetLength( record.Filesize ); writer.Close(); }