Changeset 291 for CoolStreaming/UStreamHelper.pas
- Timestamp:
- Nov 4, 2011, 11:46:15 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolStreaming/UStreamHelper.pas
r269 r291 39 39 function ReadCardinal: Cardinal; 40 40 function ReadInt64: Int64; 41 function ReadString : string;41 function ReadString(Length: Integer): string; 42 42 function ReadShortString: string; 43 43 function ReadAnsiString: string; … … 73 73 begin 74 74 FStream.ReadBuffer(StringLength, SizeOf(StringLength)); 75 SetLength(Result, StringLength); 76 if StringLength > 0 then begin 77 FStream.ReadBuffer(Result[1], StringLength); 78 end; 75 Result := ReadString(StringLength); 79 76 end; 80 77 … … 119 116 end; 120 117 121 function TStreamHelper.ReadString :string;122 begin 123 SetLength(Result, FStream.Size - FStream.Position);124 if (FStream.Size - FStream.Position) > 0 then125 FStream.Read(Result[1], FStream.Size - FStream.Position)126 118 function TStreamHelper.ReadString(Length: Integer): string; 119 begin 120 if Length > 0 then begin 121 SetLength(Result, Length); 122 FStream.Read(Result[1], Length); 123 end else Result := ''; 127 124 end; 128 125 … … 132 129 begin 133 130 FStream.ReadBuffer(Count, 1); 134 SetLength(Result, Count); 135 FStream.ReadBuffer(Result[1], Count); 131 Result := ReadString(Count); 136 132 end; 137 133
Note:
See TracChangeset
for help on using the changeset viewer.