package uk.ac.ed.inf.Metabolic.sbmlexport;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class LibSBMLConfigManager {
	
	private static boolean isWindows() {
		return System.getProperty("os.name").indexOf("Win") != -1;
	}
	static int i;
	static boolean isLoaded;

	private static String getPath() throws Exception {
		InputStream is = LibSBMLConfigManager.class.getResourceAsStream("PathToNativeSBMLLibraries.setUp");
		BufferedReader br = new BufferedReader(new InputStreamReader(is));
		String rc = br.readLine();
		return rc;
       
	}
	/**
	 * 
	 * @return true if sbml libraries loaded ok
	 */
	static boolean configure () {
		try {
		String libName = System.mapLibraryName("sbmlj");
		System.loadLibrary(libName);
		return true;
		}catch(Exception e) {
		 try{ 
			 String path = getPath();
			 if(isWindows()) {
				 System.load(path + "sbmlj.dll");
    	    
				 return true;
    		
			 } else {
				 return false;
			 }
		 }catch (Exception e2) {
			 return false;
		 }
		}
  
	}


}

@@ -794,25 +794,36 @@
 %09%7Dcatch(
-Exception
+UnsatisfiedLinkError
  e) %7B%0A%09%09
@@ -1002,16 +1002,34 @@
 %7Dcatch (
+Throwable  errorOr
 Exceptio
@@ -1033,11 +1033,8 @@
 tion
- e2
 ) %7B%0A

handle errors