code: public static Resource createResource(Resource res, short level, short type) {
  
  	boolean asDir = type == TYPE_DIR;
  	// File
  	if (level >= LEVEL_FILE && res.exists() && ((res.isDirectory() && asDir) || (res.isFile() && !asDir))) {
  	    return getCanonicalResourceEL(res);
  	}
  
  	// Parent
  	Resource parent = res.getParentResource();
  	if (level >= LEVEL_PARENT_FILE && parent != null && parent.exists() && canRW(parent)) {
  	    if (asDir) {
  		if (res.mkdirs()) return getCanonicalResourceEL(res);
  	    }
  	    else {
  		if (createNewResourceEL(res)) return getCanonicalResourceEL(res);
  	    }
  	    return getCanonicalResourceEL(res);
  	}
  
  	// Grand Parent
  	if (level >= LEVEL_GRAND_PARENT_FILE && parent != null) {
  	    Resource gparent = parent.getParentResource();
  	    if (gparent != null && gparent.exists() && canRW(gparent)) {
  		if (asDir) {
  		    if (res.mkdirs()) return getCanonicalResourceEL(res);
  		}
  		else {
  		    if (parent.mkdirs() && createNewResourceEL(res)) return getCanonicalResourceEL(res);
  		}
  	    }
  	}
  	return null;
      }
docs: create a file if possible, return file if ok, otherwise return null
  
  @param res file to touch
  @param level touch also parent and grand parent
  @param type is file or directory
  @return file if exists, otherwise null