This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: File objects, path object, filepath objects, strings


Ethan Herdrick wrote:
There are:
1) Java File objects,
2) Kawa filepath objects, which are said to be wrappers around Java File objects
3) Kawa path objects, which are... ?
4) strings which can be paths.

When should I use each type?  What is the purpose of filepath and path
objects?

They provide a layer of abstraction, so you can use the same API to work with both file names and URI/URLs. They also provide the mechanism so that that you can use URLs most places standard Scheme requires filenames:

#|kawa:3|# (define p (open-input-file "http://bothner.com";))
#|kawa:6|# (read-line p)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head>

The string "http://bothner.com"; is automatically coerced to a path,
either a filepath or a URI, respectively.

It appears that the path objects are accepted by Java when a
java.io.File is called for, which is very handy.

Not really, as you note in your follow-up. But many Scheme functions take general paths or objects that can be coerced to a path.

> It appears that
functions that take filepath and path objects generally take strings,
too..  Is this true?

Yes - as if they were coerced by (path arg). -- --Per Bothner per@bothner.com http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]