[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
At 06:03 PM 12/6/2001, Guy Steele - Sun Microsystems Labs wrote:
> From: Vladimir G Ivanovic <firstname.lastname@example.org>
> To: Paul Prescod <email@example.com>
> Cc: firstname.lastname@example.org
> Subject: Re: Java
> Date: Thu, 06 Dec 2001 14:59:36 -0800
> "PP" == Paul Prescod <email@example.com> writes:
> PP>  Why doesn't it have a concept of "current directory".
> What would the current directory be on a device with (effectively) no
> user-writable storage, say, a cellphone or a set-top box?
>"/dev", and maybe the only file there is "null".
This is just the standard Java line,"we did it this way because it is the right thing to do". They explain it to you in endless articles such as:
but really it comes down to "this is how we did it, get used to it".
The Java that run's on a cell phone isn't remotely like the Java running between my ankles. For example, try creating a String on your phone.
While the article above suggests sending information to your Java application as -D arguments, that isn't portable either because it depends on the command line length limits of the shell you are using. On NT at least it is suprisingly small.
Dylan tried to face up to the "you don't know what environment you are running in" issue. The only portable way to do IO was to put it into an exception.
Some kind of Java support might help here even if it doesn't help all the portability issues.
Here's how i got current working directory to work in JDK1.3. The code may look like Scheme, but if you squint at it you'll start to see the Java. To get it to work i change the user.dir property and compute the absolute path of the file. Using relative paths seems to get the original directory. So, its kind of a kludge.
(define (file-name name)
;; A file name should look like a string with "/" in it.
(apply string-append (separate "/" (crack (.toString name) "\\" 0))))
;; The current working directory.
(file-name (System.getProperty "user.dir")))
(define (cd directory)
;; Change the current working directory to be directory.
(System.setProperty "user.dir" (absolute-file directory)))
(define (absolute-file name)
(file-name (.getAbsolutePath (File. name))))
(define (directory name)
;; Return a list the contents of directory name.
(map* file-name (.listFiles (File. (absolute-file name)))))
(define (load-file name) (load (absolute-file name)))
It doesn't use Java's File class because its trying to interface with Sake which uses a string as a file name.
- Re: Java
- From: Guy Steele - Sun Microsystems Labs <gls@labean.East.Sun.COM>