@@ -190,12 +190,13 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
190190 } ,
191191
192192 /**
193- * Removes the entry with the given name from the entry list.
193+ * Removes the file with the given name from the entry list.
194194 *
195195 * If the entry is a directory, then all nested files and directories will be removed
196196 * @param entryName
197+ * @returns {void }
197198 */
198- deleteEntry : function ( /*String*/ entryName ) {
199+ deleteFile : function ( /*String*/ entryName ) {
199200 if ( ! loadedEntries ) {
200201 readEntries ( ) ;
201202 }
@@ -204,7 +205,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
204205 var _self = this ;
205206 this . getEntryChildren ( entry ) . forEach ( function ( child ) {
206207 if ( child . entryName !== entryName ) {
207- _self . deleteEntry ( child . entryName ) ;
208+ _self . deleteFile ( child . entryName ) ;
208209 }
209210 } ) ;
210211 }
@@ -213,6 +214,22 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
213214 mainHeader . totalEntries = entryList . length ;
214215 } ,
215216
217+ /**
218+ * Removes the entry with the given name from the entry list.
219+ *
220+ * @param {string } entryName
221+ * @returns {void }
222+ */
223+ deleteEntry : function ( /*String*/ entryName ) {
224+ if ( ! loadedEntries ) {
225+ readEntries ( ) ;
226+ }
227+ const entry = entryTable [ entryName ] ;
228+ entryList . splice ( entryList . indexOf ( entry ) , 1 ) ;
229+ delete entryTable [ entryName ] ;
230+ mainHeader . totalEntries = entryList . length ;
231+ } ,
232+
216233 /**
217234 * Iterates and returns all nested files and directories of the given entry
218235 *
@@ -238,6 +255,20 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
238255 return [ ] ;
239256 } ,
240257
258+ /**
259+ * How many child elements entry has
260+ *
261+ * @param {ZipEntry } entry
262+ * @return {integer }
263+ */
264+ getChildCount : function ( entry ) {
265+ if ( entry && entry . isDirectory ) {
266+ const list = this . getEntryChildren ( entry ) ;
267+ return list . includes ( entry ) ? list . length - 1 : list . length ;
268+ }
269+ return 0 ;
270+ } ,
271+
241272 /**
242273 * Returns the zip file
243274 *
0 commit comments