[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mark Kantrowitz's LOGICAL-PATHNAMES?

On Wednesday 22 SEP 1993, Paul Snively writes:
  I was wondering whether anyone had gotten MK's LOGICAL-PATHNAMES working in
  MCL 2.0p2?

The answer is in two parts. Yes MCL understands logical pathnames
and NO, defsystem doesn't understand them. But there is a way to
use them. Load also seems to have a problem loading files and needs
a similar fix.

Thanks to Guillame Cartier for his help in defining logical pathnames
for his extended apropos.

The following is a simple method for defining logical pathnames:
The following defines  mcl: as the toplevel directory (ccl) and uses it to
define the examples directory as a logical name for the examples folder
(setf (logical-pathname-translations "mcl")
      (list (list "mcl:**;*.*"
(setf (logical-pathname-translations "Examples")
      (list (list "Examples:**;*.*"
Now you can load the scrolling-windows from examples:
(Require 'scrolling-windows 
         "Examples:scrolling windows")

If you are using Mark Kantorwitz's Defsystem utiltity, logical pathnames
don't work correctly. Fortunately there is a fix.

The following macros translate the logical names into objects
that defsystem and load understand.

(defmacro logical-to-name (logical-name &optional rest)
  "Allow the expansion of logical pathnames"
  `(if ,rest
     (format nil "~a~a" (mac-directory-namestring 
                         (truename ,logical-name))
     (mac-directory-namestring (truename ,logical-name))))

(defun translate-name (top-dir &optional sub-dirs file)
  (let (main-dir)
    (if file
      (setq main-dir (logical-to-name top-dir sub-dirs))
      (setq main-dir (logical-to-name top-dir)
            file sub-dirs))
    (format nil "~a~a"  main-dir file)))

Here's an example that loads a file in the fasl subdirectory
in the examples folder:
  (load (logical-to-name "Examples:fasls;" "array-dialog-item"))

Here's an example that uses the macros to define the print-u system
that I added to the contrib library. The file is assumed to be
in the directory ccl:menu enhancements:
(defsystem print-u
  :source-pathname (logical-to-name "CCL:" "menu enhancements:")
  :source-extension "lisp"
  :binary-extension "fasl"
  :binary-pathname (logical-to-name "CCL:" "menu enhancements:fasls:")
  :components ((:file "print-u"))
  :initially-do (progn (CCL::require-interface :printTraps)
                       (require :quickDraw)))