connectivity/source/drivers/firebird/Driver.cxx | 14 +++++- connectivity/source/drivers/firebird/Driver.hxx | 1 desktop/source/app/app.cxx | 54 ----------------------- filter/qa/cppunit/xslt-test.cxx | 4 + include/unotools/localfilehelper.hxx | 3 + sd/qa/unit/export-tests.cxx | 31 ++++++------- sd/qa/unit/import-tests.cxx | 56 ++++++++++++------------ starmath/qa/cppunit/test_starmath.cxx | 1 unotools/source/ucbhelper/localfilehelper.cxx | 51 +++++++++++++++++++++ unotools/source/ucbhelper/tempfile.cxx | 6 +- 10 files changed, 121 insertions(+), 100 deletions(-)
New commits: commit 99b6fc7b72452660f59ebeec8596cba375c02f9d Author: Michael Stahl <[email protected]> Date: Sat Oct 11 00:24:32 2014 +0200 sd: another temp-file leak Change-Id: Idcd31ea07c460aaecff3ea56072cf65e26040bda diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index df1db00..61aead3 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -474,6 +474,7 @@ void SdExportTest::testFdo83751() OUString propValue; xUDProps->getPropertyValue(OUString("Testing")) >>= propValue; CPPUNIT_ASSERT_EQUAL(OUString("Document"), propValue); + xDocShRef->DoClose(); } CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); commit 8a74ad7f242dda910abec22fb6106a70651c8b5e Author: Michael Stahl <[email protected]> Date: Fri Oct 10 21:23:08 2014 +0200 sd: rename test classes to be unique Change-Id: I18d4f6af97fcfb9341711751a8d550e421f7a381 diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 7aa1e26..df1db00 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -56,7 +56,7 @@ using namespace ::com::sun::star; -class SdFiltersTest : public SdModelTestBase +class SdExportTest : public SdModelTestBase { public: void testN821567(); @@ -72,7 +72,7 @@ public: void testBnc822347_EmptyBullet(); void testFdo83751(); - CPPUNIT_TEST_SUITE(SdFiltersTest); + CPPUNIT_TEST_SUITE(SdExportTest); CPPUNIT_TEST(testN821567); CPPUNIT_TEST(testBnc870233_1); CPPUNIT_TEST(testBnc870233_2); @@ -88,7 +88,7 @@ public: CPPUNIT_TEST_SUITE_END(); }; -void SdFiltersTest::testN821567() +void SdExportTest::testN821567() { OUString bgImage; ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n821567.pptx"), PPTX ); @@ -154,7 +154,7 @@ void checkFontAttributes(const SdrTextObj* pObj, sal_uInt32 nColor, } -void SdFiltersTest::testBnc870233_1() +void SdExportTest::testBnc870233_1() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_1.pptx"), PPTX); xDocShRef = saveAndReload( xDocShRef, PPTX ); @@ -183,7 +183,7 @@ void SdFiltersTest::testBnc870233_1() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc870233_2() +void SdExportTest::testBnc870233_2() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_2.pptx"), PPTX); xDocShRef = saveAndReload( xDocShRef, PPTX ); @@ -219,7 +219,7 @@ void SdFiltersTest::testBnc870233_2() xDocShRef->DoClose(); } -void SdFiltersTest::testN828390_4() +void SdExportTest::testN828390_4() { bool bPassed = false; ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/n828390_4.odp"), ODP ); @@ -258,7 +258,7 @@ void SdFiltersTest::testN828390_4() xDocShRef->DoClose(); } -void SdFiltersTest::testN828390_5() +void SdExportTest::testN828390_5() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/n828390_5.odp"), ODP ); @@ -281,7 +281,7 @@ void SdFiltersTest::testN828390_5() xDocShRef->DoClose(); } -void SdFiltersTest::testMediaEmbedding() +void SdExportTest::testMediaEmbedding() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/media_embedding.odp"), ODP); @@ -316,7 +316,7 @@ void SdFiltersTest::testMediaEmbedding() xDocShRef->DoClose(); } -void SdFiltersTest::testFdo71961() +void SdExportTest::testFdo71961() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71961.odp"), ODP); @@ -347,7 +347,7 @@ void SdFiltersTest::testFdo71961() xDocShRef->DoClose(); } -void SdFiltersTest::testN828390() +void SdExportTest::testN828390() { bool bPassed = false; ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390.pptx"), PPTX ); @@ -384,7 +384,7 @@ void SdFiltersTest::testN828390() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc880763() +void SdExportTest::testBnc880763() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc880763.pptx"), PPTX); xDocShRef = saveAndReload( xDocShRef, PPTX ); @@ -408,7 +408,7 @@ void SdFiltersTest::testBnc880763() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc862510_5() +void SdExportTest::testBnc862510_5() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_5.pptx"), PPTX); xDocShRef = saveAndReload( xDocShRef, PPTX ); @@ -432,7 +432,7 @@ void SdFiltersTest::testBnc862510_5() // In numbering a bullet could be defined as empty (no character). // When exporting to OOXML make sure that the bullet is ignored and // not written into the file. -void SdFiltersTest::testBnc822347_EmptyBullet() +void SdExportTest::testBnc822347_EmptyBullet() { sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/bnc822347_EmptyBullet.odp"), ODP); xDocShRef = saveAndReload(xDocShRef, PPTX); @@ -460,7 +460,7 @@ void SdFiltersTest::testBnc822347_EmptyBullet() xDocShRef->DoClose(); } -void SdFiltersTest::testFdo83751() +void SdExportTest::testFdo83751() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/fdo83751.pptx"), PPTX); xDocShRef = saveAndReload( xDocShRef, PPTX ); @@ -476,7 +476,7 @@ void SdFiltersTest::testFdo83751() CPPUNIT_ASSERT_EQUAL(OUString("Document"), propValue); } -CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest); +CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 4baad7a..2144825 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -56,7 +56,7 @@ using namespace ::com::sun::star; /// Impress import filters tests. -class SdFiltersTest : public SdModelTestBase +class SdImportTest : public SdModelTestBase { public: void testDocumentLayout(); @@ -85,7 +85,7 @@ public: void testBnc584721_3(); void testBnc584721_4(); - CPPUNIT_TEST_SUITE(SdFiltersTest); + CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST(testDocumentLayout); CPPUNIT_TEST(testSmoketest); CPPUNIT_TEST(testN759180); @@ -145,7 +145,7 @@ NOTE: This approach is suitable only for tests of fixes that actually change the layout - best to check by reverting your fix locally after having added the test, and re-running; it should break. */ -void SdFiltersTest::testDocumentLayout() +void SdImportTest::testDocumentLayout() { struct { const char *pInput, *pDump; sal_Int32 nFormat; sal_Int32 nExportType; } aFilesToCompare[] = { @@ -174,7 +174,7 @@ void SdFiltersTest::testDocumentLayout() } } -void SdFiltersTest::testSmoketest() +void SdImportTest::testSmoketest() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/smoketest.pptx"), PPTX); @@ -202,7 +202,7 @@ void SdFiltersTest::testSmoketest() xDocShRef->DoClose(); } -void SdFiltersTest::testN759180() +void SdImportTest::testN759180() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/n759180.pptx"), PPTX); @@ -240,7 +240,7 @@ void SdFiltersTest::testN759180() xDocShRef->DoClose(); } -void SdFiltersTest::testN862510_1() +void SdImportTest::testN862510_1() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_1.pptx"), PPTX ); @@ -265,7 +265,7 @@ void SdFiltersTest::testN862510_1() xDocShRef->DoClose(); } -void SdFiltersTest::testN862510_2() +void SdImportTest::testN862510_2() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_2.pptx"), PPTX ); @@ -284,7 +284,7 @@ void SdFiltersTest::testN862510_2() xDocShRef->DoClose(); } -void SdFiltersTest::testN862510_4() +void SdImportTest::testN862510_4() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_4.pptx"), PPTX ); @@ -309,7 +309,7 @@ void SdFiltersTest::testN862510_4() xDocShRef->DoClose(); } -void SdFiltersTest::testN828390_2() +void SdImportTest::testN828390_2() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_2.pptx"), PPTX ); @@ -328,7 +328,7 @@ void SdFiltersTest::testN828390_2() xDocShRef->DoClose(); } -void SdFiltersTest::testN828390_3() +void SdImportTest::testN828390_3() { bool bPassed = true; ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_3.pptx"), PPTX ); @@ -361,7 +361,7 @@ void SdFiltersTest::testN828390_3() xDocShRef->DoClose(); } -void SdFiltersTest::testMasterPageStyleParent() +void SdImportTest::testMasterPageStyleParent() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/odp/masterpage_style_parent.odp"), ODP ); @@ -400,7 +400,7 @@ void SdFiltersTest::testMasterPageStyleParent() xDocShRef->DoClose(); } -void SdFiltersTest::testN778859() +void SdImportTest::testN778859() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"), PPTX); @@ -419,7 +419,7 @@ void SdFiltersTest::testN778859() xDocShRef->DoClose(); } -void SdFiltersTest::testFdo68594() +void SdImportTest::testFdo68594() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/ppt/fdo68594.ppt"), PPT); @@ -438,7 +438,7 @@ void SdFiltersTest::testFdo68594() xDocShRef->DoClose(); } -void SdFiltersTest::testFdo72998() +void SdImportTest::testFdo72998() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/cshapes.pptx"), PPTX); @@ -468,7 +468,7 @@ std::ostream& operator<<(std::ostream& rStrm, const Color& rColor) return rStrm; } -void SdFiltersTest::testFdo77027() +void SdImportTest::testFdo77027() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/fdo77027.odp"), ODP); @@ -492,7 +492,7 @@ void SdFiltersTest::testFdo77027() xDocShRef->DoClose(); } -void SdFiltersTest::testFdo64512() +void SdImportTest::testFdo64512() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo64512.odp"), ODP); @@ -535,7 +535,7 @@ void SdFiltersTest::testFdo64512() } // Unit test for importing charts -void SdFiltersTest::testFdo71075() +void SdImportTest::testFdo71075() { double values[] = { 12.0, 13.0, 14.0 }; ::com::sun::star::uno::Any aAny; @@ -579,7 +579,7 @@ void SdFiltersTest::testFdo71075() xDocShRef->DoClose(); } -void SdFiltersTest::testStrictOOXML() +void SdImportTest::testStrictOOXML() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/strict_ooxml.pptx"), PPTX); @@ -593,7 +593,7 @@ void SdFiltersTest::testStrictOOXML() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc870237() +void SdImportTest::testBnc870237() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870237.pptx"), PPTX); @@ -613,7 +613,7 @@ void SdFiltersTest::testBnc870237() xDocShRef->DoClose(); } -void SdFiltersTest::testCreationDate() +void SdImportTest::testCreationDate() { sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71434.pptx"), PPTX); uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY); @@ -626,7 +626,7 @@ void SdFiltersTest::testCreationDate() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc887225() +void SdImportTest::testBnc887225() { ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bnc887225.pptx"), PPTX ); // In the document, lastRow and lastCol table properties are used. @@ -674,7 +674,7 @@ void SdFiltersTest::testBnc887225() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc480256() +void SdImportTest::testBnc480256() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc480256.pptx"), PPTX); // In the document, there are two tables with table background properties. @@ -731,7 +731,7 @@ void SdFiltersTest::testBnc480256() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc584721_1() +void SdImportTest::testBnc584721_1() { // Title text shape on the master page contained wrong text. @@ -749,7 +749,7 @@ void SdFiltersTest::testBnc584721_1() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc584721_2() +void SdImportTest::testBnc584721_2() { // Import created an extra/unneeded outliner shape on the master slide next to the imported title shape. @@ -764,7 +764,7 @@ void SdFiltersTest::testBnc584721_2() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc584721_3() +void SdImportTest::testBnc584721_3() { // Subtitle was simply skipped on master slides. // Check whether the second shape is a subtitle shape with the right text. @@ -789,7 +789,7 @@ void SdFiltersTest::testBnc584721_3() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc591147() +void SdImportTest::testBnc591147() { ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc591147.pptx"), PPTX); @@ -824,7 +824,7 @@ void SdFiltersTest::testBnc591147() xDocShRef->DoClose(); } -void SdFiltersTest::testBnc584721_4() +void SdImportTest::testBnc584721_4() { // Black text was imported as white because of wrong caching mechanism @@ -863,7 +863,7 @@ void SdFiltersTest::testBnc584721_4() xDocShRef->DoClose(); } -CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest); +CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit 66d18c1fd45c32a31e1683e8ccfede61f24c0845 Author: Michael Stahl <[email protected]> Date: Fri Oct 10 21:02:10 2014 +0200 starmath: close SfxObjectShell in unit test to stop temp file leakage Change-Id: Iaf2df8a315b3e0c8cdd1f1a4a7d589682384ddaf diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx index deeade8..3889c40 100644 --- a/starmath/qa/cppunit/test_starmath.cxx +++ b/starmath/qa/cppunit/test_starmath.cxx @@ -97,6 +97,7 @@ void Test::tearDown() delete m_pEditWindow; delete m_pSmCmdBoxWindow; delete m_pDispatcher; + m_xDocShRef->DoClose(); m_xDocShRef.Clear(); BootstrapFixture::tearDown(); commit 6c2cffdfc634be8ef7ec37f7da4a4b16e5e2a04e Author: Michael Stahl <[email protected]> Date: Fri Oct 10 17:57:15 2014 +0200 connectivity: firebird: recursively delete temp directories TempFile itself will only remove empty directories. Change-Id: Ibaf986856bde172de40686ae363821b19add8106 diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx index a6eacc6..5c9c88b 100644 --- a/connectivity/source/drivers/firebird/Driver.cxx +++ b/connectivity/source/drivers/firebird/Driver.cxx @@ -31,6 +31,7 @@ #include <osl/process.h> #include <rtl/bootstrap.hxx> #include <svtools/miscopt.hxx> +#include <unotools/localfilehelper.hxx> using namespace com::sun::star; using namespace com::sun::star::uno; @@ -67,8 +68,11 @@ FirebirdDriver::FirebirdDriver(const ::com::sun::star::uno::Reference< ::com::su , m_firebirdTMPDirectory(NULL, true) , m_firebirdLockDirectory(NULL, true) { - m_firebirdTMPDirectory.EnableKillingFile(); - m_firebirdLockDirectory.EnableKillingFile(); + // Note: TempFile caches the URL on first access; call this here so that + // ~FirebirdDriver is not the first access, because that is called + // when the ServiceManager is disposing, so GetURL() would fail! + m_firebirdTMPDirectory.GetURL(); + m_firebirdLockDirectory.GetURL(); // ::utl::TempFile uses a unique temporary directory (subdirectory of // /tmp or other user specific tmp directory) per instance in which @@ -91,6 +95,12 @@ FirebirdDriver::FirebirdDriver(const ::com::sun::star::uno::Reference< ::com::su #endif } +FirebirdDriver::~FirebirdDriver() +{ + utl::removeTree(m_firebirdTMPDirectory.GetURL()); + utl::removeTree(m_firebirdLockDirectory.GetURL()); +} + void FirebirdDriver::disposing() { MutexGuard aGuard(m_aMutex); diff --git a/connectivity/source/drivers/firebird/Driver.hxx b/connectivity/source/drivers/firebird/Driver.hxx index e7ff86c..2ed77a0 100644 --- a/connectivity/source/drivers/firebird/Driver.hxx +++ b/connectivity/source/drivers/firebird/Driver.hxx @@ -63,6 +63,7 @@ namespace connectivity public: FirebirdDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext); + virtual ~FirebirdDriver(); const css::uno::Reference<css::uno::XComponentContext>& getContext() const { return m_aContext; } // OComponentHelper commit f0215dcc9e5ba47d4b7d5b9759f1bd774942d388 Author: Michael Stahl <[email protected]> Date: Fri Oct 10 17:54:58 2014 +0200 unotools: assert if TempFile::GetURL() fails due to missing file UCP Change-Id: I3dd844c656766835079bc191b3b55d3fba2c2219 diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx index 8acc2e4..7665b3d 100644 --- a/unotools/source/ucbhelper/tempfile.cxx +++ b/unotools/source/ucbhelper/tempfile.cxx @@ -364,9 +364,9 @@ OUString TempFile::GetURL() { if ( aURL.isEmpty() ) { - OUString aTmp; - LocalFileHelper::ConvertPhysicalNameToURL( GetFileName(), aTmp ); - aURL = aTmp; + OUString const name(GetFileName()); + LocalFileHelper::ConvertPhysicalNameToURL(name, aURL); + assert((name.isEmpty() || !aURL.isEmpty()) && "TempFile::GetURL failed: unit test is leaking temp files, add the ucpfile1 component!"); } return aURL; commit 124a29f0f8dd805ef1d67bd062e1978a8a88e759 Author: Michael Stahl <[email protected]> Date: Fri Oct 10 17:37:08 2014 +0200 move the removeTree function from desktop to unotools Change-Id: I98d3f4a68abfee42dac987633878b850134671d3 diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index b2c3433..5374704 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -81,6 +81,7 @@ #include <unotools/bootstrap.hxx> #include <unotools/configmgr.hxx> #include <unotools/moduleoptions.hxx> +#include <unotools/localfilehelper.hxx> #include <officecfg/Office/Common.hxx> #include <officecfg/Office/Recovery.hxx> #include <officecfg/Setup.hxx> @@ -163,57 +164,6 @@ namespace { #if HAVE_FEATURE_EXTENSIONS -void removeTree(OUString const & url) { - osl::Directory dir(url); - osl::FileBase::RC rc = dir.open(); - switch (rc) { - case osl::FileBase::E_None: - break; - case osl::FileBase::E_NOENT: - return; //TODO: SAL_WARN if recursive - default: - SAL_WARN("desktop.app", "cannot open directory " << dir.getURL() << ": " << +rc); - return; - } - for (;;) { - osl::DirectoryItem i; - rc = dir.getNextItem(i, SAL_MAX_UINT32); - if (rc == osl::FileBase::E_NOENT) { - break; - } - if (rc != osl::FileBase::E_None) { - SAL_WARN( "desktop.app", "cannot iterate directory " << dir.getURL() << ": " << +rc); - break; - } - osl::FileStatus stat( - osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName | - osl_FileStatus_Mask_FileURL); - rc = i.getFileStatus(stat); - if (rc != osl::FileBase::E_None) { - SAL_WARN( "desktop.app", "cannot stat in directory " << dir.getURL() << ": " << +rc); - continue; - } - if (stat.getFileType() == osl::FileStatus::Directory) { //TODO: symlinks - removeTree(stat.getFileURL()); - } else { - rc = osl::File::remove(stat.getFileURL()); - SAL_WARN_IF( - rc != osl::FileBase::E_None, "desktop.app", - "cannot remove file " << stat.getFileURL() << ": " << +rc); - } - } - if (dir.isOpen()) { - rc = dir.close(); - SAL_WARN_IF( - rc != osl::FileBase::E_None, "desktop.app", - "cannot close directory " << dir.getURL() << ": " << +rc); - } - rc = osl::Directory::remove(url); - SAL_WARN_IF( - rc != osl::FileBase::E_None, "desktop.app", - "cannot remove directory " << url << ": " << +rc); -} - // Remove any existing UserInstallation's extensions cache data remaining from // old installations. This addresses at least two problems: // @@ -285,7 +235,7 @@ bool cleanExtensionCache() { SAL_WARN( "desktop.app", "cannot open " << fr.getURL() << " for reading: " << +rc); break; } - removeTree(extDir); + utl::removeTree(extDir); OUString userRcFile( "$UNO_USER_PACKAGES_CACHE/registry/" "com.sun.star.comp.deployment.component.PackageRegistryBackend/unorc"); diff --git a/include/unotools/localfilehelper.hxx b/include/unotools/localfilehelper.hxx index 6f69580..84d5a88 100644 --- a/include/unotools/localfilehelper.hxx +++ b/include/unotools/localfilehelper.hxx @@ -52,6 +52,9 @@ namespace utl static ::com::sun::star::uno::Sequence< OUString > GetFolderContents( const OUString& rFolder, bool bFolder ); }; + + /// recursively remove directory and all contents + UNOTOOLS_DLLPUBLIC void removeTree(OUString const & url); } #endif diff --git a/unotools/source/ucbhelper/localfilehelper.cxx b/unotools/source/ucbhelper/localfilehelper.cxx index 665f652..1d2dedb 100644 --- a/unotools/source/ucbhelper/localfilehelper.cxx +++ b/unotools/source/ucbhelper/localfilehelper.cxx @@ -193,6 +193,57 @@ typedef ::std::vector< OUString* > StringList_Impl; return Sequence < OUString > (); } +void removeTree(OUString const & url) { + osl::Directory dir(url); + osl::FileBase::RC rc = dir.open(); + switch (rc) { + case osl::FileBase::E_None: + break; + case osl::FileBase::E_NOENT: + return; //TODO: SAL_WARN if recursive + default: + SAL_WARN("desktop.app", "cannot open directory " << dir.getURL() << ": " << +rc); + return; + } + for (;;) { + osl::DirectoryItem i; + rc = dir.getNextItem(i, SAL_MAX_UINT32); + if (rc == osl::FileBase::E_NOENT) { + break; + } + if (rc != osl::FileBase::E_None) { + SAL_WARN( "desktop.app", "cannot iterate directory " << dir.getURL() << ": " << +rc); + break; + } + osl::FileStatus stat( + osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName | + osl_FileStatus_Mask_FileURL); + rc = i.getFileStatus(stat); + if (rc != osl::FileBase::E_None) { + SAL_WARN( "desktop.app", "cannot stat in directory " << dir.getURL() << ": " << +rc); + continue; + } + if (stat.getFileType() == osl::FileStatus::Directory) { //TODO: symlinks + removeTree(stat.getFileURL()); + } else { + rc = osl::File::remove(stat.getFileURL()); + SAL_WARN_IF( + rc != osl::FileBase::E_None, "desktop.app", + "cannot remove file " << stat.getFileURL() << ": " << +rc); + } + } + if (dir.isOpen()) { + rc = dir.close(); + SAL_WARN_IF( + rc != osl::FileBase::E_None, "desktop.app", + "cannot close directory " << dir.getURL() << ": " << +rc); + } + rc = osl::Directory::remove(url); + SAL_WARN_IF( + rc != osl::FileBase::E_None, "desktop.app", + "cannot remove directory " << url << ": " << +rc); +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 3d85ec29ddd73ed996debdcf118f8c32774362ed Author: Michael Stahl <[email protected]> Date: Fri Oct 10 15:23:33 2014 +0200 filter: stop leaking temp files in xsltfilter test Change-Id: Icefec168910ba0b059f4b1887ec67cce8505ffd6 diff --git a/filter/qa/cppunit/xslt-test.cxx b/filter/qa/cppunit/xslt-test.cxx index 1a580d0..f9945ea 100644 --- a/filter/qa/cppunit/xslt-test.cxx +++ b/filter/qa/cppunit/xslt-test.cxx @@ -122,6 +122,8 @@ void XsltFilterTest::testXsltCopyNew() sal_uInt64 size(0); foo.getSize(size); CPPUNIT_ASSERT(size > 1000); // check that something happened + foo.close(); + osl_removeFile(tempURL.pData); } void XsltFilterTest::testXsltCopyOld() @@ -182,6 +184,8 @@ void XsltFilterTest::testXsltCopyOld() sal_uInt64 size(0); foo.getSize(size); CPPUNIT_ASSERT(size > 1000); // check that something happened + foo.close(); + osl_removeFile(tempURL.pData); } CPPUNIT_TEST_SUITE_REGISTRATION(XsltFilterTest); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
