private CMFolder createIntermediateFolders ( CMFolder cmRoot , CPath cpath ) { List < String > baseNames = cpath . split ( ) ; CMFolder currentFolder = cmRoot ; CMFolder childFolder = null ; boolean firstFolderCreation = true ; for ( String baseName : baseNames ) { childFolder = currentFolder . getChildByName ( baseName ) ; if ( childFolder == null ) { // Intermediate folder does not exist : has to be created if ( firstFolderCreation ) { // This is the first intermediate folder to create: // let's check that there is no blob with that name already existing try { CMBlob cmBlob = getBlobByName ( currentFolder , baseName ) ; if ( cmBlob != null ) { throw new CInvalidFileTypeException ( cmBlob . getPath ( ) , false ) ; } } catch ( ParseException e ) { throw new CStorageException ( e . getMessage ( ) , e ) ; } firstFolderCreation = false ; } childFolder = rawCreateFolder ( currentFolder , baseName ) ; } currentFolder = childFolder ; } return childFolder ; }
Creates folder with given path with required intermediate folders .