1 21 22 package org.armedbear.lisp; 23 24 import java.io.BufferedReader ; 25 import java.io.FileInputStream ; 26 import java.io.IOException ; 27 import java.io.InputStreamReader ; 28 29 public final class machine_version extends Primitive0 31 { 32 private machine_version() 33 { 34 super("machine-version"); 35 } 36 37 public LispObject execute() throws ConditionThrowable 38 { 39 String osName = System.getProperty("os.name"); 40 if (osName != null && osName.toLowerCase().startsWith("linux")) { 41 try { 42 FileInputStream in = new FileInputStream ("/proc/cpuinfo"); 43 if (in != null) { 44 BufferedReader reader = 45 new BufferedReader (new InputStreamReader (in)); 46 try { 47 String s; 48 while ((s = reader.readLine()) != null) { 49 int start = s.indexOf("model name"); 50 if (start >= 0) { 51 start = s.indexOf(':', start); 52 if (start >= 0) { 53 return new SimpleString(s.substring(start + 1).trim()); 54 } 55 } 56 } 57 } 58 finally { 59 reader.close(); 60 } 61 } 62 } 63 catch (IOException e) {} 64 } 65 return NIL; 66 } 67 68 private static final Primitive0 MACHINE_VERSION = new machine_version(); 69 } 70 | Popular Tags |