| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | function getdata(data) { | 
					
						
							|  |  |  | 	if(!data) return null; | 
					
						
							| 
									
										
										
										
											2014-05-22 12:16:51 +00:00
										 |  |  | 	if(data.data) return data.name.substr(-4) !== ".bin" ? debom_xml(data.data) : data.data.split("").map(function(x) { return x.charCodeAt(0); }); | 
					
						
							| 
									
										
										
										
											2014-01-30 03:06:14 +00:00
										 |  |  | 	if(data.asNodeBuffer && typeof Buffer !== 'undefined' && data.name.substr(-4)===".bin") return data.asNodeBuffer(); | 
					
						
							| 
									
										
										
										
											2014-05-22 12:16:51 +00:00
										 |  |  | 	if(data.asBinary && data.name.substr(-4) !== ".bin") return debom_xml(data.asBinary()); | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | 	if(data._data && data._data.getContent) { | 
					
						
							|  |  |  | 		/* TODO: something far more intelligent */ | 
					
						
							|  |  |  | 		if(data.name.substr(-4) === ".bin") return Array.prototype.slice.call(data._data.getContent()); | 
					
						
							|  |  |  | 		return Array.prototype.slice.call(data._data.getContent(),0).map(function(x) { return String.fromCharCode(x); }).join(""); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return null; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function getzipfile(zip, file) { | 
					
						
							|  |  |  | 	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]; | 
					
						
							|  |  |  | 	throw new Error("Cannot find file " + file + " in zip"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-01-30 03:06:14 +00:00
										 |  |  | 		if(typeof Buffer !== 'undefined' && typeof jszip === 'undefined') jszip = require('jszip'); | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | 		if(typeof jszip === 'undefined') jszip = require('./jszip').JSZip; | 
					
						
							|  |  |  | 		_fs = require('fs'); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |