MapTool: directory file separators?

Progress reports and musings from the developers on the current gaming tools.

Moderators: dorpond, trevor, Azhrei

Post Reply
User avatar
Blakey
Dragon
Posts: 778
Joined: Fri Mar 23, 2007 11:27 am
Location: Sussex, UK.

MapTool: directory file separators?

Post by Blakey »

Hey all,

Does MapTool explicitly set the directory file separator to '/'?

I'm asking because I can now create tokens (yay!) but when I come to save any token into a file I have just created, it fails. The failure is because it cannot match the assets on the token in memory with the assets in my token on disk. And I believe the reason is that the assets of the token in memory are held as "asset/<md5key>" and mine are held as "asset\\<md5key>".

I'm developing on Windows but am hard coding all my file separators as '/', yet the JVM is, I guess, converting them to '\\' as I'm on windows.

Any way around this?

Cheers
Blakey
The guy in the green hat.

eRaz0r
Cave Troll
Posts: 41
Joined: Sun Mar 28, 2010 12:29 am

Re: MapTool: directory file separators?

Post by eRaz0r »

try

File.separator


or

System.getProperty("file.separator")

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: MapTool: directory file separators?

Post by Azhrei »

Blakey wrote:The failure is because it cannot match the assets on the token in memory with the assets in my token on disk. And I believe the reason is that the assets of the token in memory are held as "asset/<md5key>" and mine are held as "asset\\<md5key>".
I'm not sure what this means.

Assets in memory are not referenced as filenames at all in MapTool. The MD5 sum is simply used as a key into a HashMap structure (in most places, anyway).

In any case, the docs for the java.io.File class have a lot of information about how to properly handle path separators. When I made coding changes to an existing file that used '/' I generally changed it to File.separator. That caused a lengthy email dialogue between Trevor and I about which was correct and in what circumstances. I was right of course 8), but I decided to let the topic die since the situations where it was being used didn't matter. (Any time a File object is being created or manipulated, it doesn't matter whether you use File.separator or '/'. You can view the source code for java.io.File if you want to see exactly why. But note that any I/O operations in which the File object is converted to a string and written out will use File.separator.)

Post Reply

Return to “Developer Notes”