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>
This commit is contained in:
Noel Grandin 2022-05-15 21:21:05 +02:00
parent 985240136d
commit f23633aa0a

View file

@ -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 &&
// don't both stat()ing a temporary file, unnecessary
bool bStatValid = true;
if (!(nOpenMode & StreamMode::TEMPORARY))
{
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;
// SvFileStream can't open a directory
if( bStatValid && aStatus.getFileType() == osl::FileStatus::Directory )
{
SetError( ::GetSvError( EISDIR ) );
return;
}
}
if ( !( nOpenMode & StreamMode::WRITE ) )