2953 Warning: |
2955 Warning: |
2954 Since the returned string differs among systems (and language settings), |
2956 Since the returned string differs among systems (and language settings), |
2955 it is only useful for user-information; |
2957 it is only useful for user-information; |
2956 NOT as a tag to be used by a program." |
2958 NOT as a tag to be used by a program." |
2957 |
2959 |
2958 |type buffer s n suffix idx baseNm| |
2960 |buffer s n suffix idx baseNm info| |
2959 |
2961 |
2960 "/ since we cannot depend on a 'file' command being available, |
2962 "/ since we cannot depend on a 'file' command being available, |
2961 "/ do the most obvious ones here. |
2963 "/ do the most obvious ones here. |
2962 "/ (also useful since the 'file' command takes some time, and the code |
2964 "/ (also useful since the 'file' command takes some time, and the code |
2963 "/ below is faster for common things like directories) |
2965 "/ below is faster for common things like directories) |
2964 |
2966 |
2965 self isSymbolicLink ifTrue:[ |
2967 info := self linkInfo. |
2966 ^ 'symbolic link to ' , (self linkInfo path) |
2968 info isSymbolicLink ifTrue:[ |
2967 ]. |
2969 ^ 'symbolic link to ' , info path |
2968 self isDirectory ifTrue:[ |
2970 ]. |
|
2971 info isDirectory ifTrue:[ |
2969 self isReadable ifFalse:[^ 'directory, unreadable']. |
2972 self isReadable ifFalse:[^ 'directory, unreadable']. |
2970 self isExecutable ifFalse:[^ 'directory, locked']. |
2973 self isExecutable ifFalse:[^ 'directory, locked']. |
2971 ^ 'directory' |
2974 ^ 'directory' |
2972 ]. |
2975 ]. |
2973 (type := self type) == #characterSpecial ifTrue:[ |
2976 info isCharacterSpecial ifTrue:[ |
2974 ^ 'character device special file' |
2977 ^ 'character device special file' |
2975 ]. |
2978 ]. |
2976 type == #blockSpecial ifTrue:[ |
2979 info isBlockSpecial ifTrue:[ |
2977 ^ 'block device special file' |
2980 ^ 'block device special file' |
2978 ]. |
2981 ]. |
2979 type == #socket ifTrue:[ |
2982 info isSocket ifTrue:[ |
2980 ^ 'socket' |
2983 ^ 'socket' |
2981 ]. |
2984 ]. |
|
2985 info isFifo ifTrue:[ |
|
2986 ^ 'fifo' |
|
2987 ]. |
2982 |
2988 |
2983 self isReadable ifFalse:[^ 'unreadable']. |
2989 self isReadable ifFalse:[^ 'unreadable']. |
2984 self fileSize == 0 ifTrue:[^ 'empty']. |
2990 info fileSize == 0 ifTrue:[^ 'empty']. |
2985 |
2991 |
2986 suffix := self suffix asLowercase. |
2992 suffix := self suffix asLowercase. |
2987 baseNm := self withoutSuffix baseName asLowercase. |
2993 baseNm := self withoutSuffix baseName asLowercase. |
2988 |
2994 |
2989 ((#('st' 'rc' 'chg' 'htm' 'html' 'ps' 'cls' 'pac') includes:suffix) |
2995 ((#('st' 'rc' 'chg' 'htm' 'html' 'ps' 'cls' 'pac') includes:suffix) |
3055 |
3061 |
3056 " |
3062 " |
3057 'Makefile' asFilename fileType |
3063 'Makefile' asFilename fileType |
3058 '.' asFilename fileType |
3064 '.' asFilename fileType |
3059 '/dev/null' asFilename fileType |
3065 '/dev/null' asFilename fileType |
|
3066 '/usr/tmp' asFilename fileType |
3060 '/tmp/.X11-unix/X0' asFilename fileType |
3067 '/tmp/.X11-unix/X0' asFilename fileType |
3061 'smalltalk.rc' asFilename fileType |
3068 'smalltalk.rc' asFilename fileType |
3062 'bitmaps/SBrowser.xbm' asFilename fileType |
3069 'bitmaps/SBrowser.xbm' asFilename fileType |
3063 " |
3070 " |
3064 |
3071 |
3128 |
3135 |
3129 "Modified: / 17.8.1998 / 10:24:10 / cg" |
3136 "Modified: / 17.8.1998 / 10:24:10 / cg" |
3130 ! |
3137 ! |
3131 |
3138 |
3132 linkInfo |
3139 linkInfo |
3133 "return the files info if its a symbolic link; nil otherwise. |
3140 "return the files info. If it is a symbolic link return the info of the link itself |
3134 On OS's which do not support symbolic links, nil is always returned. |
3141 instead of the link's target. |
3135 The information is the same as returned by #info, except that if the |
3142 The information is the same as returned by #info, except that if the |
3136 receiver represents a symbolic link, the links information |
3143 receiver represents a symbolic link, the links information |
3137 is returned |
3144 is returned |
3138 (while in this case, #info returns the info of the target file, |
3145 (while in this case, #info returns the info of the target file, |
3139 which is accessed via the symbolic link). |
3146 which is accessed via the symbolic link). |
3140 |
3147 |
3141 In addition to the normal entries, Unix returns an additional entry: |
3148 In addition to the normal entries, Unix returns an additional entry: |
3142 path -> the target files pathname |
3149 path -> the target files pathname |
3143 |
3150 |
3144 See the comment in #info for more details." |
3151 See the comment in #info for more details." |
3145 |
3152 |
3146 ^ OperatingSystem linkInfoOf:(self osNameForAccess) |
3153 ^ OperatingSystem linkInfoOf:(self osNameForAccess) |
3147 |
3154 |
3150 '/dev/null' asFilename linkInfo |
3157 '/dev/null' asFilename linkInfo |
3151 'Make.proto' asFilename linkInfo |
3158 'Make.proto' asFilename linkInfo |
3152 'Make.proto' asFilename linkInfo path |
3159 'Make.proto' asFilename linkInfo path |
3153 'source/Point.st' asFilename linkInfo |
3160 'source/Point.st' asFilename linkInfo |
3154 '../../libbasic/Point.st' asFilename linkInfo |
3161 '../../libbasic/Point.st' asFilename linkInfo |
|
3162 '/usr/tmp' asFilename linkInfo |
3155 " |
3163 " |
3156 |
3164 |
3157 "Modified: 1.11.1996 / 20:49:09 / cg" |
3165 "Modified: 1.11.1996 / 20:49:09 / cg" |
3158 ! |
3166 ! |
3159 |
3167 |
4265 If the receiver represents a symbolic link, thats the fileName of the |
4273 If the receiver represents a symbolic link, thats the fileName of the |
4266 final target. Otherwise, its the receivers pathName itself. |
4274 final target. Otherwise, its the receivers pathName itself. |
4267 If any file along the symbolic path does not exist (i.e. is a broken link), |
4275 If any file along the symbolic path does not exist (i.e. is a broken link), |
4268 nil is returned." |
4276 nil is returned." |
4269 |
4277 |
4270 |t target path| |
4278 |t path info| |
4271 |
4279 |
4272 self isSymbolicLink ifFalse:[ |
4280 info := self linkInfo. |
4273 self exists ifFalse:[^ nil]. |
4281 info isNil ifTrue:[ |
4274 ^ self pathName |
4282 " I do not exist" |
4275 ]. |
4283 ^ nil. |
|
4284 ]. |
|
4285 info isSymbolicLink ifFalse:[ |
|
4286 ^ self pathName |
|
4287 ]. |
|
4288 |
4276 t := self. |
4289 t := self. |
4277 [t isSymbolicLink] whileTrue:[ |
4290 [ |
4278 path := t linkInfo path. |
4291 path := info path. |
4279 path isNil ifTrue:[ |
4292 path isNil ifTrue:[ |
4280 "/ cannot happen |
4293 "/ cannot happen |
4281 ^ nil |
4294 ^ nil |
4282 ]. |
4295 ]. |
4283 target := (self class named:t directoryName) construct:path. |
4296 t := (self class named:t directoryName) construct:path. |
4284 target exists ifFalse:[^ nil]. |
4297 info := t linkInfo. |
4285 t := target asFilename |
4298 info isNil ifTrue:[ |
4286 ]. |
4299 "t does not exist" |
4287 t exists ifFalse:[^ nil]. |
4300 ^ nil |
|
4301 ]. |
|
4302 ] doWhile:[info isSymbolicLink]. |
|
4303 |
4288 ^ t pathName |
4304 ^ t pathName |
4289 |
4305 |
4290 " |
4306 " |
4291 '/foo/bar' asFilename physicalPathName |
4307 '/foo/bar' asFilename physicalPathName |
4292 '.' asFilename physicalPathName |
4308 '.' asFilename physicalPathName |
4293 '../..' asFilename physicalPathName |
4309 '../..' asFilename physicalPathName |
4294 'include/abbrev.stc' asFilename physicalPathName |
4310 '/usr/tmp' asFilename physicalPathName |
4295 " |
4311 " |
4296 |
4312 |
4297 "Modified: 21.12.1996 / 15:29:50 / cg" |
4313 "Modified: 21.12.1996 / 15:29:50 / cg" |
4298 ! |
4314 ! |
4299 |
4315 |