From: joker
Subject: please help me about path names.
Date: 
Message-ID: <8b9f3789-6d29-4fd0-83ea-f898f8d9df0e@m3g2000hsc.googlegroups.com>
in the book common lisp a gentle introduction to lisp
there is an example like this...

file name:
timber.dat

includes:
"The North Slope"
((45 redwood) (12 oak) (43 maple))
100

code:
(defun get-tree-data ()
  (with-open-file (stream "/usr/dst/timber.dat")
    (let* ((tree-loc (read stream))
            (tree-table (read stream))
            (num-trees (read stream)))
        (format t "~&There are ~S trees on ~S."
                     num-trees tree-loc)
        (format t "~&They are:  ~S" tree-table))))

> (get-tree-data)
There are 100 trees on "The North Slope".
They are:  ((45 REDWOOD) (12 OAK) (43 MAPLE))
NIL

now i can not reach this file in this example it is not clear where
the file is...
for example my path is E:\timber.dat
how must i change this code in order to reach my file
i am using win xp(in E:)

thank you very much for your help.

From: Brian
Subject: Re: please help me about path names.
Date: 
Message-ID: <0e4f476f-ba41-4a53-b0c3-bf3e1beaeb41@l42g2000hsc.googlegroups.com>
joker wrote:
> now i can not reach this file in this example it is not clear where
> the file is...
> for example my path is E:\timber.dat
> how must i change this code in order to reach my file
> i am using win xp(in E:)
Look around WITH-OPEN-FILE  :)

And you probably want to write the pathname as "E:/timber.dat" because
you would need to do "E:\\timber.dat" to escape the backslash
otherwise.
From: Marco Antoniotti
Subject: Re: please help me about path names.
Date: 
Message-ID: <c71f021a-d6f0-4072-9bf3-0de4a0fa6f4c@x41g2000hsb.googlegroups.com>
On Apr 14, 5:16 am, Brian <··············@gmail.com> wrote:
> joker wrote:
> > now i can not reach this file in this example it is not clear where
> > the file is...
> > for example my path is E:\timber.dat
> > how must i change this code in order to reach my file
> > i am using win xp(in E:)
>
> Look around WITH-OPEN-FILE  :)
>
> And you probably want to write the pathname as "E:/timber.dat" because
> you would need to do "E:\\timber.dat" to escape the backslash
> otherwise.

The actual syntax that can be fed to WITH-OPEN-FILE is eventually the
pathname syntax that can be fed PARSE-NAMESTRING; i.e. it is
implementation dependent.  Most likely, the safest string to pass
PARSE-NAMESTRING on a DOS/Windows/MS file system is the quoted one  "E:
\\timber.dat".   I hear that Windows now accepts Unix like pathnames,
YMMV.

Cheers
--
Marco
From: Pascal J. Bourguignon
Subject: Re: please help me about path names.
Date: 
Message-ID: <7cy77g24jp.fsf@pbourguignon.anevia.com>
Brian <··············@gmail.com> writes:

> joker wrote:
>> now i can not reach this file in this example it is not clear where
>> the file is...
>> for example my path is E:\timber.dat
>> how must i change this code in order to reach my file
>> i am using win xp(in E:)
> Look around WITH-OPEN-FILE  :)
>
> And you probably want to write the pathname as "E:/timber.dat" because
> you would need to do "E:\\timber.dat" to escape the backslash
> otherwise.

Either that, or you can use logical pathnames, with which you could
leave that detail out of the scope of your program (thus rendering it
"portable").


;;; 100% portable code follows.

(load-logical-pathname-translations "DATA")

;; Note that which file is loaded, and what format it must have, are
;; implementation specific (==> read your implementation
;; documentation).  But the net result will be that the following:

(with-open-file (data #P"DATA:TIMBER.DAT")
   #|...|#)

;; will access the right file.



-- 
__Pascal Bourguignon__