Ignore:
Timestamp:
2014-06-14T12:40:50+02:00 (10 years ago)
Author:
bastiK
Message:

reworked MirroredInputStream (renamed to CachedFile):

  • no more awkwardly open and close InputStream if you just want the underlying file (e.g. to get file inside zip file)
  • make it easier to add configuration parameters, without having endless list of parameters for the constructor (Factory style, similar to ImageProvider)

breaks plugins; see #10139

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/FileWatcher.java

    r7244 r7248  
    5959            throw new IllegalStateException("File watcher is not available");
    6060        }
    61         try (MirroredInputStream mis = style.getMirroredInputStream()) {
    62             // Get underlying file
    63             File file = mis.getFile();
    64             if (file == null) {
    65                 throw new IllegalArgumentException("Style "+style+" does not have a local file");
    66             }
    67             // Get parent directory as WatchService allows only to monitor directories, not single files
    68             File dir = file.getParentFile();
    69             if (dir == null) {
    70                 throw new IllegalArgumentException("Style "+style+" does not have a parent directory");
    71             }
    72             synchronized(this) {
    73                 // Register directory. Can be called several times for a same directory without problem
    74                 // (it returns the same key so it should not send events several times)
    75                 dir.toPath().register(watcher, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE);
    76                 styleMap.put(file.toPath(), style);
    77             }
     61        CachedFile cf = style.getCachedFile();
     62        // Get underlying file
     63        File file = cf.getFile();
     64        if (file == null) {
     65            throw new IllegalArgumentException("Style "+style+" does not have a local file");
     66        }
     67        // Get parent directory as WatchService allows only to monitor directories, not single files
     68        File dir = file.getParentFile();
     69        if (dir == null) {
     70            throw new IllegalArgumentException("Style "+style+" does not have a parent directory");
     71        }
     72        synchronized(this) {
     73            // Register directory. Can be called several times for a same directory without problem
     74            // (it returns the same key so it should not send events several times)
     75            dir.toPath().register(watcher, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_CREATE);
     76            styleMap.put(file.toPath(), style);
    7877        }
    7978    }
Note: See TracChangeset for help on using the changeset viewer.