@@ -190,12 +190,13 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
190
190
} ,
191
191
192
192
/**
193
- * Removes the entry with the given name from the entry list.
193
+ * Removes the file with the given name from the entry list.
194
194
*
195
195
* If the entry is a directory, then all nested files and directories will be removed
196
196
* @param entryName
197
+ * @returns {void }
197
198
*/
198
- deleteEntry : function ( /*String*/ entryName ) {
199
+ deleteFile : function ( /*String*/ entryName ) {
199
200
if ( ! loadedEntries ) {
200
201
readEntries ( ) ;
201
202
}
@@ -204,7 +205,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
204
205
var _self = this ;
205
206
this . getEntryChildren ( entry ) . forEach ( function ( child ) {
206
207
if ( child . entryName !== entryName ) {
207
- _self . deleteEntry ( child . entryName ) ;
208
+ _self . deleteFile ( child . entryName ) ;
208
209
}
209
210
} ) ;
210
211
}
@@ -213,6 +214,22 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
213
214
mainHeader . totalEntries = entryList . length ;
214
215
} ,
215
216
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
+
216
233
/**
217
234
* Iterates and returns all nested files and directories of the given entry
218
235
*
@@ -238,6 +255,20 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
238
255
return [ ] ;
239
256
} ,
240
257
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
+
241
272
/**
242
273
* Returns the zip file
243
274
*
0 commit comments