public static Folder createFolderPath ( final SecurityContext securityContext , final String path ) throws FrameworkException { final App app = StructrApp . getInstance ( securityContext ) ; if ( path == null ) { return null ; } Folder folder = ( Folder ) FileHelper . getFileByAbsolutePath ( securityContext , path ) ; if ( folder != null ) { return folder ; } String [ ] parts = PathHelper . getParts ( path ) ; String partialPath = "" ; for ( String part : parts ) { // ignore ".." and "." in paths if ( ".." . equals ( part ) || "." . equals ( part ) ) { continue ; } Folder parent = folder ; partialPath += PathHelper . PATH_SEP + part ; folder = ( Folder ) FileHelper . getFileByAbsolutePath ( securityContext , partialPath ) ; if ( folder == null ) { folder = app . create ( Folder . class , part ) ; } if ( parent != null ) { folder . setParent ( parent ) ; } } return folder ; }
Create one folder per path item and return the last folder .