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

    Specify file/directory names that should not be used because they are not portable.

    /**
     * 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);
    
Search
    • Home