diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-15 21:21:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-16 17:51:02 +0200 |
commit | f23633aa0adf5048b283e7bedb08f67198cff591 (patch) | |
tree | f22b31bb12072353f0d2b1d29b5882f55e6c9ae8 /tools/source | |
parent | 985240136dd0d99c50fd0e0b87b777f5b93e5153 (diff) |
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>
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/stream/strmunx.cxx | 18 |
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 ) ) |