From b4a32ddc1c5e8e8f9f410329b8f7817b8d60b13e Mon Sep 17 00:00:00 2001 From: Carl Eastlund Date: Tue, 1 Dec 2009 02:10:50 +0000 Subject: [PATCH] Merged changes from branches/cce/plt+addon-dir: - Added PLTADDONDIR environment variable to control the location of generated files from Planet and Scribble, specifically by overriding the result of (find-system-path 'addon-dir). - Updated documentation of find-system-path to report this change. svn: r17121 --- .../scribblings/reference/filesystem.scrbl | 8 ++++--- src/mzscheme/src/file.c | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/collects/scribblings/reference/filesystem.scrbl b/collects/scribblings/reference/filesystem.scrbl index 240ece9b6d..39e9e5d4d7 100644 --- a/collects/scribblings/reference/filesystem.scrbl +++ b/collects/scribblings/reference/filesystem.scrbl @@ -81,9 +81,11 @@ by @scheme[kind], which must be one of the following: ]} @item{@indexed-scheme['addon-dir] --- a directory for installing PLT Scheme - extensions. It's the same as @scheme['pref-dir], except under Mac OS - X, where it is @filepath{Library/PLT Scheme} in the user's home - directory. This directory might not exist.} + extensions. This directory is specified by the @indexed-envvar{PLTADDONDIR} + environment variable. If the environment variable is undefined or not a legal + path name, this directory defaults to @filepath{Library/PLT Scheme} in the + user's home directory under Mac OS X and @scheme['pref-dir] otherwise. This + directory might not exist.} @item{@indexed-scheme['doc-dir] --- the standard directory for storing the current user's documents. Under Unix, it's the same as diff --git a/src/mzscheme/src/file.c b/src/mzscheme/src/file.c index ef2652bfc0..337118b3a2 100644 --- a/src/mzscheme/src/file.c +++ b/src/mzscheme/src/file.c @@ -5768,6 +5768,19 @@ find_system_path(int argc, Scheme_Object **argv) return CURRENT_WD(); } + + /* first option for addon_dir: PLTADDONDIR environment variable */ + if (which == id_addon_dir) { + char* p; + + if ((p = getenv("PLTADDONDIR"))) { + p = scheme_expand_filename(p, -1, NULL, NULL, 0); + if (p) + return scheme_make_path(p); + } + + /* If PLTADDONDIR is undefined or malformed, fall through to default */ + } { /* Everything else is in ~: */ @@ -5854,6 +5867,17 @@ find_system_path(int argc, Scheme_Object **argv) return CURRENT_WD(); } + /* first option for addon_dir: PLTADDONDIR environment variable */ + if (which == id_addon_dir) { + if ((p = getenv("PLTADDONDIR"))) { + p = scheme_expand_filename(p, -1, NULL, NULL, 0); + if (p) + return scheme_make_path(p); + } + + /* If PLTADDONDIR is undefined or malformed, fall through to default */ + } + home = NULL; {