Juergen Schmidt wrote:
Hi Ariel, Oliver,

well i didn't remember this UCB API when i have written my last comment on Olivers posting.

But Ariel pointed out that we have this API and that of course this API can be used to convert an URL into a system path. Advantage is that it can be used from Basic and other languages as well.
Just to stress Jürgen's point, here is an example in ooRexx drawn directly from Ariel's great example:

   xContext = UNO.connect()            -- connect to server, retrieve xContext
                                       -- define test filename
   sSystemPath="d:\über den Wölkchen\muß die Freiheit wohl...txt"
   sBase      =""
   say "sSystemPath:    ["sSystemPath"]"

   uriFileName=convertToURL(xContext, sBase, sSystemPath)
   say "uriFileName:    ["uriFileName"]"

   systemFileName=convertFromURL(xContext, uriFileName)
   say "systemFileName: ["systemFileName"]"

   ::requires UNO.CLS      -- get the UNO support

   ::routine convertFromURL      public
     use arg xContext, sFileURL

     service="com.sun.star.ucb.FileContentProvider"
     xMCf = xContext~getServiceManager   -- retrieve XMultiComponentFactory
     xFileConverter=xMCF~createInstanceWithContext(service,xContext) 
~XFileIdentifierConverter
     return xFileConverter~getSystemPathFromFileURL(sFileURL)

   ::routine convertToURL       public
     use arg xContext, sBase, sSystemPath

     service="com.sun.star.ucb.FileContentProvider"
     xMCf = xContext~getServiceManager   -- retrieve XMultiComponentFactory
     xFileConverter=xMCF~createInstanceWithContext(service,xContext) 
~XFileIdentifierConverter
     return xFileConverter~getFileURLFromSystemPath(sBase,sSystemPath)
Running it yields:

   sSystemPath:    [d:\über den Wölkchen\muß die Freiheit wohl...txt]
   uriFileName:    
[file:///d:/%C3%BCber%20den%20W%C3%B6lkchen/mu%C3%9F%20die%20Freiheit%20wohl...txt]
   systemFileName: [d:\über den Wölkchen\muß die Freiheit wohl...txt]
---rony


Reply via email to