1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_ucb.hxx" 30*cdf0e10cSrcweir #include "com/sun/star/io/IOException.hpp" 31*cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp" 32*cdf0e10cSrcweir #include "osl/diagnose.h" 33*cdf0e10cSrcweir #include "filstr.hxx" 34*cdf0e10cSrcweir #include "shell.hxx" 35*cdf0e10cSrcweir #include "prov.hxx" 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir using namespace fileaccess; 39*cdf0e10cSrcweir using namespace com::sun::star; 40*cdf0e10cSrcweir using namespace com::sun::star::ucb; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir /******************************************************************************/ 45*cdf0e10cSrcweir /* */ 46*cdf0e10cSrcweir /* XStream_impl implementation */ 47*cdf0e10cSrcweir /* */ 48*cdf0e10cSrcweir /******************************************************************************/ 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir uno::Any SAL_CALL 52*cdf0e10cSrcweir XStream_impl::queryInterface( 53*cdf0e10cSrcweir const uno::Type& rType ) 54*cdf0e10cSrcweir throw( uno::RuntimeException) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir uno::Any aRet = cppu::queryInterface( rType, 57*cdf0e10cSrcweir SAL_STATIC_CAST( lang::XTypeProvider*,this ), 58*cdf0e10cSrcweir SAL_STATIC_CAST( io::XStream*,this ), 59*cdf0e10cSrcweir SAL_STATIC_CAST( io::XInputStream*,this ), 60*cdf0e10cSrcweir SAL_STATIC_CAST( io::XOutputStream*,this ), 61*cdf0e10cSrcweir SAL_STATIC_CAST( io::XSeekable*,this ), 62*cdf0e10cSrcweir SAL_STATIC_CAST( io::XTruncate*,this ), 63*cdf0e10cSrcweir SAL_STATIC_CAST( io::XAsyncOutputMonitor*,this ) ); 64*cdf0e10cSrcweir return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir void SAL_CALL 69*cdf0e10cSrcweir XStream_impl::acquire( 70*cdf0e10cSrcweir void ) 71*cdf0e10cSrcweir throw() 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir OWeakObject::acquire(); 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir void SAL_CALL 78*cdf0e10cSrcweir XStream_impl::release( 79*cdf0e10cSrcweir void ) 80*cdf0e10cSrcweir throw() 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir OWeakObject::release(); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 87*cdf0e10cSrcweir // XTypeProvider 88*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////// 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_7( XStream_impl, 92*cdf0e10cSrcweir lang::XTypeProvider, 93*cdf0e10cSrcweir io::XStream, 94*cdf0e10cSrcweir io::XSeekable, 95*cdf0e10cSrcweir io::XInputStream, 96*cdf0e10cSrcweir io::XOutputStream, 97*cdf0e10cSrcweir io::XTruncate, 98*cdf0e10cSrcweir io::XAsyncOutputMonitor ) 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir XStream_impl::XStream_impl( shell* pMyShell,const rtl::OUString& aUncPath, sal_Bool bLock ) 103*cdf0e10cSrcweir : m_bInputStreamCalled( false ), 104*cdf0e10cSrcweir m_bOutputStreamCalled( false ), 105*cdf0e10cSrcweir m_pMyShell( pMyShell ), 106*cdf0e10cSrcweir m_xProvider( m_pMyShell->m_pProvider ), 107*cdf0e10cSrcweir m_bLock( bLock ), 108*cdf0e10cSrcweir m_aFile( aUncPath ), 109*cdf0e10cSrcweir m_nErrorCode( TASKHANDLER_NO_ERROR ), 110*cdf0e10cSrcweir m_nMinorErrorCode( TASKHANDLER_NO_ERROR ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir sal_uInt32 nFlags = ( OpenFlag_Read | OpenFlag_Write ); 113*cdf0e10cSrcweir if ( !bLock ) 114*cdf0e10cSrcweir nFlags |= OpenFlag_NoLock; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir osl::FileBase::RC err = m_aFile.open( nFlags ); 117*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir m_nIsOpen = false; 120*cdf0e10cSrcweir m_aFile.close(); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir m_nErrorCode = TASKHANDLING_OPEN_FOR_STREAM; 123*cdf0e10cSrcweir m_nMinorErrorCode = err; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir else 126*cdf0e10cSrcweir m_nIsOpen = true; 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir XStream_impl::~XStream_impl() 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir try 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir closeStream(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir catch (io::IOException const &) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir OSL_ENSURE(false, "unexpected situation"); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir catch (uno::RuntimeException const &) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir OSL_ENSURE(false, "unexpected situation"); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir sal_Int32 SAL_CALL XStream_impl::CtorSuccess() 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir return m_nErrorCode; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir sal_Int32 SAL_CALL XStream_impl::getMinorError() 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir return m_nMinorErrorCode; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir uno::Reference< io::XInputStream > SAL_CALL 162*cdf0e10cSrcweir XStream_impl::getInputStream( ) 163*cdf0e10cSrcweir throw( uno::RuntimeException) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 167*cdf0e10cSrcweir m_bInputStreamCalled = true; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir return uno::Reference< io::XInputStream >( this ); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir uno::Reference< io::XOutputStream > SAL_CALL 174*cdf0e10cSrcweir XStream_impl::getOutputStream( ) 175*cdf0e10cSrcweir throw( uno::RuntimeException ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 179*cdf0e10cSrcweir m_bOutputStreamCalled = true; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir return uno::Reference< io::XOutputStream >( this ); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void SAL_CALL XStream_impl::truncate(void) 186*cdf0e10cSrcweir throw( io::IOException, uno::RuntimeException ) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir if (osl::FileBase::E_None != m_aFile.setSize(0)) 189*cdf0e10cSrcweir throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir if (osl::FileBase::E_None != m_aFile.setPos(Pos_Absolut,sal_uInt64(0))) 192*cdf0e10cSrcweir throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir //=========================================================================== 198*cdf0e10cSrcweir // XStream_impl private non interface methods 199*cdf0e10cSrcweir //=========================================================================== 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir sal_Int32 SAL_CALL 202*cdf0e10cSrcweir XStream_impl::readBytes( 203*cdf0e10cSrcweir uno::Sequence< sal_Int8 >& aData, 204*cdf0e10cSrcweir sal_Int32 nBytesToRead ) 205*cdf0e10cSrcweir throw( io::NotConnectedException, 206*cdf0e10cSrcweir io::BufferSizeExceededException, 207*cdf0e10cSrcweir io::IOException, 208*cdf0e10cSrcweir uno::RuntimeException) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir if( ! m_nIsOpen ) 211*cdf0e10cSrcweir throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir sal_Int8 * buffer; 214*cdf0e10cSrcweir try 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir buffer = new sal_Int8[nBytesToRead]; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir catch( std::bad_alloc ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir if( m_nIsOpen ) m_aFile.close(); 221*cdf0e10cSrcweir throw io::BufferSizeExceededException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir sal_uInt64 nrc(0); 225*cdf0e10cSrcweir if(m_aFile.read( (void* )buffer,sal_uInt64(nBytesToRead),nrc ) 226*cdf0e10cSrcweir != osl::FileBase::E_None) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir delete[] buffer; 229*cdf0e10cSrcweir throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir aData = uno::Sequence< sal_Int8 > ( buffer, (sal_uInt32)nrc ); 232*cdf0e10cSrcweir delete[] buffer; 233*cdf0e10cSrcweir return ( sal_Int32 ) nrc; 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir sal_Int32 SAL_CALL 238*cdf0e10cSrcweir XStream_impl::readSomeBytes( 239*cdf0e10cSrcweir uno::Sequence< sal_Int8 >& aData, 240*cdf0e10cSrcweir sal_Int32 nMaxBytesToRead ) 241*cdf0e10cSrcweir throw( io::NotConnectedException, 242*cdf0e10cSrcweir io::BufferSizeExceededException, 243*cdf0e10cSrcweir io::IOException, 244*cdf0e10cSrcweir uno::RuntimeException) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir return readBytes( aData,nMaxBytesToRead ); 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir void SAL_CALL 251*cdf0e10cSrcweir XStream_impl::skipBytes( 252*cdf0e10cSrcweir sal_Int32 nBytesToSkip ) 253*cdf0e10cSrcweir throw( io::NotConnectedException, 254*cdf0e10cSrcweir io::BufferSizeExceededException, 255*cdf0e10cSrcweir io::IOException, 256*cdf0e10cSrcweir uno::RuntimeException ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir m_aFile.setPos( osl_Pos_Current, sal_uInt64( nBytesToSkip ) ); 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir sal_Int32 SAL_CALL 263*cdf0e10cSrcweir XStream_impl::available( 264*cdf0e10cSrcweir void ) 265*cdf0e10cSrcweir throw( io::NotConnectedException, 266*cdf0e10cSrcweir io::IOException, 267*cdf0e10cSrcweir uno::RuntimeException) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir return 0; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir void SAL_CALL 274*cdf0e10cSrcweir XStream_impl::writeBytes( const uno::Sequence< sal_Int8 >& aData ) 275*cdf0e10cSrcweir throw( io::NotConnectedException, 276*cdf0e10cSrcweir io::BufferSizeExceededException, 277*cdf0e10cSrcweir io::IOException, 278*cdf0e10cSrcweir uno::RuntimeException) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir sal_uInt32 length = aData.getLength(); 281*cdf0e10cSrcweir if(length) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir sal_uInt64 nWrittenBytes(0); 284*cdf0e10cSrcweir const sal_Int8* p = aData.getConstArray(); 285*cdf0e10cSrcweir if(osl::FileBase::E_None != m_aFile.write(((void*)(p)),sal_uInt64(length),nWrittenBytes) || 286*cdf0e10cSrcweir nWrittenBytes != length ) 287*cdf0e10cSrcweir throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir void SAL_CALL 293*cdf0e10cSrcweir XStream_impl::closeStream( 294*cdf0e10cSrcweir void ) 295*cdf0e10cSrcweir throw( io::NotConnectedException, 296*cdf0e10cSrcweir io::IOException, 297*cdf0e10cSrcweir uno::RuntimeException ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir if( m_nIsOpen ) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir osl::FileBase::RC err = m_aFile.close(); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir if( err != osl::FileBase::E_None ) { 304*cdf0e10cSrcweir io::IOException ex; 305*cdf0e10cSrcweir ex.Message = rtl::OUString::createFromAscii( 306*cdf0e10cSrcweir "could not close file"); 307*cdf0e10cSrcweir throw ex; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir m_nIsOpen = false; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir void SAL_CALL 315*cdf0e10cSrcweir XStream_impl::closeInput( 316*cdf0e10cSrcweir void ) 317*cdf0e10cSrcweir throw( io::NotConnectedException, 318*cdf0e10cSrcweir io::IOException, 319*cdf0e10cSrcweir uno::RuntimeException ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 322*cdf0e10cSrcweir m_bInputStreamCalled = false; 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir if( ! m_bOutputStreamCalled ) 325*cdf0e10cSrcweir closeStream(); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir void SAL_CALL 330*cdf0e10cSrcweir XStream_impl::closeOutput( 331*cdf0e10cSrcweir void ) 332*cdf0e10cSrcweir throw( io::NotConnectedException, 333*cdf0e10cSrcweir io::IOException, 334*cdf0e10cSrcweir uno::RuntimeException ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir osl::MutexGuard aGuard( m_aMutex ); 337*cdf0e10cSrcweir m_bOutputStreamCalled = false; 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir if( ! m_bInputStreamCalled ) 340*cdf0e10cSrcweir closeStream(); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir void SAL_CALL 345*cdf0e10cSrcweir XStream_impl::seek( 346*cdf0e10cSrcweir sal_Int64 location ) 347*cdf0e10cSrcweir throw( lang::IllegalArgumentException, 348*cdf0e10cSrcweir io::IOException, 349*cdf0e10cSrcweir uno::RuntimeException ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir if( location < 0 ) 352*cdf0e10cSrcweir throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); 353*cdf0e10cSrcweir if( osl::FileBase::E_None != m_aFile.setPos( Pos_Absolut, sal_uInt64( location ) ) ) 354*cdf0e10cSrcweir throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir sal_Int64 SAL_CALL 359*cdf0e10cSrcweir XStream_impl::getPosition( 360*cdf0e10cSrcweir void ) 361*cdf0e10cSrcweir throw( io::IOException, 362*cdf0e10cSrcweir uno::RuntimeException ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir sal_uInt64 uPos; 365*cdf0e10cSrcweir if( osl::FileBase::E_None != m_aFile.getPos( uPos ) ) 366*cdf0e10cSrcweir throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 367*cdf0e10cSrcweir return sal_Int64( uPos ); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir sal_Int64 SAL_CALL 371*cdf0e10cSrcweir XStream_impl::getLength( 372*cdf0e10cSrcweir void ) 373*cdf0e10cSrcweir throw( io::IOException, 374*cdf0e10cSrcweir uno::RuntimeException ) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir sal_uInt64 uEndPos; 377*cdf0e10cSrcweir if ( m_aFile.getSize(uEndPos) != osl::FileBase::E_None ) 378*cdf0e10cSrcweir throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); 379*cdf0e10cSrcweir else 380*cdf0e10cSrcweir return sal_Int64( uEndPos ); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir void SAL_CALL 384*cdf0e10cSrcweir XStream_impl::flush() 385*cdf0e10cSrcweir throw( io::NotConnectedException, 386*cdf0e10cSrcweir io::BufferSizeExceededException, 387*cdf0e10cSrcweir io::IOException, 388*cdf0e10cSrcweir uno::RuntimeException ) 389*cdf0e10cSrcweir {} 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir void XStream_impl::waitForCompletion() 392*cdf0e10cSrcweir throw (io::IOException, uno::RuntimeException) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir // At least on UNIX, to reliably learn about any errors encountered by 395*cdf0e10cSrcweir // asynchronous NFS write operations, without closing the file directly 396*cdf0e10cSrcweir // afterwards, there appears to be no cheaper way than to call fsync: 397*cdf0e10cSrcweir if (m_nIsOpen && m_aFile.sync() != osl::FileBase::E_None) { 398*cdf0e10cSrcweir throw io::IOException( 399*cdf0e10cSrcweir rtl::OUString( 400*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 401*cdf0e10cSrcweir "could not synchronize file to disc")), 402*cdf0e10cSrcweir static_cast< OWeakObject * >(this)); 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir } 405