KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > lisp > Site


1 /*
2  * Site.java
3  *
4  * Copyright (C) 2003-2004 Peter Graves
5  * $Id: Site.java,v 1.2 2004/09/18 02:06:10 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */

21
22 package org.armedbear.lisp;
23
24 import java.io.File JavaDoc;
25 import java.net.URL JavaDoc;
26
27 public final class Site extends Lisp
28 {
29     private static final String JavaDoc LISP_HOME;
30
31     static {
32         String JavaDoc lispHome = null;
33         URL JavaDoc url = Lisp.class.getResource("boot.lisp");
34         if (url != null) {
35             String JavaDoc protocol = url.getProtocol();
36             if (protocol != null && protocol.equals("file")) {
37                 String JavaDoc path = url.getPath();
38                 int index = path.lastIndexOf('/');
39                 if (index >= 0) {
40                     lispHome = path.substring(0, index + 1);
41                     if (Utilities.isPlatformWindows()) {
42                         if (lispHome.length() > 0 && lispHome.charAt(0) == '/')
43                             lispHome = lispHome.substring(1);
44                     }
45                 }
46             }
47         }
48         LISP_HOME = lispHome;
49     }
50
51     public static final String JavaDoc getLispHome()
52     {
53         return LISP_HOME;
54     }
55
56     // ### *lisp-home*
57
private static final Symbol _LISP_HOME_ =
58         exportSpecial("*LISP-HOME*", PACKAGE_EXT, NIL);
59
60     static {
61         try {
62             String JavaDoc s = Site.getLispHome();
63             if (s != null)
64                 _LISP_HOME_.setSymbolValue(new Pathname(s));
65         }
66         catch (Throwable JavaDoc t) {
67             Debug.trace(t);
68         }
69     }
70 }
71
Popular Tags