示例#1
0
 protected String replaceExt(String filename, String ext) {
   int index = filename.indexOf('#');
   if (index < 0) {
     return Filenames.replaceExt(filename, ext);
   }
   return Filenames.replaceExt(filename.substring(0, index), ext) + filename.substring(index);
 }
示例#2
0
  public void checkRedundantFileExt(String filename) {
    if (filename == null || !checkFileExt) {
      return;
    }

    if (!checkedFilenames.add(filename)) {
      return;
    }

    // If the file has an extension, isn't valid, but would be valid with a different extension...
    if (!Filenames.getExtension(filename).isEmpty() && !isValidFilename(filename)) {
      ResourceId resourceId = resolveResource(filename);
      if (resourceId != null && isValidFilename(resourceId.getCanonicalFilename())) {
        LOG.warn("Incorrect file extension: {}", filename);
      }
    }

    // Check if a file extension in the default list has been specified.
    for (String ext : autoFileExts) {
      if (filename.endsWith("." + ext)) {
        if (isValidFilename(filename)) {
          LOG.debug("You don't need to specify the file extension: {}", filename);
        }
        break;
      }
    }
  }