| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | function getdata(data) { | 
					
						
							|  |  |  | 	if(!data) return null; | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 	if(data.name.substr(-4) === ".bin") { | 
					
						
							|  |  |  | 		if(data.data) return char_codes(data.data); | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 		if(data.asNodeBuffer && has_buf) return data.asNodeBuffer(); | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 		if(data._data && data._data.getContent) return Array.prototype.slice.call(data._data.getContent()); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		if(data.data) return data.name.substr(-4) !== ".bin" ? debom_xml(data.data) : char_codes(data.data); | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 		if(data.asNodeBuffer && has_buf) return debom_xml(data.asNodeBuffer().toString('binary')); | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 		if(data.asBinary) return debom_xml(data.asBinary()); | 
					
						
							|  |  |  | 		if(data._data && data._data.getContent) return debom_xml(cc2str(Array.prototype.slice.call(data._data.getContent(),0))); | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return null; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-10 02:22:38 +00:00
										 |  |  | function safegetzipfile(zip, file) { | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | 	var f = file; if(zip.files[f]) return zip.files[f]; | 
					
						
							|  |  |  | 	f = file.toLowerCase(); if(zip.files[f]) return zip.files[f]; | 
					
						
							|  |  |  | 	f = f.replace(/\//g,'\\'); if(zip.files[f]) return zip.files[f]; | 
					
						
							| 
									
										
										
										
											2014-10-10 02:22:38 +00:00
										 |  |  | 	return null; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function getzipfile(zip, file) { | 
					
						
							|  |  |  | 	var o = safegetzipfile(zip, file); | 
					
						
							|  |  |  | 	if(o == null) throw new Error("Cannot find file " + file + " in zip"); | 
					
						
							|  |  |  | 	return o; | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-15 05:08:18 +00:00
										 |  |  | function getzipdata(zip, file, safe) { | 
					
						
							|  |  |  | 	if(!safe) return getdata(getzipfile(zip, file)); | 
					
						
							|  |  |  | 	if(!file) return null; | 
					
						
							|  |  |  | 	try { return getzipdata(zip, file); } catch(e) { return null; } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | var _fs, jszip; | 
					
						
							|  |  |  | if(typeof JSZip !== 'undefined') jszip = JSZip; | 
					
						
							|  |  |  | if (typeof exports !== 'undefined') { | 
					
						
							|  |  |  | 	if (typeof module !== 'undefined' && module.exports) { | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 		if(has_buf && typeof jszip === 'undefined') jszip = require('js'+'zip'); | 
					
						
							|  |  |  | 		if(typeof jszip === 'undefined') jszip = require('./js'+'zip').JSZip; | 
					
						
							|  |  |  | 		_fs = require('f'+'s'); | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } |