Error in absolute path with File.getAbsultuePath()

Error in absolute path with File.getAbsultuePath()

Postby jokro » Tue Apr 15, 2014 8:33 pm

Hi,

I have a problem converting relative to absolute links. File.getAbsolutePath() or getAbsoluteFile() do not generate the expected value in situations when a directory is rerouted, e.g. the My documents directory is rerouted to a different disk, from C: to D:. In contrast, basic Freeplane does give the right absolute path if preferences is set to absolute hyperlinks. (I have the same problem on a network where "rerouting" or "virtual pathways" (I do not know the proper name) is applied.

Concrete case
If I set hyperlinks absolute, and i drag a file then freeplane generates link (uri):
file:/D:/Jodi_sync_TrueImage/Desktop/image-filenamame.png

Setting hyperlinks to relative, freeplane generates for this same file uri:
../../../../Jodi_sync_TrueImage/Desktop/image-filenamame.png

In the latter situation, applying File.getAbsolutePath() or getAbsoluteFile() I get file:/C:/Jodi_sync_TrueImage/Desktop/image-filenamame.png
The path is right except for the disk: "C" shoud be "D" ?

Is this a bug or should I use another method from Freeplane to get the absolute path ?

Thx
Jodi
jokro
 
Posts: 486
Joined: Sun Jul 24, 2011 2:56 pm

Re: Error in absolute path with File.getAbsultuePath()

Postby dpolivaev » Wed Apr 16, 2014 6:22 am

Code: Select all
         final UrlManager urlManager = (UrlManager) Controller.getCurrentModeController().getExtension(UrlManager.class);
         final URI absoluteUri = urlManager.getAbsoluteUri(map, uri);
User avatar
dpolivaev
Site Admin
 
Posts: 667
Joined: Sat Jul 23, 2011 1:21 pm

Re: Error in absolute path with File.getAbsultuePath()

Postby jokro » Wed Apr 16, 2014 2:23 pm

Dimitry, thank you
Jodi
jokro
 
Posts: 486
Joined: Sun Jul 24, 2011 2:56 pm


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 1 guest