• Intro Headers Instructions Macros Commands
  • Fork me on GitHub
    • Introduction
    • How to install bnd
    • Guided Tour
    • Guided Tour Workspace & Projects
    • Concepts
    • Best practices
    • Build
    • Project Setup
    • Generating JARs
    • Versioning
    • Baselining
    • Service Components
    • Metatype
    • Contracts
    • Bundle Annotations
    • Accessor Properties
    • SPI Annotations
    • Resolving Dependencies
    • Launching
    • Startlevels
    • Testing
    • Testing with Launchpad
    • Packaging Applications
    • JPMS Libraries
    • Wrapping Libraries to OSGi Bundles
    • Generating Documentation
    • Commands
    • For Developers
    • Tips for Windows users
    • Tools bound to bnd
    • Headers
    • Instruction Reference
    • Instruction Index
    • Macro Reference
    • Macro Index
    • Plugins
    • External Plugins
    • Settings
    • Errors
    • Warnings
    • Frequently Asked Questions
  • -invalidfilenames

    /**
     * Verify of the path names in the JAR are valid on all OS's (mainly
     * windows)
     */
    void verifyPathNames() {
    	if (!since(About._2_3))
    		return;
    
    	Set<String> invalidPaths = new HashSet<String>();
    	Pattern pattern = ReservedFileNames;
    	setProperty("@", ReservedFileNames.pattern());
    	String p = getProperty(INVALIDFILENAMES);
    	unsetProperty("@");
    	if (p != null) {
    		try {
    			pattern = Pattern.compile(p, Pattern.CASE_INSENSITIVE);
    		}
    		catch (Exception e) {
    			SetLocation error = error("%s is not a valid regular expression %s: %s", INVALIDFILENAMES,
    					e.getMessage(), p);
    			error.context(p).header(INVALIDFILENAMES);
    			return;
    		}
    	}
    
    	Set<String> segments = new HashSet<String>();
    	for (String path : dot.getResources().keySet()) {
    		String parts[] = path.split("/");
    		for (String part : parts) {
    			if (segments.add(part) && pattern.matcher(part).matches()) {
    				invalidPaths.add(path);
    			}
    		}
    	}
    
    	if (invalidPaths.isEmpty())
    		return;
    
    	error("Invalid file/directory names for Windows in JAR: %s. You can set the regular expression used with %s, the default expression is %s",
    			invalidPaths, INVALIDFILENAMES, ReservedFileNames.pattern());
    }
    
    
    
    public final static Pattern	ReservedFileNames				= Pattern
    																	.compile(
    																			"CON(\\..+)?|PRN(\\..+)?|AUX(\\..+)?|CLOCK$|NUL(\\..+)?|COM[1-9](\\..+)?|LPT[1-9](\\..+)?|"
    																					+ "\\$Mft|\\$MftMirr|\\$LogFile|\\$Volume|\\$AttrDef|\\$Bitmap|\\$Boot|\\$BadClus|\\$Secure|"
    																					+ "\\$Upcase|\\$Extend|\\$Quota|\\$ObjId|\\$Reparse",
    																			Pattern.CASE_INSENSITIVE);
    
    • GitHub