|
32 | 32 | package org.scijava.script; |
33 | 33 |
|
34 | 34 | import java.io.File; |
35 | | -import java.io.IOException; |
36 | 35 | import java.io.Reader; |
37 | 36 | import java.io.StringReader; |
38 | 37 | import java.math.BigDecimal; |
@@ -106,8 +105,8 @@ public class DefaultScriptService extends |
106 | 105 | /** Menu prefix to use for each script directory, if any. */ |
107 | 106 | private HashMap<File, MenuPath> menuPrefixes; |
108 | 107 |
|
109 | | - /** Index of available scripts, by script <em>file</em>. */ |
110 | | - private HashMap<File, ScriptInfo> scripts; |
| 108 | + /** Index of available scripts, by script path. */ |
| 109 | + private HashMap<String, ScriptInfo> scripts; |
111 | 110 |
|
112 | 111 | /** Table of short type names to associated {@link Class}. */ |
113 | 112 | private HashMap<String, Class<?>> aliasMap; |
@@ -330,7 +329,7 @@ private HashMap<File, MenuPath> menuPrefixes() { |
330 | 329 | } |
331 | 330 |
|
332 | 331 | /** Gets {@link #scripts}, initializing if needed. */ |
333 | | - private HashMap<File, ScriptInfo> scripts() { |
| 332 | + private HashMap<String, ScriptInfo> scripts() { |
334 | 333 | if (scripts == null) initScripts(); |
335 | 334 | return scripts; |
336 | 335 | } |
@@ -386,13 +385,13 @@ private synchronized void initMenuPrefixes() { |
386 | 385 | private synchronized void initScripts() { |
387 | 386 | if (scripts != null) return; // already initialized |
388 | 387 |
|
389 | | - final HashMap<File, ScriptInfo> map = new HashMap<>(); |
| 388 | + final HashMap<String, ScriptInfo> map = new HashMap<>(); |
390 | 389 |
|
391 | 390 | final ArrayList<ScriptInfo> scriptList = new ArrayList<>(); |
392 | 391 | new ScriptFinder(this).findScripts(scriptList); |
393 | 392 |
|
394 | 393 | for (final ScriptInfo info : scriptList) { |
395 | | - map.put(asFile(info.getPath()), info); |
| 394 | + map.put(info.getPath(), info); |
396 | 395 | } |
397 | 396 |
|
398 | 397 | scripts = map; |
@@ -461,17 +460,6 @@ private ScriptInfo getOrCreate(final File file) { |
461 | 460 | return new ScriptInfo(getContext(), file); |
462 | 461 | } |
463 | 462 |
|
464 | | - private File asFile(final String path) { |
465 | | - final File file = new File(path); |
466 | | - try { |
467 | | - return file.getCanonicalFile(); |
468 | | - } |
469 | | - catch (final IOException exc) { |
470 | | - log.warn(exc); |
471 | | - return file.getAbsoluteFile(); |
472 | | - } |
473 | | - } |
474 | | - |
475 | 463 | @SuppressWarnings({ "rawtypes", "unchecked" }) |
476 | 464 | private Future<ScriptModule> cast(final Future<Module> future) { |
477 | 465 | return (Future) future; |
|
0 commit comments