Changeset 13927 in osm for applications/editors/josm/plugins/wmsplugin
- Timestamp:
- 2009-02-28T20:34:43+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Cache.java
r13645 r13927 4 4 import java.io.File; 5 5 import java.io.FileFilter; 6 import java.math.BigInteger; 7 import java.security.MessageDigest; 6 8 import java.util.Date; 7 9 import java.util.Iterator; … … 9 11 import java.util.TreeMap; 10 12 import javax.imageio.*; 13 11 14 12 15 import org.openstreetmap.josm.Main; … … 127 130 } 128 131 129 private String clean(String ident) { 130 return ident.replaceAll("[^a-zA-Z0-9]", ""); 132 private static String getUniqueFilename(String ident) { 133 try { 134 MessageDigest md = MessageDigest.getInstance("MD5"); 135 BigInteger number = new BigInteger(1, md.digest(ident.getBytes())); 136 return number.toString(16); 137 } catch(Exception e) { 138 // Fall back. Remove unsuitable characters and some random ones to shrink down path length. 139 // Limit it to 70 characters, that leaves about 190 for the path on Windows/NTFS 140 ident = ident.replaceAll("[^a-zA-Z0-9]", ""); 141 ident = ident.replaceAll("[acegikmoqsuwy]", ""); 142 return ident.substring(ident.length() - 70); 143 } 131 144 } 132 145 133 146 private File getPath(String ident) { 134 return new File(dir, clean(ident) + ".png");147 return new File(dir, getUniqueFilename(ident) + ".png"); 135 148 } 136 149 }
Note:
See TracChangeset
for help on using the changeset viewer.