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
MapTool: directory file separators?
Moderators: dorpond, trevor, Azhrei
MapTool: directory file separators?
The guy in the green hat.
Re: MapTool: directory file separators?
try
File.separator
or
System.getProperty("file.separator")
File.separator
or
System.getProperty("file.separator")
Re: MapTool: directory file separators?
I'm not sure what this means.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>".
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 , 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.)