Changeset 1543


Ignore:
Timestamp:
11/18/20 11:15:44 (3 years ago)
Author:
davidb
Message:

When unpacking resources from a JAR file, important that when specifying a directory, it ends in the directory separator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r1538 r1543  
    18311831                        // Extract private resources
    18321832                        Path resourcesPrivate = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-private");
    1833                         extractResources("org/expeditee/assets/resources-private", resourcesPrivate, force);
     1833                        extractResources("org/expeditee/assets/resources-private/", resourcesPrivate, force);
    18341834                       
    18351835                        // Extract public resources
    18361836                        Path resourcesPublic = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-public");
    1837                         extractResources("org/expeditee/assets/resources-public", resourcesPublic, force);
     1837                        extractResources("org/expeditee/assets/resources-public/", resourcesPublic, force);
    18381838                } else if (AuthenticatorBrowser.isAuthenticationRequired()) {
    18391839                        // Deal with the instance of being in the old regime but using authentication.
     
    18411841                        // Ensure additional framesets
    18421842                        Path framesetsDir = Paths.get(FrameIO.FRAME_PATH);
    1843                         boolean extracted = extractResources("org/expeditee/assets/resources-public/framesets", framesetsDir, force);
     1843                        boolean extracted = extractResources("org/expeditee/assets/resources-public/framesets/", framesetsDir, force);
    18441844                       
    18451845                        // Ensure additional images
    18461846                        Path imagesDir = Paths.get(FrameIO.IMAGES_PATH);
    1847                         extracted |= extractResources("org/expeditee/assets/resources-public/images", imagesDir, force);
     1847                        extracted |= extractResources("org/expeditee/assets/resources-public/images/", imagesDir, force);
    18481848                       
    18491849                        // Ensure deaddrops area exists
     
    18961896        private static boolean extractResources(String source, Path destination, boolean force) {
    18971897                // If resources have already been extracted, and we are not forcing the extraction, there is nothing to do.
     1898       
    18981899                if (!force && destination.resolve(".res").toFile().exists()) {
    18991900                        return false;
     
    19071908                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    19081909                URL resourceUrl = classLoader.getResource(source);
     1910               
    19091911                if (resourceUrl.getProtocol().equals("jar")) {
    19101912                        try {
     
    19591961                                continue;
    19601962                        }
    1961                         File out = destination.resolve(ze.getName().substring(source.length())).toFile();
     1963                       
     1964                        // Note:
     1965                        //   'source' needs to be specified as directory ending in a "/"
     1966                        // If it doesn't then 'ze_name_rel' incorrectly presents as an absolute name
     1967                        //
     1968                        // As this is a private method, the "/" requirement is considered a reasonable
     1969                        // requirement to ensure is applied within this class.
     1970                       
     1971                        String ze_name = ze.getName();         
     1972                        String ze_name_rel = ze_name.substring(source.length());                       
     1973                       
     1974                        File out = destination.resolve(ze_name_rel).toFile();
     1975                       
    19621976                        if (ze.isDirectory()) {
    19631977                                out.mkdirs();
Note: See TracChangeset for help on using the changeset viewer.