summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-09-21 20:54:00 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-29 09:11:18 +0200
commit4b95451f859bac8e05956ce12df17f1ee410032d (patch)
tree2ebe03c8ecbba3c9179d33c346774e037fcfc224 /desktop
parenta08468c1a5255d3fb04cd8a0dc627acdea40426a (diff)
split utl::TempFile into fast and named variants
which makes it easier to know what each variant requires to stay on it's happy path Change-Id: I3275a2543573367714bc78092e882f6535507285 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140469 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx16
-rw-r--r--desktop/source/app/appinit.cxx4
-rw-r--r--desktop/source/app/dispatchwatcher.cxx4
-rw-r--r--desktop/source/app/updater.cxx4
-rw-r--r--desktop/source/deployment/manager/dp_manager.cxx4
-rw-r--r--desktop/source/deployment/registry/dp_backend.cxx4
-rw-r--r--desktop/source/lib/init.cxx2
-rw-r--r--desktop/source/pkgchk/unopkg/unopkg_app.cxx4
8 files changed, 19 insertions, 23 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 437acd28df42..f8b5e02536df 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -678,7 +678,7 @@ void DesktopLOKTest::testPaintTile()
void DesktopLOKTest::testSaveAs()
{
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "png", nullptr));
}
@@ -689,7 +689,7 @@ void DesktopLOKTest::testSaveAsJsonOptions()
LibLODocument_Impl* pDocument = loadDoc("3page.odg");
// When exporting that document to PDF, skipping the first page:
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
OString aOptions("{\"PageRange\":{\"type\":\"string\",\"value\":\"2-\"}}");
CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "pdf", aOptions.getStr()));
@@ -714,7 +714,7 @@ void DesktopLOKTest::testSaveAsJsonOptions()
void DesktopLOKTest::testSaveAsCalc()
{
LibLODocument_Impl* pDocument = loadDoc("search.ods");
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "png", nullptr));
}
@@ -2731,7 +2731,7 @@ void DesktopLOKTest::testInsertCertificate_DER_ODT()
{
// Load the document, save it into a temp file and load that file again
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "odt", nullptr));
closeDoc();
@@ -2781,7 +2781,7 @@ void DesktopLOKTest::testInsertCertificate_PEM_ODT()
{
// Load the document, save it into a temp file and load that file again
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "odt", nullptr));
closeDoc();
@@ -2838,7 +2838,7 @@ void DesktopLOKTest::testInsertCertificate_PEM_DOCX()
{
// Load the document, save it into a temp file and load that file again
LibLODocument_Impl* pDocument = loadDoc("blank_text.docx");
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "docx", nullptr));
closeDoc();
@@ -2895,7 +2895,7 @@ void DesktopLOKTest::testSignDocument_PEM_PDF()
{
// Load the document, save it into a temp file and load that file again
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
Scheduler::ProcessEventsToIdle();
@@ -3105,7 +3105,7 @@ void DesktopLOKTest::testCalcSaveAs()
Scheduler::ProcessEventsToIdle();
// Save as a new file.
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
aTempFile.EnableKillingFile();
pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "ods", nullptr);
closeDoc();
diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx
index 9ce317209e87..1c837b833d16 100644
--- a/desktop/source/app/appinit.cxx
+++ b/desktop/source/app/appinit.cxx
@@ -245,11 +245,11 @@ void Desktop::CreateTemporaryDirectory()
}
// create new current temporary directory
- OUString aTempPath = ::utl::TempFile::SetTempNameBaseDirectory( aTempBaseURL );
+ OUString aTempPath = ::utl::SetTempNameBaseDirectory( aTempBaseURL );
if ( aTempPath.isEmpty()
&& ::osl::File::getTempDirURL( aTempBaseURL ) == osl::FileBase::E_None )
{
- aTempPath = ::utl::TempFile::SetTempNameBaseDirectory( aTempBaseURL );
+ aTempPath = ::utl::SetTempNameBaseDirectory( aTempBaseURL );
}
// set new current temporary directory
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 16b76cb789fd..8ae45b40daa6 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -572,10 +572,10 @@ bool DispatchWatcher::executeDispatchRequests( const std::vector<DispatchRequest
OUString aOutFile
= aOutFilename.GetMainURL(INetURLObject::DecodeMechanism::NONE);
- std::unique_ptr<utl::TempFile> fileForCat;
+ std::unique_ptr<utl::TempFileNamed> fileForCat;
if( aDispatchRequest.aRequestType == REQUEST_CAT )
{
- fileForCat = std::make_unique<utl::TempFile>();
+ fileForCat = std::make_unique<utl::TempFileNamed>();
if (fileForCat->IsValid())
fileForCat->EnableKillingFile();
else
diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx
index 2748373e5f62..e0d5bcd832b5 100644
--- a/desktop/source/app/updater.cxx
+++ b/desktop/source/app/updater.cxx
@@ -285,7 +285,7 @@ bool isUserWritable(const OUString& rFileURL)
bool update()
{
- utl::TempFile aTempDir(nullptr, true);
+ utl::TempFileNamed aTempDir(nullptr, true);
OUString aTempDirURL = aTempDir.GetURL();
CopyUpdaterToTempDir(Updater::getExecutableDirURL(), aTempDirURL);
@@ -566,7 +566,7 @@ std::string download_content(const OString& rURL, bool bFile, OUString& rHash)
curl_easy_setopt(curl.get(), CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
std::string response_body;
- utl::TempFile aTempFile;
+ utl::TempFileNamed aTempFile;
WriteDataFile aFile(aTempFile.GetStream(StreamMode::WRITE));
if (!bFile)
{
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index 2c52741c2acb..b26d1004a053 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -608,9 +608,7 @@ OUString PackageManagerImpl::insertToActivationLayer(
Reference<XCommandEnvironment> xCmdEnv(
sourceContent.getCommandEnvironment() );
- OUString baseDir(m_activePackages_expanded);
- ::utl::TempFile aTemp(&baseDir, false);
- OUString tempEntry = aTemp.GetURL();
+ OUString tempEntry = ::utl::CreateTempURL(&m_activePackages_expanded, false);
tempEntry = tempEntry.copy(tempEntry.lastIndexOf('/') + 1);
OUString destFolder = makeURL( m_activePackages, tempEntry) + "_";
diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx
index 28fe1b8de218..016ff66286d9 100644
--- a/desktop/source/deployment/registry/dp_backend.cxx
+++ b/desktop/source/deployment/registry/dp_backend.cxx
@@ -215,9 +215,7 @@ OUString PackageRegistryBackend::createFolder(
ucbhelper::Content dataContent;
::dp_misc::create_folder(&dataContent, sDataFolder, xCmdEnv);
- const OUString baseDir(sDataFolder);
- ::utl::TempFile aTemp(&baseDir, true);
- const OUString& url = aTemp.GetURL();
+ const OUString url = ::utl::CreateTempURL(&sDataFolder, true);
return sDataFolder + url.subView(url.lastIndexOf('/'));
}
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b3fae56f721f..bf088d2a4f52 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -6624,7 +6624,7 @@ static void preloadData()
// Create user profile in the temp directory for loading the dictionaries
OUString sUserPath;
rtl::Bootstrap::get("UserInstallation", sUserPath);
- utl::TempFile aTempDir(nullptr, true);
+ utl::TempFileNamed aTempDir(nullptr, true);
aTempDir.EnableKillingFile();
rtl::Bootstrap::set("UserInstallation", aTempDir.GetURL());
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
index f733dbb4dde9..5e3828dea8b2 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
@@ -216,7 +216,7 @@ extern "C" int unopkg_main()
Reference<XLogHandler> xFileHandler;
Reference<XLogHandler> xConsoleHandler;
std::unique_ptr<comphelper::EventLogger> logger;
- std::unique_ptr<utl::TempFile> pUserProfileTempDir;
+ std::unique_ptr<utl::TempFileNamed> pUserProfileTempDir;
OptionInfo const * info_shared = getOptionInfo(
s_option_infos, "shared" );
@@ -314,7 +314,7 @@ extern "C" int unopkg_main()
// tdf#129917 Use temp user profile when installing shared extensions
if (option_shared)
{
- pUserProfileTempDir.reset(new utl::TempFile(nullptr, true));
+ pUserProfileTempDir.reset(new utl::TempFileNamed(nullptr, true));
pUserProfileTempDir->EnableKillingFile();
}