private static String getThemeName(AbstractFile themeFile) { return themeFile.getNameWithoutExtension(); }
/** * Checks if CRC file exists. * @param file firts part */ private void findCRCFile(AbstractFile file) { AbstractFile f = file.getParent(); if (f != null) { try { crcFile = f.getDirectChild(file.getNameWithoutExtension() + ".sfv"); } catch (IOException e) { LOGGER.debug("Caught exception", e); } } }
/** * Tests the <code>$b</code> keyword. */ @Test public void testBasenameSubstitution() { String[] tokens; // Makes sure single file substitution works. tokens = Command.getTokens("$b", files[0]); assert 1 == tokens.length; assert files[0].getNameWithoutExtension().equals(tokens[0]); // Makes sure multiple file substitution works. tokens = Command.getTokens("$b", files); assert files.length == tokens.length; for(int i = 0; i < 3; i++) assert files[i].getNameWithoutExtension().equals(tokens[i]); }
/** * Gets the value from <code>file</code> that should be used to replace <code>keyword</code>. * @param keyword character to replace. * @param file file from which to retrieve the replacement value. * @return the requested replacement value. */ private static String getKeywordReplacement(char keyword, AbstractFile file) { switch(keyword) { case KEYWORD_PATH: return file.getAbsolutePath(); case KEYWORD_NAME: return file.getName(); case KEYWORD_PARENT: AbstractFile parentFile = file.getParent(); return parentFile==null?"":parentFile.getAbsolutePath(); case KEYWORD_VM_PATH: return new File(System.getProperty("user.dir")).getAbsolutePath(); case KEYWORD_EXTENSION: String extension; if((extension = file.getExtension()) == null) return ""; return extension; case KEYWORD_NAME_WITHOUT_EXTENSION: return file.getNameWithoutExtension(); } throw new IllegalArgumentException(); }
if (classFilter.accept(currentClass = Class.forName(currentPackage + file.getNameWithoutExtension(), false, loader))) result.add(currentClass);
@Override protected PathFieldContent computeInitialPath(FileSet files) { String initialPath = mainFrame.getInactivePanel().getCurrentFolder().getAbsolutePath(true); AbstractFile file; String fileName; // Computes the archive's default name: // - if it only contains one file, uses that file's name. // - if it contains more than one file, uses the FileSet's parent folder's name. if(files.size() == 1) { file = files.elementAt(0); fileName = file.isDirectory() && !DesktopManager.isApplication(file) ?file.getName() :file.getNameWithoutExtension(); } else { file = files.getBaseFolder(); fileName = file.isRoot()?"":DesktopManager.isApplication(file)?file.getNameWithoutExtension():file.getName(); } return new PathFieldContent(initialPath + fileName + "." + Archiver.getFormatExtension(lastFormat), initialPath.length(), initialPath.length() + fileName.length()); }
@Override protected PathFieldContent computeInitialPath(FileSet files) { String path = destFolder.getAbsolutePath(true) + files.elementAt(0).getNameWithoutExtension(); if (files.size() == 1) { searchParts(files.elementAt(0)); } return new PathFieldContent(path); }
String initialValue = mkfileMode ? currentFile.getName() : currentFile.getNameWithoutExtension(); if (initialValue != null) { pathField.setText(initialValue);
/** * It is possible to add several files with same name to the Trash. These files are distinguished * by _N appended to the name, where _N is rising int number. <br/> * This method tries to find first empty <code>filename_N.ext</code>. * * @param file File to be deleted * @return Suitable filename in trash (without .trashinfo extension) */ private String getUniqueFilename(AbstractFile file) throws IOException { // try if no previous file in trash exists if (!TRASH_FILES_SUBFOLDER.getChild(file.getName()).exists()) return file.getName(); String rawName = file.getNameWithoutExtension(); String extension = file.getExtension(); // find first empty filename in format filename_N.ext String filename; int count = 1; while(true) { filename = rawName + "_" + count++; if(extension!=null) filename += "." + extension; if(!TRASH_FILES_SUBFOLDER.getChild(filename).exists()) return filename; } } }
new StartsWithFilenameFilter(part1.getNameWithoutExtension(), false), new AttributeFileFilter(FileAttribute.FILE), new EqualsFilenameFilter(part1.getName(), false, true)
/** * It is possible to add several files with same name to the Trash. These files are distinguished * by _N appended to the name, where _N is rising int number. <br/> * This method tries to find first empty <code>filename_N.ext</code>. * * @param file File to be deleted * @return Suitable filename in trash (without .trashinfo extension) */ private String getUniqueFilename(AbstractFile file) throws IOException { // try if no previous file in trash exists if (!TRASH_FILES_SUBFOLDER.getChild(file.getName()).exists()) return file.getName(); String rawName = file.getNameWithoutExtension(); String extension = file.getExtension(); // find first empty filename in format filename_N.ext String filename; int count = 1; while(true) { filename = rawName + "_" + count++; if(extension!=null) filename += "." + extension; if(!TRASH_FILES_SUBFOLDER.getChild(filename).exists()) return filename; } } }
insertPattern("[C]"); } else if (source == btnNameRange) { String firstFile = files.get(0).getNameWithoutExtension(); BatchRenameSelectRange dlg = new BatchRenameSelectRange(this, firstFile); dlg.showDialog();