cdm/src/main/java/ucar/nc2/util/DiskCache2.java
private String makeCachePath(String fileLocation) {

    // remove ':', '?', '=', replace '\' with '/', leading or trailing '/'
    String cachePath = fileLocation;
    cachePath = StringUtil2.remove(cachePath, '?');
    cachePath = StringUtil2.remove(cachePath, '=');
    cachePath = StringUtil2.replace(cachePath, '\\', "/");
    if (cachePath.startsWith("/"))
      cachePath = cachePath.substring(1);
    if (cachePath.endsWith("/"))
      cachePath = cachePath.substring(0, cachePath.length()-1);
    cachePath = StringUtil2.remove(cachePath, ':');

    // remove directories
    if (cachePathPolicy == CachePathPolicy.OneDirectory) {
      cachePath = StringUtil2.replace(cachePath, '/', "-");
    }

    // eliminate leading directories
    else if (cachePathPolicy == CachePathPolicy.NestedTruncate) {
      int pos = cachePath.indexOf(cachePathPolicyParam);
      if (pos >= 0)
        cachePath = cachePath.substring(pos+cachePathPolicyParam.length());
      if (cachePath.startsWith("/"))
        cachePath = cachePath.substring(1);
    }

    // make sure the parent directory exists
    if (cachePathPolicy != CachePathPolicy.OneDirectory) {
      File file = new File(root + cachePath);
      File parent = file.getParentFile();
      if (!parent.exists()) {
        if (root == null) { // LOOK shouldnt happen, remove soon
          System.out.printf("mkdir4 %s%n", parent.getPath());
          new Throwable().printStackTrace();
        }
        boolean ret = parent.mkdirs();
        if (!ret) cacheLog.warn("Error creating parent: " + parent);
      }
    }

    return root + cachePath;
  }
private String makeCachePath(String fileLocation) {

    // remove ':', '?', '=', replace '\' with '/', leading or trailing '/'
    String cachePath = fileLocation;
    cachePath = StringUtil2.remove(cachePath, '?');
    cachePath = StringUtil2.remove(cachePath, '=');
    cachePath = StringUtil2.replace(cachePath, '\\', "/");
    if (cachePath.startsWith("/"))
      cachePath = cachePath.substring(1);
    if (cachePath.endsWith("/"))
      cachePath = cachePath.substring(0, cachePath.length()-1);
    cachePath = StringUtil2.remove(cachePath, ':');

    // remove directories
    if (cachePathPolicy == CachePathPolicy.OneDirectory) {
      cachePath = StringUtil2.replace(cachePath, '/', "-");
    }

    // eliminate leading directories
    else if (cachePathPolicy == CachePathPolicy.NestedTruncate) {
      int pos = cachePath.indexOf(cachePathPolicyParam);
      if (pos >= 0)
        cachePath = cachePath.substring(pos+cachePathPolicyParam.length());
      if (cachePath.startsWith("/"))
        cachePath = cachePath.substring(1);
    }

    // make sure the parent directory exists
    if (cachePathPolicy != CachePathPolicy.OneDirectory) {
      File file = new File(root + cachePath);
      File parent = file.getParentFile();
      if (!parent.exists()) {
        if (root == null) { // LOOK shouldnt happen, remove soon
          System.out.printf("mkdir4 %s%n", parent.getPath());
          new Throwable().printStackTrace();
        }
        boolean ret = parent.mkdirs();
        if (!ret) cacheLog.warn("Error creating parent: " + parent);
      }
    }

    return root + cachePath;
  }
private String makeCachePath ( String fileLocation ) { // remove ':', '?', '=', replace '\' with '/', leading or trailing '/' String cachePath = fileLocation ; cachePath = StringUtil2 . remove ( cachePath , ' ' ) ; cachePath = StringUtil2 . remove ( cachePath , ' ' ) ; cachePath = StringUtil2 . replace ( cachePath , ' ' , "/" ) ; if ( cachePath . startsWith ( "/" ) ) cachePath = cachePath . substring ( 1 ) ; if ( cachePath . endsWith ( "/" ) ) cachePath = cachePath . substring ( 0 , cachePath . length ( ) - 1 ) ; cachePath = StringUtil2 . remove ( cachePath , ' ' ) ; // remove directories if ( cachePathPolicy == CachePathPolicy . OneDirectory ) { cachePath = StringUtil2 . replace ( cachePath , ' ' , "-" ) ; } // eliminate leading directories else if ( cachePathPolicy == CachePathPolicy . NestedTruncate ) { int pos = cachePath . indexOf ( cachePathPolicyParam ) ; if ( pos >= 0 ) cachePath = cachePath . substring ( pos + cachePathPolicyParam . length ( ) ) ; if ( cachePath . startsWith ( "/" ) ) cachePath = cachePath . substring ( 1 ) ; } // make sure the parent directory exists if ( cachePathPolicy != CachePathPolicy . OneDirectory ) { File file = new File ( root + cachePath ) ; File parent = file . getParentFile ( ) ; if ( ! parent . exists ( ) ) { if ( root == null ) { // LOOK shouldnt happen, remove soon System . out . printf ( "mkdir4 %s%n" , parent . getPath ( ) ) ; new Throwable ( ) . printStackTrace ( ) ; } boolean ret = parent . mkdirs ( ) ; if ( ! ret ) cacheLog . warn ( "Error creating parent: " + parent ) ; } } return root + cachePath ; }
Make the cache filename
@param fileLocation normal file location
@return cache filename
Make the cache filename