01: /*
02: * Site.java
03: *
04: * Copyright (C) 2003-2004 Peter Graves
05: * $Id: Site.java,v 1.2 2004/09/18 02:06:10 piso Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * 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;
25: import java.net.URL;
26:
27: public final class Site extends Lisp {
28: private static final String LISP_HOME;
29:
30: static {
31: String lispHome = null;
32: URL url = Lisp.class.getResource("boot.lisp");
33: if (url != null) {
34: String protocol = url.getProtocol();
35: if (protocol != null && protocol.equals("file")) {
36: String path = url.getPath();
37: int index = path.lastIndexOf('/');
38: if (index >= 0) {
39: lispHome = path.substring(0, index + 1);
40: if (Utilities.isPlatformWindows()) {
41: if (lispHome.length() > 0
42: && lispHome.charAt(0) == '/')
43: lispHome = lispHome.substring(1);
44: }
45: }
46: }
47: }
48: LISP_HOME = lispHome;
49: }
50:
51: public static final String getLispHome() {
52: return LISP_HOME;
53: }
54:
55: // ### *lisp-home*
56: private static final Symbol _LISP_HOME_ = exportSpecial(
57: "*LISP-HOME*", PACKAGE_EXT, NIL);
58:
59: static {
60: try {
61: String s = Site.getLispHome();
62: if (s != null)
63: _LISP_HOME_.setSymbolValue(new Pathname(s));
64: } catch (Throwable t) {
65: Debug.trace(t);
66: }
67: }
68: }
|