@@ -113,7 +113,12 @@ module.exports = function (/*String*/input) {
113
113
readAsTextAsync : function ( /*Object*/ entry , /*Function*/ callback , /*String - Optional*/ encoding ) {
114
114
var item = getEntry ( entry ) ;
115
115
if ( item ) {
116
- item . getDataAsync ( function ( data ) {
116
+ item . getDataAsync ( function ( data , err ) {
117
+ if ( err ) {
118
+ callback ( data , err ) ;
119
+ return ;
120
+ }
121
+
117
122
if ( data && data . length ) {
118
123
callback ( data . toString ( encoding || "utf8" ) ) ;
119
124
} else {
@@ -358,7 +363,7 @@ module.exports = function (/*String*/input) {
358
363
359
364
var entryName = item . entryName ;
360
365
361
- var target = sanitize ( targetPath , pth . resolve ( targetPath , maintainEntryPath ? entryName : pth . basename ( entryName ) ) ) ;
366
+ var target = sanitize ( targetPath , maintainEntryPath ? entryName : pth . basename ( entryName ) ) ;
362
367
363
368
if ( item . isDirectory ) {
364
369
target = pth . resolve ( target , ".." ) ;
@@ -369,9 +374,9 @@ module.exports = function (/*String*/input) {
369
374
if ( ! content ) {
370
375
throw Utils . Errors . CANT_EXTRACT_FILE ;
371
376
}
372
- var childName = sanitize ( targetPath , child . entryName ) ;
377
+ var childName = sanitize ( targetPath , maintainEntryPath ? child . entryName : pth . basename ( child . entryName ) ) ;
373
378
374
- Utils . writeFileTo ( pth . resolve ( targetPath , maintainEntryPath ? childName : childName . substr ( entryName . length ) ) , content , overwrite ) ;
379
+ Utils . writeFileTo ( childName , content , overwrite ) ;
375
380
} ) ;
376
381
return true ;
377
382
}
@@ -470,8 +475,12 @@ module.exports = function (/*String*/input) {
470
475
callback ( undefined ) ;
471
476
return ;
472
477
}
473
- entry . getDataAsync ( function ( content ) {
478
+ entry . getDataAsync ( function ( content , err ) {
474
479
if ( i <= 0 ) return ;
480
+ if ( err ) {
481
+ callback ( new Error ( err ) ) ;
482
+ return ;
483
+ }
475
484
if ( ! content ) {
476
485
i = 0 ;
477
486
callback ( new Error ( Utils . Errors . CANT_EXTRACT_FILE ) ) ;
0 commit comments