Kaydet (Commit) df391dc4 authored tarafından Rüdiger Timm's avatar Rüdiger Timm

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.
üst abb342de
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment