--- a/Filename.st Fri Aug 13 21:29:09 2004 +0200
+++ b/Filename.st Fri Aug 13 21:30:22 2004 +0200
@@ -2913,6 +2913,8 @@
osName := self osNameForAccess.
info := OperatingSystem infoOf:osName.
info isNil ifTrue:[
+ "maybe this is a symbolic link with a broken link target.
+ Answer the dates of the link itself"
info := OperatingSystem linkInfoOf:osName.
info isNil ifTrue:[
^ nil
@@ -2955,33 +2957,37 @@
it is only useful for user-information;
NOT as a tag to be used by a program."
- |type buffer s n suffix idx baseNm|
+ |buffer s n suffix idx baseNm info|
"/ since we cannot depend on a 'file' command being available,
"/ do the most obvious ones here.
"/ (also useful since the 'file' command takes some time, and the code
"/ below is faster for common things like directories)
- self isSymbolicLink ifTrue:[
- ^ 'symbolic link to ' , (self linkInfo path)
+ info := self linkInfo.
+ info isSymbolicLink ifTrue:[
+ ^ 'symbolic link to ' , info path
].
- self isDirectory ifTrue:[
+ info isDirectory ifTrue:[
self isReadable ifFalse:[^ 'directory, unreadable'].
self isExecutable ifFalse:[^ 'directory, locked'].
^ 'directory'
].
- (type := self type) == #characterSpecial ifTrue:[
+ info isCharacterSpecial ifTrue:[
^ 'character device special file'
].
- type == #blockSpecial ifTrue:[
+ info isBlockSpecial ifTrue:[
^ 'block device special file'
].
- type == #socket ifTrue:[
+ info isSocket ifTrue:[
^ 'socket'
].
+ info isFifo ifTrue:[
+ ^ 'fifo'
+ ].
self isReadable ifFalse:[^ 'unreadable'].
- self fileSize == 0 ifTrue:[^ 'empty'].
+ info fileSize == 0 ifTrue:[^ 'empty'].
suffix := self suffix asLowercase.
baseNm := self withoutSuffix baseName asLowercase.
@@ -3057,6 +3063,7 @@
'Makefile' asFilename fileType
'.' asFilename fileType
'/dev/null' asFilename fileType
+ '/usr/tmp' asFilename fileType
'/tmp/.X11-unix/X0' asFilename fileType
'smalltalk.rc' asFilename fileType
'bitmaps/SBrowser.xbm' asFilename fileType
@@ -3130,8 +3137,8 @@
!
linkInfo
- "return the files info if its a symbolic link; nil otherwise.
- On OS's which do not support symbolic links, nil is always returned.
+ "return the files info. If it is a symbolic link return the info of the link itself
+ instead of the link's target.
The information is the same as returned by #info, except that if the
receiver represents a symbolic link, the links information
is returned
@@ -3139,7 +3146,7 @@
which is accessed via the symbolic link).
In addition to the normal entries, Unix returns an additional entry:
- path -> the target files pathname
+ path -> the target files pathname
See the comment in #info for more details."
@@ -3152,6 +3159,7 @@
'Make.proto' asFilename linkInfo path
'source/Point.st' asFilename linkInfo
'../../libbasic/Point.st' asFilename linkInfo
+ '/usr/tmp' asFilename linkInfo
"
"Modified: 1.11.1996 / 20:49:09 / cg"
@@ -4267,31 +4275,39 @@
If any file along the symbolic path does not exist (i.e. is a broken link),
nil is returned."
- |t target path|
-
- self isSymbolicLink ifFalse:[
- self exists ifFalse:[^ nil].
- ^ self pathName
+ |t path info|
+
+ info := self linkInfo.
+ info isNil ifTrue:[
+ " I do not exist"
+ ^ nil.
].
+ info isSymbolicLink ifFalse:[
+ ^ self pathName
+ ].
+
t := self.
- [t isSymbolicLink] whileTrue:[
- path := t linkInfo path.
- path isNil ifTrue:[
- "/ cannot happen
- ^ nil
- ].
- target := (self class named:t directoryName) construct:path.
- target exists ifFalse:[^ nil].
- t := target asFilename
- ].
- t exists ifFalse:[^ nil].
+ [
+ path := info path.
+ path isNil ifTrue:[
+ "/ cannot happen
+ ^ nil
+ ].
+ t := (self class named:t directoryName) construct:path.
+ info := t linkInfo.
+ info isNil ifTrue:[
+ "t does not exist"
+ ^ nil
+ ].
+ ] doWhile:[info isSymbolicLink].
+
^ t pathName
"
'/foo/bar' asFilename physicalPathName
'.' asFilename physicalPathName
'../..' asFilename physicalPathName
- 'include/abbrev.stc' asFilename physicalPathName
+ '/usr/tmp' asFilename physicalPathName
"
"Modified: 21.12.1996 / 15:29:50 / cg"
@@ -5005,7 +5021,7 @@
!Filename class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.280 2004-04-01 11:52:36 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.281 2004-08-13 19:30:22 stefan Exp $'
! !
Filename initialize!