[PATCH] writing out tools/fsys.hxx (extensions)

Andras Timar (via Code Review) gerrit at gerrit.libreoffice.org
Fri Mar 29 09:13:23 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3119

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/19/3119/1

writing out tools/fsys.hxx (extensions)

Change-Id: I6b2132e7441be1579f6233ec56fdaf8807a60b55
---
M extensions/source/plugin/base/context.cxx
M extensions/source/plugin/base/plcom.cxx
M extensions/source/plugin/base/xplugin.cxx
3 files changed, 30 insertions(+), 31 deletions(-)



diff --git a/extensions/source/plugin/base/context.cxx b/extensions/source/plugin/base/context.cxx
index a499201..61bf607 100644
--- a/extensions/source/plugin/base/context.cxx
+++ b/extensions/source/plugin/base/context.cxx
@@ -48,8 +48,8 @@
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
-#include <tools/fsys.hxx>
 #include <tools/urlobj.hxx>
+#include <osl/file.hxx>
 
 #include <cppuhelper/implbase1.hxx>
 
@@ -215,7 +215,7 @@
             aStream.Seek( STREAM_SEEK_TO_BEGIN );
             aStream.Read( aBuf.getArray(), nBytes );
             aStream.Close();
-            DirEntry( aFileName ).Kill();
+            osl::File::remove( aFileName );
         }
     }
 
@@ -278,9 +278,8 @@
         m_aMIMEType( mimetype ),
         m_aTarget( target )
 {
-    DirEntry aEntry;
-    m_aFileName = aEntry.TempName().GetFull();
-    ::rtl::OString aFile = ::rtl::OUStringToOString( m_aFileName, osl_getThreadTextEncoding() );
+    osl::FileBase::createTempFile( 0, 0, &m_aFileName );
+    OString aFile = OUStringToOString( m_aFileName, osl_getThreadTextEncoding() );
     fp = fopen( aFile.getStr() , "wb" );
 
     Reference< ::com::sun::star::io::XActiveDataControl >  xControl( source, UNO_QUERY );
@@ -292,8 +291,7 @@
 
 FileSink::~FileSink()
 {
-    DirEntry aEntry( m_aFileName );
-    aEntry.Kill();
+    osl::File::remove( m_aFileName );
 }
 
 void FileSink::closeOutput() throw()
diff --git a/extensions/source/plugin/base/plcom.cxx b/extensions/source/plugin/base/plcom.cxx
index 4239c85..11fc4e3 100644
--- a/extensions/source/plugin/base/plcom.cxx
+++ b/extensions/source/plugin/base/plcom.cxx
@@ -45,7 +45,7 @@
 
 #include <cstdarg>
 
-#include <tools/fsys.hxx>
+#include <osl/file.hxx>
 #include <plugin/impl.hxx>
 
 PluginComm::PluginComm( const ::rtl::OString& rLibName, bool bReusable ) :
@@ -61,10 +61,10 @@
     PluginManager::get().getPluginComms().remove( this );
     while( m_aFilesToDelete.size() )
     {
-        String aFile = m_aFilesToDelete.front();
+        OUString aFile( m_aFilesToDelete.front() );
         m_aFilesToDelete.pop_front();
-        DirEntry aEntry( aFile );
-        aEntry.Kill();
+        osl::FileBase::getFileURLFromSystemPath( aFile, aFile );
+        osl::File::remove( aFile );
     }
 }
 
diff --git a/extensions/source/plugin/base/xplugin.cxx b/extensions/source/plugin/base/xplugin.cxx
index 24fa2c7..5e96bee 100644
--- a/extensions/source/plugin/base/xplugin.cxx
+++ b/extensions/source/plugin/base/xplugin.cxx
@@ -45,7 +45,6 @@
 
 #include <comphelper/processfactory.hxx>
 #include <plugin/impl.hxx>
-#include <tools/fsys.hxx>
 #include <ucbhelper/content.hxx>
 #include <tools/urlobj.hxx>
 #include <tools/string.hxx>
@@ -67,9 +66,6 @@
 using namespace com::sun::star::beans;
 using namespace com::sun::star::plugin;
 using namespace osl;
-
-using ::rtl::OUString;
-using ::rtl::OString;
 
 class PluginDisposer : public salhelper::Timer
 {
@@ -99,8 +95,6 @@
     else
         release();
 }
-
-//==================================================================================================
 
 Any XPlugin_Impl::queryInterface( const Type& type ) throw( RuntimeException )
 {
@@ -964,20 +958,27 @@
     Guard< Mutex > aGuard( m_pPlugin->getMutex() );
 
     m_pPlugin->getInputStreams().push_back( this );
-    DirEntry aEntry;
-    aEntry = aEntry.TempName();
+    OUString aTmpFile;
+    osl::FileBase::createTempFile( 0, 0, &aTmpFile );
 
     // set correct extension, some plugins need that
-    DirEntry aName( String( m_aNPStream.url, m_pPlugin->getTextEncoding() ) );
-    String aExtension = aName.GetExtension();
-    if( aExtension.Len() )
-        aEntry.SetExtension( aExtension );
-    m_aFileStream.Open( aEntry.GetFull(), STREAM_READ | STREAM_WRITE );
+    OUString aName( m_aNPStream.url, strlen( m_aNPStream.url ), m_pPlugin->getTextEncoding() );
+    OUString aExtension;
+    sal_Int32 nSepInd = aName.lastIndexOf(".");
+    if( nSepInd != -1 )
+    {
+       aExtension = aName.copy( nSepInd + 1, aName.getLength() - nSepInd - 1 );
+    }
+    if( !aExtension.isEmpty() )
+    {
+        aTmpFile += aExtension;
+    }
+    m_aFileStream.Open( aTmpFile, STREAM_READ | STREAM_WRITE );
     if( ! m_aFileStream.IsOpen() )
     {
-        // #74808# might be that the extension scrambled the whole filename
-        aEntry = aEntry.TempName();
-        m_aFileStream.Open( aEntry.GetFull(), STREAM_READ | STREAM_WRITE );
+        // might be that the extension scrambled the whole filename
+        osl::FileBase::createTempFile( 0, 0, &aTmpFile );
+        m_aFileStream.Open( aTmpFile, STREAM_READ | STREAM_WRITE );
     }
 }
 
@@ -987,12 +988,12 @@
 
     m_pPlugin->getInputStreams().remove( this );
 
-    String aFile( m_aFileStream.GetFileName() );
+    OUString aFile( m_aFileStream.GetFileName() );
 
     m_aFileStream.Close();
     if( m_pPlugin )
     {
-        rtl::OString aFileName(rtl::OUStringToOString(aFile, m_pPlugin->getTextEncoding()));
+        OString aFileName(OUStringToOString(aFile, m_pPlugin->getTextEncoding()));
         if( m_pPlugin->getPluginComm() && m_nMode != -1 )
             // mode -1 means either an error occurred,
             // or the plugin is already disposing
@@ -1009,10 +1010,10 @@
             m_pPlugin->getInputStreams().remove( this );
         }
         else
-            DirEntry( m_aFileStream.GetFileName() ).Kill();
+            osl::File::remove( aFile );
     }
     else
-        DirEntry( m_aFileStream.GetFileName() ).Kill();
+        osl::File::remove( aFile );
     if( m_pContent )
         delete m_pContent;
 }

-- 
To view, visit https://gerrit.libreoffice.org/3119
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b2132e7441be1579f6233ec56fdaf8807a60b55
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Andras Timar <atimar at suse.com>



More information about the LibreOffice mailing list