summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-15 21:21:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-16 17:51:02 +0200
commitf23633aa0adf5048b283e7bedb08f67198cff591 (patch)
treef22b31bb12072353f0d2b1d29b5882f55e6c9ae8
parentpdfwriter: validator: fix rule 6.4-3 (diff)
downloadcore-f23633aa0adf5048b283e7bedb08f67198cff591.tar.gz
core-f23633aa0adf5048b283e7bedb08f67198cff591.zip
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 <noel.grandin@collabora.co.uk>
-rw-r--r--tools/source/stream/strmunx.cxx18
1 files changed, 12 insertions, 6 deletions
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 ) )