@@ -113,7 +113,12 @@ module.exports = function (/*String*/input) {
113113 readAsTextAsync : function ( /*Object*/ entry , /*Function*/ callback , /*String - Optional*/ encoding ) {
114114 var item = getEntry ( entry ) ;
115115 if ( item ) {
116- item . getDataAsync ( function ( data ) {
116+ item . getDataAsync ( function ( data , err ) {
117+ if ( err ) {
118+ callback ( data , err ) ;
119+ return ;
120+ }
121+
117122 if ( data && data . length ) {
118123 callback ( data . toString ( encoding || "utf8" ) ) ;
119124 } else {
@@ -358,7 +363,7 @@ module.exports = function (/*String*/input) {
358363
359364 var entryName = item . entryName ;
360365
361- var target = sanitize ( targetPath , pth . resolve ( targetPath , maintainEntryPath ? entryName : pth . basename ( entryName ) ) ) ;
366+ var target = sanitize ( targetPath , maintainEntryPath ? entryName : pth . basename ( entryName ) ) ;
362367
363368 if ( item . isDirectory ) {
364369 target = pth . resolve ( target , ".." ) ;
@@ -369,9 +374,9 @@ module.exports = function (/*String*/input) {
369374 if ( ! content ) {
370375 throw Utils . Errors . CANT_EXTRACT_FILE ;
371376 }
372- var childName = sanitize ( targetPath , child . entryName ) ;
377+ var childName = sanitize ( targetPath , maintainEntryPath ? child . entryName : pth . basename ( child . entryName ) ) ;
373378
374- Utils . writeFileTo ( pth . resolve ( targetPath , maintainEntryPath ? childName : childName . substr ( entryName . length ) ) , content , overwrite ) ;
379+ Utils . writeFileTo ( childName , content , overwrite ) ;
375380 } ) ;
376381 return true ;
377382 }
@@ -470,8 +475,12 @@ module.exports = function (/*String*/input) {
470475 callback ( undefined ) ;
471476 return ;
472477 }
473- entry . getDataAsync ( function ( content ) {
478+ entry . getDataAsync ( function ( content , err ) {
474479 if ( i <= 0 ) return ;
480+ if ( err ) {
481+ callback ( new Error ( err ) ) ;
482+ return ;
483+ }
475484 if ( ! content ) {
476485 i = 0 ;
477486 callback ( new Error ( Utils . Errors . CANT_EXTRACT_FILE ) ) ;
0 commit comments