> VFS.st and File.st have changes made to the isFile
method and other
> additions I've been using for a while now. I didn't
include an isPipe in
> File, although it might be useful
For now, I'm applying this patch which is actually quite
orthogonal to
yours. It implements isDirectory in terms of the st_mode
field of
struct stat.
From here, you can implement things such as isRegularFile,
isSocket,
etc. Note that this is different from symbolic links, where
you use
lstat first to get isSymbolicLink, and if it is a symbolic
link you use
stat to get the real data. The latter step, however,
destroys the
isSymbolicLink data, so you have to save it. You don't need
anything
similar for other special files.
Paolo
2006-10-27 Paolo Bonzini <bonzini gnu.org>
* kernel/VFS.st: Implement isDirectory by accessing struct
stat.
--- orig/kernel/VFS.st
+++ mod/kernel/VFS.st
 -335,7
+335,8  isSymbolicLink
isDirectory
"Answer whether a file with the name contained in
the receiver does exist
and identifies a directory."
- self subclassResponsibility!
+ ^false
+!
isReadable
"Answer whether a file with the name contained in
the receiver does exist
 -433,6
+434,11  size
^self stat stSize value
!
+isDirectory
+ "Answer whether the file is a directory."
+ ^(self stat stMode value bitAnd: 8r170000) = 8r040000
+!
+
isSymbolicLink
"Answer whether the file is a symbolic link."
isSymbolicLink isNil ifTrue: [ self refresh ].
 -494,21
+500,6  exists
^File errno == 0
!
-isDirectory
- "Answer whether a file with the name contained in
the receiver does exist
- and identifies a directory."
- | dir errno |
- dir := self openDir: self realFileName.
- errno := File errno.
- (errno = 0) ifTrue: [
- self closeDir: dir.
- ^true
- ].
- errno = 20 ifTrue: [ ^false ].
- errno = 13 ifTrue: [ ^true ].
- File checkError: errno
-!
-
isReadable
"Answer whether a file with the name contained in
the receiver does exist
and is readable"
_______________________________________________
help-smalltalk mailing list
help-smalltalk gnu.org
http://lists.gnu.org/mailman/listinfo/help-smalltalk
|