diff options
author | Andreas Bille <abi@openoffice.org> | 2001-01-23 08:13:32 +0000 |
---|---|---|
committer | Andreas Bille <abi@openoffice.org> | 2001-01-23 08:13:32 +0000 |
commit | 4a3f2227f6201ffb900de737d13cfadd85d717bc (patch) | |
tree | 017429c14202c57254452dc620673014a80b4055 /ucb/source | |
parent | 3c4396ec87bd0297904954f1439c65ea9ce0a3ba (diff) |
#77581#
Replaced recursive procedure "OneMore", which produces a stack overflow for
extremly large directories,
by an iterative procedure.
Diffstat (limited to 'ucb/source')
-rw-r--r-- | ucb/source/ucp/file/filrset.cxx | 157 |
1 files changed, 119 insertions, 38 deletions
diff --git a/ucb/source/ucp/file/filrset.cxx b/ucb/source/ucp/file/filrset.cxx index f45c47093b8c..c805a4003e7f 100644 --- a/ucb/source/ucp/file/filrset.cxx +++ b/ucb/source/ucp/file/filrset.cxx @@ -2,9 +2,9 @@ * * $RCSfile: filrset.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: kso $ $Date: 2001-01-18 09:20:28 $ + * last change: $Author: abi $ $Date: 2001-01-23 09:13:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -345,30 +345,32 @@ XResultSet_impl::OneMore( throw( sdbc::SQLException, uno::RuntimeException ) { + if( ! m_nIsOpen ) return false; + if( m_bFaked ) return OneMoreFaked(); - osl::DirectoryItem m_aDirIte; - - if( ! m_nIsOpen ) return false; - - osl::FileBase::RC err = m_aFolder.getNextItem( m_aDirIte ); + osl::FileBase::RC err; + sal_Bool IsRegular; + rtl::OUString aUnqPath; + osl::DirectoryItem m_aDirIte; + uno::Reference< sdbc::XRow > aRow; - if( err == osl::FileBase::E_NOENT || err == osl::FileBase::E_INVAL ) + while( true ) { - m_aFolder.close(); - isFinalChanged(); - return ( m_nIsOpen = false ); - } - else if( err == osl::FileBase::E_None ) - { - sal_Bool IsRegular; - rtl::OUString aUnqPath; - uno::Reference< sdbc::XRow > aRow = m_pMyShell->getv( -1,this,m_sProperty,m_aDirIte,aUnqPath,IsRegular ); + err = m_aFolder.getNextItem( m_aDirIte ); - if( m_nOpenMode == OpenMode::DOCUMENTS ) + if( err == osl::FileBase::E_NOENT || err == osl::FileBase::E_INVAL ) { - if( IsRegular ) + m_aFolder.close(); + isFinalChanged(); + return ( m_nIsOpen = false ); + } + else if( err == osl::FileBase::E_None ) + { + aRow = m_pMyShell->getv( -1,this,m_sProperty,m_aDirIte,aUnqPath,IsRegular ); + + if( m_nOpenMode == OpenMode::DOCUMENTS && IsRegular ) { vos::OGuard aGuard( m_aMutex ); m_aItems.push_back( aRow ); @@ -376,15 +378,13 @@ XResultSet_impl::OneMore( m_aUnqPath.push_back( aUnqPath ); rowCountChanged(); return true; + } - else + else if( m_nOpenMode == OpenMode::DOCUMENTS && ! IsRegular ) { - return OneMore(); + continue; } - } - else if( m_nOpenMode == OpenMode::FOLDERS ) - { - if( ! IsRegular ) + else if( m_nOpenMode == OpenMode::FOLDERS && ! IsRegular ) { vos::OGuard aGuard( m_aMutex ); m_aItems.push_back( aRow ); @@ -393,29 +393,110 @@ XResultSet_impl::OneMore( rowCountChanged(); return true; } + else if( m_nOpenMode == OpenMode::FOLDERS && IsRegular ) + { + continue; + } else { - return OneMore(); + vos::OGuard aGuard( m_aMutex ); + m_aItems.push_back( aRow ); + m_aIdents.push_back( uno::Reference< XContentIdentifier >() ); + m_aUnqPath.push_back( aUnqPath ); + rowCountChanged(); + return true; } } - else + else // error fetching anything { - vos::OGuard aGuard( m_aMutex ); - m_aItems.push_back( aRow ); - m_aIdents.push_back( uno::Reference< XContentIdentifier >() ); - m_aUnqPath.push_back( aUnqPath ); - rowCountChanged(); - return true; + throw sdbc::SQLException(); + return false; } } - else - { - throw sdbc::SQLException(); - return false; - } } + + +/* + sal_Bool SAL_CALL + XResultSet_impl::OneMore( + void ) + throw( sdbc::SQLException, + uno::RuntimeException ) + { + if( m_bFaked ) + return OneMoreFaked(); + + osl::DirectoryItem m_aDirIte; + + if( ! m_nIsOpen ) return false; + + osl::FileBase::RC err = m_aFolder.getNextItem( m_aDirIte ); + + if( err == osl::FileBase::E_NOENT || err == osl::FileBase::E_INVAL ) + { + m_aFolder.close(); + isFinalChanged(); + return ( m_nIsOpen = false ); + } + else if( err == osl::FileBase::E_None ) + { + sal_Bool IsRegular; + rtl::OUString aUnqPath; + uno::Reference< sdbc::XRow > aRow = m_pMyShell->getv( -1,this,m_sProperty,m_aDirIte,aUnqPath,IsRegular ); + + if( m_nOpenMode == OpenMode::DOCUMENTS ) + { + if( IsRegular ) + { + vos::OGuard aGuard( m_aMutex ); + m_aItems.push_back( aRow ); + m_aIdents.push_back( uno::Reference< XContentIdentifier >() ); + m_aUnqPath.push_back( aUnqPath ); + rowCountChanged(); + return true; + } + else + { + return OneMore(); + } + } + else if( m_nOpenMode == OpenMode::FOLDERS ) + { + if( ! IsRegular ) + { + vos::OGuard aGuard( m_aMutex ); + m_aItems.push_back( aRow ); + m_aIdents.push_back( uno::Reference< XContentIdentifier >() ); + m_aUnqPath.push_back( aUnqPath ); + rowCountChanged(); + return true; + } + else + { + return OneMore(); + } + } + else + { + vos::OGuard aGuard( m_aMutex ); + m_aItems.push_back( aRow ); + m_aIdents.push_back( uno::Reference< XContentIdentifier >() ); + m_aUnqPath.push_back( aUnqPath ); + rowCountChanged(); + return true; + } + } + else + { + throw sdbc::SQLException(); + return false; + } + } +*/ + + sal_Bool SAL_CALL XResultSet_impl::next( void ) |