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

Need to use raw format logical file names for UNIX....

    Date: Sun, 4 Aug 91 22:10:07 EDT
    From: cdwilli@algol.cs.umbc.edu (Chris Willianson (Guest of Al))
    I made the pathname by appending a string, the name of a directory,
    onto a logical pathname from the translations file for the program.
    The logical pathname translates to a literal, lowercase pathname, but
    the directory I appended to it is all caps.  So, my logical pathname,
    "working-files:data;" gets translated to "/usr/share/symbolics/data/"
    but the string I've added to create a new logical pathname, "testing;"
    gets uppercased by function fs:directory-list; I get back the message
    "No such pathname: /usr/share/symbolics/data/TESTING/."

Unfortunately, you don't say what you really did.  You can't
append strings to logical pathnames.

Perhaps you did:

(let ((unix-path (send logical-path :translated-pathname)))
  (fs:make-pathname :directory (append (pathname-directory unix-path) '("testing"))
		    :defaults unix-path))


To use raw case instead of interchange case:

(let ((unix-path (send logical-path :translated-pathname)))
  (fs:make-pathname :raw-directory (append (send unix-path :raw-directory) '("testing"))
		    :defaults unix-path))


This isn't quite the Common Lisp way to write it, but the Common Lisp
way doesn't work in Genera 8.0.1, and I haven't played with 8.1 yet
to know if it has been done there yet.

    Question: How can I switch from interchange format to raw format?  Is
    there some rule I can put in the translations file that tells
    functions like fs:directory-list not to uppercase an appended
    directory name?  I've appended lots of these directory names to lots
    of logical pathnames throughout the program.  Now if I can just get
    the operating system to leave the case of pathname strings alone....

Well, since you're so vague about what you actually are doing,
I'm not quite sure what to make about your talk of the translations
file and rules and such.  Frankly, I haven't been able to figure
out how the translations file enters into it, since logical pathnames
DO NOT REMEMBER CASE.  You have to work extra hard to get anything
to come out on the Unix side with any uppercase at all, since interchange
case yields lowercase on Unix.

But also, I'd like to point out that if you'd stick to using
interchange case, you would be writing portable code, and
also solving your problem at the same time.  Your Unix filenames
would use lowercase, and map as appropriate on other systems.
The only drawback would be the need to work with interchange
case (i.e. "TESTING") in your program instead of raw, system-specific,
non-portable case (i.e. "testing").

(let ((unix-path (send logical-path :translated-pathname)))
  (fs:make-pathname :directory (append (pathname-directory unix-path) '("TESTING"))
		    :defaults unix-path))

or even simpler, working completely with logical pathnames.

(send (fs:make-pathname :directory (append (pathname-directory logical-path) '("TESTING"))
			:defaults logical-path)


This gives you the advantage that you can then control the mapping with the
translations file.  In fact, this is the technique I recommend to you.

For what it's worth, I apologize for choosing wrong as to what the
more common case behaviour would be, ten years ago.  At the time,
there were more systems with upper-case being the norm.  Now,
of course, there are more with lower-case being the norm.  So
interchange case looks weird, and people shy away from using it.
But for portability, the internal portable representation had to
be one or the other, and I made my best guess, and history went
the other way.  sigh.  And now it's even becoming an ANSI standard.