diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-08 15:53:58 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-09 09:08:44 +0100 |
commit | 5259ab8104cfba60c40748ed0cd59d93df038c5b (patch) | |
tree | 7fcae441dae8461edab4bbc539d43f25eaddfc64 | |
parent | a6ec829055ab0b9d223979ae5f90d158d5549db1 (diff) |
sfx2 store: create temp files next to local files
This way it's more likely that we can do a cheap rename instead of a
copy in SfxMedium::Commit().
Change-Id: I45c80cd19c3ab3bc70ecbf9793dbe1bb55994ee9
Reviewed-on: https://gerrit.libreoffice.org/47611
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 27fe78208317..3ca1d1a2d2f9 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -3385,7 +3385,18 @@ void SfxMedium::CreateTempFile( bool bReplace ) pImpl->m_aName.clear(); } - pImpl->pTempFile = new ::utl::TempFile(); + OUString aLogicBase; + if (comphelper::isFileUrl(pImpl->m_aLogicName)) + { + // Try to create the temp file in the same directory. + sal_Int32 nOffset = pImpl->m_aLogicName.lastIndexOf("/"); + if (nOffset != -1) + aLogicBase = pImpl->m_aLogicName.copy(0, nOffset); + if (aLogicBase == "file://") + // Doesn't make sense. + aLogicBase.clear(); + } + pImpl->pTempFile = new ::utl::TempFile(aLogicBase.isEmpty() ? nullptr : &aLogicBase); pImpl->pTempFile->EnableKillingFile(); pImpl->m_aName = pImpl->pTempFile->GetFileName(); OUString aTmpURL = pImpl->pTempFile->GetURL(); |