diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-09-15 09:44:06 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-15 11:23:37 +0100 |
commit | 22eb754f613fdaa0c90f9c98a4373e6f7faa0a99 (patch) | |
tree | 1d6f63bc227a4a1f0ae2e257281431aa270ac52d /basic/source/runtime/iosys.cxx | |
parent | 565587eba10a8c4e01d4346669327bd9065c5dfa (diff) |
replace ByteString::Fill
Diffstat (limited to 'basic/source/runtime/iosys.cxx')
-rw-r--r-- | basic/source/runtime/iosys.cxx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx index 7f4274cba9fc..5b57527cb8ce 100644 --- a/basic/source/runtime/iosys.cxx +++ b/basic/source/runtime/iosys.cxx @@ -45,6 +45,7 @@ #include <ctype.h> #include <rtl/byteseq.hxx> #include <rtl/textenc.h> +#include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/textenc.h> #include <rtl/ustrbuf.hxx> @@ -652,11 +653,21 @@ SbError SbiStream::Read( ByteString& rBuf, sal_uInt16 n, bool bForceReadingPerBy } else { - if( !n ) n = nLen; + if( !n ) + n = nLen; if( !n ) return nError = SbERR_BAD_RECORD_LENGTH; - rBuf.Fill( n, ' ' ); - pStrm->Read( (void*)rBuf.GetBuffer(), n ); + rtl::OStringBuffer aBuffer(read_uInt8s_AsOString(*pStrm, n)); + //Pad it out with ' ' to the requested length on short read + sal_Int32 nRead = aBuffer.getLength(); + sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(n); + if (nRead < nRequested) + { + aBuffer.setLength(nRequested); + for (sal_Int32 i = nRead; i < nRequested; ++i) + aBuffer.setCharAt(i, ' '); + } + rBuf = aBuffer.makeStringAndClear(); } MapError(); if( !nError && pStrm->IsEof() ) |