Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions src/org/armedbear/lisp/FileStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ public FileStream(Pathname pathname,
* http://www.weitz.de/flexi-streams/#make-external-format
*/
super(Symbol.FILE_STREAM);
final File file = pathname.getFile();
final Pathname physicalPathname
= (pathname instanceof LogicalPathname)
? (Pathname) LogicalPathname.translateLogicalPathname((LogicalPathname) pathname)
: pathname;
final File file = physicalPathname.getFile();
String mode = null;
if (direction == Keyword.INPUT) {
mode = "r";
Expand Down Expand Up @@ -298,32 +302,37 @@ public LispObject execute(LispObject first, LispObject second,
direction != Keyword.IO)
error(new LispError("Direction must be :INPUT, :OUTPUT, or :IO."));

if (pathname.isJar()) {
final Pathname dispatchPathname
= (pathname instanceof LogicalPathname)
? (Pathname) LogicalPathname.translateLogicalPathname((LogicalPathname) pathname)
: pathname;

if (dispatchPathname.isJar()) {
if (direction != Keyword.INPUT) {
error(new FileError("Only direction :INPUT is supported for jar files.", pathname));
error(new FileError("Only direction :INPUT is supported for jar files.", dispatchPathname));
}
try {
return new JarStream(pathname,
try {
return new JarStream(dispatchPathname,
elementType, direction, ifExists,
externalFormat);
} catch (IOException e) {
return error(new StreamError(null, e));
}
} else if (pathname instanceof URLPathname
&& !(URLPathname.isFile(pathname))) {
} else if (dispatchPathname instanceof URLPathname
&& !(URLPathname.isFile(dispatchPathname))) {
if (direction != Keyword.INPUT) {
error(new FileError("Only direction :INPUT is supported for URLs.", pathname));
error(new FileError("Only direction :INPUT is supported for URLs.", dispatchPathname));
}
try {
return new URLStream(pathname,
try {
return new URLStream(dispatchPathname,
elementType, direction, ifExists,
externalFormat);
} catch (IOException e) {
return error(new StreamError(null, e));
}
} else {
try {
return new FileStream(pathname,
return new FileStream(pathname,
elementType, direction, ifExists,
externalFormat);
}
Expand Down
6 changes: 5 additions & 1 deletion src/org/armedbear/lisp/Pathname.java
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,13 @@ public String printObject() {
// We have a namestring. Check for pathname components that
// can't be read from the namestring.
if ((getHost() != NIL && !isURL())
|| getVersion() != NIL)
|| getVersion() != NIL)
{
useNamestring = false;
} else if (getName() == NIL && getType() != NIL) {
// Namestring would be ".type" which reads back with
// name="type" rather than name=NIL, type=type.
useNamestring = false;
} else if (getName() instanceof AbstractString) {
String n = getName().getStringValue();
if (n.equals(".") || n.equals("..")) {
Expand Down
6 changes: 3 additions & 3 deletions src/org/armedbear/lisp/open.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
;; this abstract pathname if and only if a file with this name does
;; not yet exist." See java.io.File.createNewFile().
(create-new-file (namestring pathname))))
(make-file-stream pathname element-type :input nil external-format))
(make-file-stream p element-type :input nil external-format))
(:probe
(case if-does-not-exist
(:error
Expand All @@ -166,7 +166,7 @@
;; this abstract pathname if and only if a file with this name does
;; not yet exist." See java.io.File.createNewFile().
(create-new-file (namestring pathname))))
(let ((stream (make-file-stream pathname element-type
(let ((stream (make-file-stream p element-type
:input nil external-format)))
(when stream
(close stream))
Expand Down Expand Up @@ -214,7 +214,7 @@
(error 'simple-error
:format-control "Option not supported: ~S."
:format-arguments (list if-exists))))
(let ((stream (make-file-stream pathname element-type
(let ((stream (make-file-stream p element-type
direction if-exists external-format)))
(unless stream
(error 'file-error
Expand Down