tools/source/stream/strmunx.cxx |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit f23633aa0adf5048b283e7bedb08f67198cff591
Author:     Noel Grandin <[email protected]>
AuthorDate: Sun May 15 21:21:05 2022 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Mon May 16 17:51:02 2022 +0200

    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 <[email protected]>

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 ) )

Reply via email to