diff options
author | Hans-Joachim Lankenau <hjs@openoffice.org> | 2010-12-17 17:08:13 +0100 |
---|---|---|
committer | Hans-Joachim Lankenau <hjs@openoffice.org> | 2010-12-17 17:08:13 +0100 |
commit | e700990dc06cbfaedf796358c2acbbe9a57de276 (patch) | |
tree | ba67c07000df1bde0b28b744927b58faca6e848a /ucb | |
parent | f2132e7a6d2207dc01a2e78cc66f2c3cc7dd69ef (diff) | |
parent | 4a10568519d12734fd6ba14bf299e40bc7e39336 (diff) |
CWS-TOOLING: integrate CWS fwk160
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/file/shell.cxx | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/ucb/source/ucp/file/shell.cxx b/ucb/source/ucp/file/shell.cxx index c0ce3bebad..52f88a4807 100644 --- a/ucb/source/ucp/file/shell.cxx +++ b/ucb/source/ucp/file/shell.cxx @@ -1805,14 +1805,26 @@ shell::write( sal_Int32 CommandId, { aFile.close(); err = aFile.open( OpenFlag_Write ); - } - if( err != osl::FileBase::E_None ) - { - installError( CommandId, - TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE, - err ); - return sal_False; + if( err != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE, + err ); + return sal_False; + } + + // the existing file was just opened and should be overwritten now, + // truncate it first + + err = aFile.setSize( 0 ); + if( err != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_FILESIZE_FOR_WRITE, + err ); + return sal_False; + } } } else @@ -1844,7 +1856,6 @@ shell::write( sal_Int32 CommandId, sal_Bool bSuccess = sal_True; - sal_uInt64 nTotalNumberOfBytes = 0; sal_uInt64 nWrittenBytes; sal_Int32 nReadBytes = 0, nRequestedBytes = 32768 /*32k*/; uno::Sequence< sal_Int8 > seq( nRequestedBytes ); @@ -1901,20 +1912,9 @@ shell::write( sal_Int32 CommandId, bSuccess = sal_False; break; } - - nTotalNumberOfBytes += nWrittenBytes; } } while( nReadBytes == nRequestedBytes ); - err = aFile.setSize( nTotalNumberOfBytes ); - if( err != osl::FileBase::E_None ) - { - installError( CommandId, - TASKHANDLING_FILESIZE_FOR_WRITE, - err ); - bSuccess = sal_False; - } - err = aFile.close(); if( err != osl::FileBase::E_None ) { |