diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-11-26 13:42:49 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-11-26 13:42:49 +0000 |
commit | df391dc4ea4ac9b500c81c4a38e7096df2c702b3 (patch) | |
tree | 9536a9bfe5c3826609f9af21371b0c4c2f3df06e /ucb | |
parent | abb342de2d3d12eb061147fa4d52300967114c81 (diff) |
INTEGRATION: CWS sb26 (1.80.22); FILE MERGED
2004/11/23 16:10:57 sb 1.80.22.1: #i37704# Get rid of unnecessary calls to osl_syncFile.
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/file/shell.cxx | 144 |
1 files changed, 70 insertions, 74 deletions
diff --git a/ucb/source/ucp/file/shell.cxx b/ucb/source/ucp/file/shell.cxx index 0b2187a25c65..3bbe030f406e 100644 --- a/ucb/source/ucp/file/shell.cxx +++ b/ucb/source/ucp/file/shell.cxx @@ -2,9 +2,9 @@ * * $RCSfile: shell.cxx,v $ * - * $Revision: 1.81 $ + * $Revision: 1.82 $ * - * last change: $Author: obo $ $Date: 2004-11-17 09:56:50 $ + * last change: $Author: rt $ $Date: 2004-11-26 14:42:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1828,6 +1828,13 @@ shell::write( sal_Int32 CommandId, const uno::Reference< io::XInputStream >& aInputStream ) throw() { + if( ! aInputStream.is() ) + { + installError( CommandId, + TASKHANDLING_INPUTSTREAM_FOR_WRITE ); + return sal_False; + } + // Create parent path, if necessary. if ( ! ensuredir( CommandId, getParentName( aUnqPath ), @@ -1881,96 +1888,85 @@ shell::write( sal_Int32 CommandId, sal_Bool bSuccess = sal_True; - if( ! aInputStream.is() ) - { - installError( CommandId, - TASKHANDLING_INPUTSTREAM_FOR_WRITE ); - bSuccess = sal_False; - } - else + sal_uInt64 nTotalNumberOfBytes = 0; + sal_uInt64 nWrittenBytes; + sal_Int32 nReadBytes = 0, nRequestedBytes = 32768 /*32k*/; + uno::Sequence< sal_Int8 > seq( nRequestedBytes ); + + do { - sal_uInt64 nTotalNumberOfBytes = 0; - sal_uInt64 nWrittenBytes; - sal_Int32 nReadBytes = 0, nRequestedBytes = 32768 /*32k*/; - uno::Sequence< sal_Int8 > seq( nRequestedBytes ); + try + { + nReadBytes = aInputStream->readBytes( seq, + nRequestedBytes ); + } + catch( const io::NotConnectedException& ) + { + installError( CommandId, + TASKHANDLING_NOTCONNECTED_FOR_WRITE ); + bSuccess = sal_False; + break; + } + catch( const io::BufferSizeExceededException& ) + { + installError( CommandId, + TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE ); + bSuccess = sal_False; + break; + } + catch( const io::IOException& ) + { + installError( CommandId, + TASKHANDLING_IOEXCEPTION_FOR_WRITE ); + bSuccess = sal_False; + break; + } - do + if( nReadBytes ) { - try - { - nReadBytes = aInputStream->readBytes( seq, - nRequestedBytes ); - } - catch( const io::NotConnectedException& ) - { - installError( CommandId, - TASKHANDLING_NOTCONNECTED_FOR_WRITE ); - bSuccess = sal_False; - break; - } - catch( const io::BufferSizeExceededException& ) + const sal_Int8* p = seq.getConstArray(); + + err = aFile.write( ((void*)(p)), + sal_uInt64( nReadBytes ), + nWrittenBytes ); + + if( err != osl::FileBase::E_None ) { installError( CommandId, - TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE ); + TASKHANDLING_FILEIOERROR_FOR_WRITE, + err ); bSuccess = sal_False; break; } - catch( const io::IOException& ) + else if( nWrittenBytes != sal_uInt64( nReadBytes ) ) { installError( CommandId, - TASKHANDLING_IOEXCEPTION_FOR_WRITE ); + TASKHANDLING_FILEIOERROR_FOR_NO_SPACE ); bSuccess = sal_False; break; } - if( nReadBytes ) - { - const sal_Int8* p = seq.getConstArray(); - - err = aFile.write( ((void*)(p)), - sal_uInt64( nReadBytes ), - nWrittenBytes ); - - if( err != osl::FileBase::E_None ) - { - installError( CommandId, - TASKHANDLING_FILEIOERROR_FOR_WRITE, - err ); - bSuccess = sal_False; - break; - } - else if( nWrittenBytes != sal_uInt64( nReadBytes ) ) - { - installError( CommandId, - TASKHANDLING_FILEIOERROR_FOR_NO_SPACE ); - bSuccess = sal_False; - break; - } - - nTotalNumberOfBytes += nWrittenBytes; - } - } while( sal_uInt64( nReadBytes ) == nRequestedBytes ); - - err = aFile.setSize( nTotalNumberOfBytes ); - if( err != osl::FileBase::E_None ) - { - installError( CommandId, - TASKHANDLING_FILESIZE_FOR_WRITE, - err ); - bSuccess = sal_False; + nTotalNumberOfBytes += nWrittenBytes; } + } while( sal_uInt64( nReadBytes ) == nRequestedBytes ); - err = aFile.sync(); - if( err != osl::FileBase::E_None ) - { - installError( CommandId, - TASKHANDLING_FILEIOERROR_FOR_WRITE, - err ); - bSuccess = sal_False; - } + err = aFile.setSize( nTotalNumberOfBytes ); + if( err != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_FILESIZE_FOR_WRITE, + err ); + bSuccess = sal_False; } - aFile.close(); + err = aFile.close(); + if( err != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_FILEIOERROR_FOR_WRITE, + err ); + bSuccess = sal_False; + } return bSuccess; } |