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

Re: file-length



Tops-20 requires a GTJFN before we can find file length.  But we can
certainly implement it by opening the file temporarily inside
file-length.  So you shouldn't stop just because some OS's may
need to open the file.

However you should consider that this may lead to ambiguity because of
version numbers.  Consider the following code sequences:
   (check-attributes "foo.bar")
   (if (attributes-look-good)
       (read-file "foo.bar"))
or
   (write-file "foo.bar")
   (look-at-attributes "foo.bar")
The problem with both of these is that some other program may create
a new version of foo.bar in the interim.  If we say that you can
look at attributes only for an open stream, then people are more
likely to open the file once, and do their I/O and attribute-checking
on the open stream.  On TOPS-20, we could get the same effect by
encouraging people to do TRUE-NAME the first time they refer to a
file.  Then they can be sure they are always talking about the same
one.  But on Unix this wouldn't work.

So the safest thing is probably to keep the current definition.
If somebody really does want to look at the length of a file and
will never be opening it, you can define a macro to allow a
syntax like
  (with-temporarily-open-file "foo.bar" x (file-length x))
-------