@ SuppressWarnings ( { "JavaDoc" } ) private void addParentDirs ( ArchiveEntry archiveEntry , File baseDir , String entry , ZipArchiveOutputStream zOut , String prefix ) throws IOException { if ( ! doFilesonly && getIncludeEmptyDirs ( ) ) { Stack < String > directories = new Stack < String > ( ) ; // Don't include the last entry itself if it's // a dir; it will be added on its own. int slashPos = entry . length ( ) - ( entry . endsWith ( "/" ) ? 1 : 0 ) ; while ( ( slashPos = entry . lastIndexOf ( ' ' , slashPos - 1 ) ) != - 1 ) { String dir = entry . substring ( 0 , slashPos + 1 ) ; if ( addedDirs . contains ( prefix + dir ) ) { break ; } directories . push ( dir ) ; } while ( ! directories . isEmpty ( ) ) { String dir = directories . pop ( ) ; File f ; if ( baseDir != null ) { f = new File ( baseDir , dir ) ; } else { f = new File ( dir ) ; } // the // At this point we could do something like read the atr final PlexusIoResource res = new AnonymousResource ( f ) ; zipDir ( res , zOut , prefix + dir , archiveEntry . getDefaultDirMode ( ) ) ; } } }
Ensure all parent dirs of a given entry have been added .