diff options
author | Mathias Bauer <mba@openoffice.org> | 2000-12-07 10:29:57 +0000 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2000-12-07 10:29:57 +0000 |
commit | 3bb9abc0ae8b1915eccd3fe415bb8473162b419c (patch) | |
tree | 8268820ac54b6bc6f2dc12afb34e21850df18bc9 /unotools | |
parent | cb6d3ff7ea5b0e019978316641dc7ac97433fb85 (diff) |
#80466#: new helper methods to convert filenames
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/inc/unotools/localfilehelper.hxx | 6 | ||||
-rw-r--r-- | unotools/source/ucbhelper/localfilehelper.cxx | 46 |
2 files changed, 48 insertions, 4 deletions
diff --git a/unotools/inc/unotools/localfilehelper.hxx b/unotools/inc/unotools/localfilehelper.hxx index 74167a9584fc..bf569ab80334 100644 --- a/unotools/inc/unotools/localfilehelper.hxx +++ b/unotools/inc/unotools/localfilehelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: localfilehelper.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mba $ $Date: 2000-12-01 11:45:37 $ + * last change: $Author: mba $ $Date: 2000-12-07 11:29:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,6 +83,7 @@ public: Returning sal_True and an empty URL means that the URL doesn't point to a local file. */ static sal_Bool ConvertPhysicalNameToURL( const String& rName, String& rReturn ); + static sal_Bool ConvertSystemPathToURL( const String& rName, const String& rBaseURL, String& rReturn ); /** Converts a "UCB compatible" URL into a "physical" file name. @@ -91,6 +92,7 @@ public: file system is present ( watch: this doesn't mean that this file really exists! ) */ static sal_Bool ConvertURLToPhysicalName( const String& rName, String& rReturn ); + static sal_Bool ConvertURLToSystemPath( const String& rName, String& rReturn ); static sal_Bool IsLocalFile( const String& rName ); diff --git a/unotools/source/ucbhelper/localfilehelper.cxx b/unotools/source/ucbhelper/localfilehelper.cxx index 3aea48144da2..5c36857e4b55 100644 --- a/unotools/source/ucbhelper/localfilehelper.cxx +++ b/unotools/source/ucbhelper/localfilehelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: localfilehelper.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: vg $ $Date: 2000-12-04 10:50:59 $ + * last change: $Author: mba $ $Date: 2000-12-07 11:29:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,6 +87,48 @@ using namespace ::com::sun::star::ucb; namespace utl { +sal_Bool LocalFileHelper::ConvertSystemPathToURL( const String& rName, const String& rBaseURL, String& rReturn ) +{ + rtl::OUString aRet; + ::ucb::ContentBroker* pBroker = ::ucb::ContentBroker::get(); + if ( !pBroker ) + { + ::rtl::OUString aTmp; + FileBase::normalizePath( rName, aTmp ); + FileBase::getFileURLFromNormalizedPath( aTmp, aRet ); + } + else + { + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentProviderManager > xManager = + pBroker->getContentProviderManagerInterface(); + aRet = ::ucb::getFileURLFromSystemPath( xManager, rBaseURL, aRet ); + } + + rReturn = aRet; + return ( aRet.getLength() != 0 ); +} + +sal_Bool LocalFileHelper::ConvertURLToSystemPath( const String& rName, String& rReturn ) +{ + rtl::OUString aRet; + ::ucb::ContentBroker* pBroker = ::ucb::ContentBroker::get(); + if ( !pBroker ) + { + ::rtl::OUString aTmp; + FileBase::getNormalizedPathFromFileURL( rName, aTmp ); + FileBase::getSystemPathFromNormalizedPath( aTmp, aRet ); + } + else + { + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentProviderManager > xManager = + pBroker->getContentProviderManagerInterface(); + aRet = ::ucb::getSystemPathFromFileURL( xManager, rName, rName ); + } + + rReturn = aRet; + return sal_True; +} + sal_Bool LocalFileHelper::ConvertPhysicalNameToURL( const String& rName, String& rReturn ) { rtl::OUString aRet; |