File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
MLAPI/NetworkingManagerComponents/Binary Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -625,6 +625,29 @@ public override void WriteByte(byte value)
625
625
_WriteByte ( value ) ;
626
626
UpdateLength ( ) ;
627
627
}
628
+ /// <summary>
629
+ /// Copy data from another stream
630
+ /// </summary>
631
+ /// <param name="s">Stream to copy from</param>
632
+ /// <param name="count">How many bytes to read. Set to value less than one to read until ReadByte returns -1</param>
633
+ public void CopyFrom ( Stream s , int count = - 1 )
634
+ {
635
+ if ( s is BitStream b )
636
+ {
637
+ ulong bytes = b . BitLength >> 3 ;
638
+ Write ( b . target , 0 , ( int ) bytes ) ;
639
+ if ( ( b . BitLength & 7 ) != 0 ) _WriteBits ( b . target [ bytes - 1 ] , ( int ) ( b . BitLength & 7 ) ) ;
640
+ }
641
+ else
642
+ {
643
+ int read ;
644
+ bool readToEnd = count < 0 ;
645
+ while ( ( readToEnd || count -- > 0 ) && ( read = s . ReadByte ( ) ) != - 1 )
646
+ _WriteIntByte ( read ) ;
647
+ }
648
+
649
+ UpdateLength ( ) ;
650
+ }
628
651
629
652
/// <summary>
630
653
/// Update length of data considered to be "written" to the stream.
You can’t perform that action at this time.
0 commit comments