LCOV - code coverage report
Current view: top level - package/source/xstor - selfterminatefilestream.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 36 0.0 %
Date: 2014-04-14 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      21             : 
      22             : #include "selfterminatefilestream.hxx"
      23             : #include <comphelper/processfactory.hxx>
      24             : 
      25             : using namespace ::com::sun::star;
      26             : 
      27           0 : OSelfTerminateFileStream::OSelfTerminateFileStream( const uno::Reference< uno::XComponentContext > xContext, const OUString& aURL )
      28           0 : : m_aURL( aURL )
      29             : {
      30           0 :     uno::Reference< uno::XComponentContext > xOwnContext = xContext;
      31           0 :     if ( !xOwnContext.is() )
      32           0 :         xOwnContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
      33             : 
      34             :     // IMPORTANT: The implementation is based on idea that m_xFileAccess, m_xInputStream and m_xSeekable are always set
      35             :     // otherwise an exception is thrown in constructor
      36             : 
      37           0 :     m_xFileAccess.set( ucb::SimpleFileAccess::create(xOwnContext) );
      38             : 
      39           0 :     m_xInputStream.set( m_xFileAccess->openFileRead( aURL ), uno::UNO_SET_THROW );
      40           0 :     m_xSeekable.set( m_xInputStream, uno::UNO_QUERY_THROW );
      41           0 : }
      42             : 
      43           0 : OSelfTerminateFileStream::~OSelfTerminateFileStream()
      44             : {
      45           0 :     CloseStreamDeleteFile();
      46           0 : }
      47             : 
      48           0 : void OSelfTerminateFileStream::CloseStreamDeleteFile()
      49             : {
      50             :     try
      51             :     {
      52           0 :         m_xInputStream->closeInput();
      53             :     }
      54           0 :     catch( uno::Exception& )
      55             :     {}
      56             : 
      57             :     try
      58             :     {
      59           0 :         m_xFileAccess->kill( m_aURL );
      60             :     }
      61           0 :     catch( uno::Exception& )
      62             :     {}
      63           0 : }
      64             : 
      65           0 : sal_Int32 SAL_CALL OSelfTerminateFileStream::readBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
      66             :         throw ( io::NotConnectedException,
      67             :                 io::BufferSizeExceededException,
      68             :                 io::IOException,
      69             :                 uno::RuntimeException, std::exception )
      70             : {
      71           0 :     return m_xInputStream->readBytes( aData, nBytesToRead );
      72             : }
      73             : 
      74           0 : sal_Int32 SAL_CALL OSelfTerminateFileStream::readSomeBytes( uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
      75             :         throw ( io::NotConnectedException,
      76             :                 io::BufferSizeExceededException,
      77             :                 io::IOException,
      78             :                 uno::RuntimeException, std::exception )
      79             : {
      80           0 :     return m_xInputStream->readSomeBytes( aData, nMaxBytesToRead );
      81             : }
      82             : 
      83           0 : void SAL_CALL OSelfTerminateFileStream::skipBytes( sal_Int32 nBytesToSkip )
      84             :         throw ( io::NotConnectedException,
      85             :                 io::BufferSizeExceededException,
      86             :                 io::IOException,
      87             :                 uno::RuntimeException, std::exception )
      88             : {
      89           0 :     return m_xInputStream->skipBytes( nBytesToSkip );
      90             : }
      91             : 
      92           0 : sal_Int32 SAL_CALL OSelfTerminateFileStream::available(  )
      93             :         throw ( io::NotConnectedException,
      94             :                 io::IOException,
      95             :                 uno::RuntimeException, std::exception )
      96             : {
      97           0 :     return m_xInputStream->available();
      98             : }
      99             : 
     100           0 : void SAL_CALL OSelfTerminateFileStream::closeInput(  )
     101             :         throw ( io::NotConnectedException,
     102             :                 io::IOException,
     103             :                 uno::RuntimeException, std::exception )
     104             : {
     105           0 :     CloseStreamDeleteFile();
     106           0 : }
     107             : 
     108           0 : void SAL_CALL OSelfTerminateFileStream::seek( sal_Int64 location )
     109             :         throw ( lang::IllegalArgumentException,
     110             :                 io::IOException,
     111             :                 uno::RuntimeException, std::exception )
     112             : {
     113           0 :     m_xSeekable->seek( location );
     114           0 : }
     115             : 
     116           0 : sal_Int64 SAL_CALL OSelfTerminateFileStream::getPosition()
     117             :         throw ( io::IOException,
     118             :                 uno::RuntimeException, std::exception)
     119             : {
     120           0 :     return m_xSeekable->getPosition();
     121             : }
     122             : 
     123           0 : sal_Int64 SAL_CALL OSelfTerminateFileStream::getLength()
     124             :         throw ( io::IOException,
     125             :                 uno::RuntimeException, std::exception )
     126             : {
     127           0 :     return m_xSeekable->getLength();
     128             : }
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10