From f23633aa0adf5048b283e7bedb08f67198cff591 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 15 May 2022 21:21:05 +0200 Subject: no need to stat a dir when opening a temporary file it can never be a dir Change-Id: Ib1c234cb20387cd075a19e13e6656738be88716b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134397 Tested-by: Jenkins Reviewed-by: Noel Grandin --- tools/source/stream/strmunx.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'tools/source/stream/strmunx.cxx') diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index d01866476f51..5964529f34a1 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -372,14 +372,20 @@ void SvFileStream::Open( const OUString& rFilename, StreamMode nOpenMode ) // FIXME: we really need to switch to a pure URL model ... if ( osl::File::getFileURLFromSystemPath( aFilename, aFileURL ) != osl::FileBase::E_None ) aFileURL = aFilename; - bool bStatValid = ( osl::DirectoryItem::get( aFileURL, aItem) == osl::FileBase::E_None && - aItem.getFileStatus( aStatus ) == osl::FileBase::E_None ); - // SvFileStream can't open a directory - if( bStatValid && aStatus.getFileType() == osl::FileStatus::Directory ) + // don't both stat()ing a temporary file, unnecessary + bool bStatValid = true; + if (!(nOpenMode & StreamMode::TEMPORARY)) { - SetError( ::GetSvError( EISDIR ) ); - return; + bStatValid = ( osl::DirectoryItem::get( aFileURL, aItem) == osl::FileBase::E_None && + aItem.getFileStatus( aStatus ) == osl::FileBase::E_None ); + + // SvFileStream can't open a directory + if( bStatValid && aStatus.getFileType() == osl::FileStatus::Directory ) + { + SetError( ::GetSvError( EISDIR ) ); + return; + } } if ( !( nOpenMode & StreamMode::WRITE ) ) -- cgit