static String computeShortName(Manifest manifest, String fileName) { // use the name captured in the manifest, as often plugins // depend on the specific short name in its URLs. String n = manifest.getMainAttributes().getValue("Short-Name"); if(n!=null) return n; // maven seems to put this automatically, so good fallback to check. n = manifest.getMainAttributes().getValue("Extension-Name"); if(n!=null) return n; // otherwise infer from the file name, since older plugins don't have // this entry. return getBaseName(fileName); }
protected String identifyPluginShortName(File t) { try { JarFile j = new JarFile(t); try { String name = j.getManifest().getMainAttributes().getValue("Short-Name"); if (name!=null) return name; } finally { j.close(); } } catch (IOException e) { LOGGER.log(WARNING, "Failed to identify the short name from "+t,e); } return FilenameUtils.getBaseName(t.getName()); // fall back to the base name of what's uploaded }
public String getInputId() { return FilenameUtils.getBaseName(inputFile.getPath()); } }
@Override public String getProblemName() { return FilenameUtils.getBaseName(problemFile.getName()); }
public String getInputId() { return FilenameUtils.getBaseName(inputFile.getPath()); }
@Override public String getInputId() { return FilenameUtils.getBaseName(inputFile.getParentFile().getPath()); }
@Override public String getInputId() { return FilenameUtils.getBaseName(inputFile.getParentFile().getPath()); }
private void generateChannelApk(final File inputFile, final File outputDir, final String channel) { final String name = FilenameUtils.getBaseName(inputFile.getName()); final String extension = FilenameUtils.getExtension(inputFile.getName()); final String newName = name + "_" + channel + "." + extension; final File channelApk = new File(outputDir, newName); try { FileUtils.copyFile(inputFile, channelApk); ChannelWriter.put(channelApk, channel, extraInfo); } catch (IOException | SignatureNotFoundException e) { e.printStackTrace(); } } }
private void generateChannelApk(final File inputFile, final File outputDir, final String channel, final String alias, final Map<String, String> extraInfo) { final String channelName = alias == null ? channel : alias; final String name = FilenameUtils.getBaseName(inputFile.getName()); final String extension = FilenameUtils.getExtension(inputFile.getName()); final String newName = name + "_" + channelName + "." + extension; final File channelApk = new File(outputDir, newName); try { FileUtils.copyFile(inputFile, channelApk); ChannelWriter.put(channelApk, channel, extraInfo); } catch (IOException | SignatureNotFoundException e) { e.printStackTrace(); } } }
public static String getRuleSetFilename(String rulesetFileName) { return FilenameUtils.getBaseName(StringUtils.chomp(rulesetFileName)); }
/** * Construct filename for a late file. If the file does not exists in the output dir, retain the original name. * Otherwise, append a LATE_COMPONENT{RandomInteger} to the original file name. * For example, if file "part1.123.avro" exists in dir "/a/b/", the returned path will be "/a/b/part1.123.late12345.avro". */ public Path constructLateFilePath(String originalFilename, FileSystem fs, Path outputDir) throws IOException { if (!fs.exists(new Path(outputDir, originalFilename))) { return new Path(outputDir, originalFilename); } return constructLateFilePath(FilenameUtils.getBaseName(originalFilename) + LATE_COMPONENT + new Random().nextInt(Integer.MAX_VALUE) + SEPARATOR + FilenameUtils.getExtension(originalFilename), fs, outputDir); }
/** Maps paths to classes. */ private static Stream<Class<?>> getClasses(URL url, String packageName) throws IOException, URISyntaxException { return getPathsInDir(url) .stream() .filter(path -> "class".equalsIgnoreCase(FilenameUtils.getExtension(path.toString()))) .<Class<?>>map(path -> { try { return Class.forName(packageName + "." + FilenameUtils.getBaseName(path.getFileName().toString())); } catch (ClassNotFoundException e) { e.printStackTrace(); return null; } }) .filter(Objects::nonNull); }
public static Result run(String inPaths, String pkgName) throws IOException, ClassHierarchyException, IllegalArgumentException { String outPath = ""; String firstInPath = inPaths.split(",")[0]; if (firstInPath.endsWith(".jar") || firstInPath.endsWith(".aar")) { outPath = FilenameUtils.getFullPath(firstInPath) + FilenameUtils.getBaseName(firstInPath) + MODEL_JAR_SUFFIX; } else if (new File(firstInPath).exists()) { outPath = FilenameUtils.getFullPath(firstInPath) + DEFAULT_ASTUBX_LOCATION; } return run(inPaths, pkgName, outPath, DEBUG, VERBOSE); } /**
@Test public void testGetBaseName() { assertEquals(null, FilenameUtils.getBaseName(null)); assertEquals("noseperator", FilenameUtils.getBaseName("noseperator.inthispath")); assertEquals("c", FilenameUtils.getBaseName("a/b/c.txt")); assertEquals("c", FilenameUtils.getBaseName("a/b/c")); assertEquals("", FilenameUtils.getBaseName("a/b/c/")); assertEquals("c", FilenameUtils.getBaseName("a\\b\\c")); assertEquals("file.txt", FilenameUtils.getBaseName("file.txt.bak")); }
@Override protected void handleFile(File file, int depth, Collection results) { String fileName = file.getName(); if (!FilenameUtils.getExtension(fileName).equalsIgnoreCase(XML_EXTENSION)) { return; } String xmlContentOfFie = safeReadFileToString(file); if (xmlContentOfFie == null || !file.canRead()) { serverHealthService.update(ServerHealthState.warning("Command Repository", "Failed to access command snippet XML file located in Go Server Directory at " + file.getPath() + ". Go does not have sufficient permissions to access it.", HealthStateType.commandRepositoryAccessibilityIssue(), systemEnvironment.getCommandRepoWarningTimeout())); LOGGER.warn("[Command Repository] Failed to access command snippet XML file located in Go Server Directory at {}. Go does not have sufficient permissions to access it.", file.getAbsolutePath()); return; } try { String relativeFilePath = FileUtil.removeLeadingPath(commandRepositoryBaseDirectory.get(), file.getAbsolutePath()); results.add(commandSnippetXmlParser.parse(xmlContentOfFie, FilenameUtils.getBaseName(fileName), relativeFilePath)); } catch (Exception e) { LOGGER.warn("Failed loading command snippet from {}", file.getAbsolutePath()); LOGGER.debug(null, e); } }
@Override public void init(RootNode root) { List<DexNode> dexNodes = root.getDexNodes(); if (dexNodes.isEmpty()) { return; } InputFile firstInputFile = dexNodes.get(0).getDexFile().getInputFile(); String firstInputFileName = firstInputFile.getFile().getAbsolutePath(); String inputPath = FilenameUtils.getFullPathNoEndSeparator(firstInputFileName); String inputName = FilenameUtils.getBaseName(firstInputFileName); File deobfMapFile = new File(inputPath, inputName + ".jobf"); JadxArgs args = root.getArgs(); deobfuscator = new Deobfuscator(args, dexNodes, deobfMapFile); boolean deobfuscationOn = args.isDeobfuscationOn(); if (deobfuscationOn) { deobfuscator.execute(); } boolean isCaseSensitive = FileUtils.isCaseSensitiveFS(new File(inputPath)); // args.getOutDir() - not set in gui checkClasses(root, isCaseSensitive); }
@Test public void testGetBaseName_with_nullByte() { try { assertEquals("file.txt", FilenameUtils.getBaseName("fil\u0000e.txt.bak")); } catch (final IllegalArgumentException ignore) { } }
@Override public TspSolution readSolution() throws IOException { tspSolution = new TspSolution(); tspSolution.setId(0L); tspSolution.setName(FilenameUtils.getBaseName(inputFile.getName())); floydSteinbergDithering(); createVisitList(); BigInteger possibleSolutionSize = factorial(tspSolution.getLocationList().size() - 1); logger.info("TspSolution {} has {} locations with a search space of {}.", getInputId(), tspSolution.getLocationList().size(), getFlooredPossibleSolutionSize(possibleSolutionSize)); return tspSolution; }
@BeforeStep public void createOutputNameFromInput(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); } if (!executionContext.containsKey(outputKeyName)) { executionContext.putString(outputKeyName, path + FilenameUtils.getBaseName(inputName) + ".csv"); } }
/** Keys for overriding default layer properties */ public static class StyleProperty<T> { T get(Map<StyleProperty, Object> map, T def) { return map != null && map.containsKey(this) ? (T) map.get(this) : def; } public static StyleProperty<String> FORMAT = new StyleProperty<String>(); public static StyleProperty<Version> FORMAT_VERSION = new StyleProperty<Version>(); public static StyleProperty<LegendInfo> LEGEND_INFO = new StyleProperty<LegendInfo>(); }