423 "Modified: 7.9.1995 / 10:48:31 / claus" |
423 "Modified: 7.9.1995 / 10:48:31 / claus" |
424 "Created: 7.3.1996 / 14:51:18 / cg" |
424 "Created: 7.3.1996 / 14:51:18 / cg" |
425 "Modified: 7.3.1996 / 14:53:10 / cg" |
425 "Modified: 7.3.1996 / 14:53:10 / cg" |
426 ! ! |
426 ! ! |
427 |
427 |
428 !Filename class methodsFor:'queries'! |
428 !Filename class methodsFor:'queries'! |
429 |
429 |
430 components:aString |
430 components:aString |
431 "separate the pathName given by aString into |
431 "separate the pathName given by aString into |
432 a collection containing the directory components and the files name as |
432 a collection containing the directory components and the files name as |
433 the final component. |
433 the final component. |
1090 |
1090 |
1091 |info dates| |
1091 |info dates| |
1092 |
1092 |
1093 info := OperatingSystem infoOf:nameString. |
1093 info := OperatingSystem infoOf:nameString. |
1094 info isNil ifTrue:[ |
1094 info isNil ifTrue:[ |
1095 info := OperatingSystem linkInfoOf:nameString. |
1095 info := OperatingSystem linkInfoOf:nameString. |
1096 info isNil ifTrue:[ |
1096 info isNil ifTrue:[ |
1097 ^ nil |
1097 ^ nil |
1098 ] |
1098 ] |
1099 ]. |
1099 ]. |
1100 dates := IdentityDictionary new. |
1100 dates := IdentityDictionary new. |
1101 dates at:#modified put:(info at:#modified). |
1101 dates at:#modified put:(info modified). |
1102 dates at:#accessed put:(info at:#accessed). |
1102 dates at:#accessed put:(info accessed). |
1103 dates at:#statusChanged put:(info at:#statusChanged). |
1103 dates at:#statusChanged put:(info statusChanged). |
1104 ^ dates |
1104 ^ dates |
1105 |
1105 |
1106 " |
1106 " |
1107 Filename currentDirectory dates |
1107 Filename currentDirectory dates |
1108 '../regression' asFilename dates |
1108 '../regression' asFilename dates |
1109 " |
1109 " |
|
1110 |
|
1111 "Modified: 1.11.1996 / 20:19:24 / cg" |
1110 ! |
1112 ! |
1111 |
1113 |
1112 fileSize |
1114 fileSize |
1113 "return the size of the file in bytes" |
1115 "return the size of the file in bytes" |
1114 |
1116 |
1115 |info| |
1117 |info| |
1116 |
1118 |
1117 info := self info. |
1119 info := self info. |
1118 info isNil ifTrue:[^ nil]. |
1120 info isNil ifTrue:[^ nil]. |
1119 ^ info at:#size |
1121 ^ info size |
|
1122 |
|
1123 "Modified: 1.11.1996 / 20:24:43 / cg" |
1120 ! |
1124 ! |
1121 |
1125 |
1122 fileType |
1126 fileType |
1123 "this returns a string describing the type of contents of |
1127 "this returns a string describing the type of contents of |
1124 the file. This is done using the unix 'file' command, |
1128 the file. This is done using the unix 'file' command, |
1214 |
1218 |
1215 "Modified: 26.7.1996 / 19:13:07 / cg" |
1219 "Modified: 26.7.1996 / 19:13:07 / cg" |
1216 ! |
1220 ! |
1217 |
1221 |
1218 info |
1222 info |
1219 "return the files info; that is a collection of file attributes, |
1223 "return some object filled with the files info; |
1220 (actually a dictionary) where the keys are #type, #uid, #gid, #size etc. |
1224 the info (for which corresponding access methods are understood by |
1221 The actual amount and detail returned may depend on the OS used. |
1225 the returned object) is: |
1222 On unix, if you ask for the info of a symbolic link, the target |
1226 |
1223 files info is returned. (see also: #linkInfo) |
1227 type - a symbol giving the files fileType |
1224 |
1228 mode - numeric access mode |
1225 On unix, the contents is: |
1229 uid - owners user id |
1226 id -> the inode number (integer) |
1230 gid - owners group id |
1227 uid -> the numeric user id of the files owner |
1231 size - files size |
1228 gid -> the numeric group id of the files owner |
1232 id - files number (i.e. inode number) |
1229 statusChanged -> the absoluteTime when the files status changed last |
1233 accessed - last access time (as osTime-stamp) |
1230 (i.e. protection change, owner change etc.) |
1234 modified - last modification time (as osTime-stamp) |
1231 accessed -> the absoluteTime when the file was last accessed |
1235 statusChanged - last staus change (as osTime-stamp) |
1232 modified -> the absoluteTime when the file was last modified |
1236 |
1233 size -> the size (in bytes) of the file |
1237 Some of the fields may be returned as nil on systems which do not provide |
1234 type -> the files type (#regular, #directory, #characterSpecial) |
1238 all of the information. |
1235 mode -> the files access protection bits (rwxrwxrwx mask). |
|
1236 |
|
1237 The minimum returned info (i.e. on all OS's) will consist of at least: |
1239 The minimum returned info (i.e. on all OS's) will consist of at least: |
1238 modified |
1240 modified |
1239 size |
1241 size |
1240 type |
1242 type |
1241 |
1243 |
1242 Some OS's (VMS) may return more info. |
1244 Dont expect things like uid/gid/mode to be non-nil; write your application |
1243 |
1245 to either handle nil values, |
1244 Dont expect things like uid/gid/mode to be there; write your application |
|
1245 to either handle the cases where info-entries are not present, |
|
1246 or (better) use one of isXXXX query methods. (Be prepared for DOS ...) |
1246 or (better) use one of isXXXX query methods. (Be prepared for DOS ...) |
|
1247 (i.e. instead of: |
|
1248 someFilename type == #directory |
|
1249 use |
|
1250 someFIlename isDirectory |
1247 " |
1251 " |
1248 |
1252 |
1249 ^ OperatingSystem infoOf:nameString |
1253 ^ OperatingSystem infoOf:nameString |
1250 |
1254 |
1251 " |
1255 " |
1254 'Make.proto' asFilename info |
1258 'Make.proto' asFilename info |
1255 'source/Point.st' asFilename info |
1259 'source/Point.st' asFilename info |
1256 'source/Point.st' asFilename linkInfo |
1260 'source/Point.st' asFilename linkInfo |
1257 '../../libbasic/Point.st' asFilename info |
1261 '../../libbasic/Point.st' asFilename info |
1258 " |
1262 " |
|
1263 |
|
1264 "Modified: 1.11.1996 / 20:22:40 / cg" |
1259 ! |
1265 ! |
1260 |
1266 |
1261 linkInfo |
1267 linkInfo |
1262 "return the files info if its a symbolic link; nil otherwise. |
1268 "return the files info if its a symbolic link; nil otherwise. |
1263 On OS's which do not support symbolic links, nil is always returned. |
1269 On OS's which do not support symbolic links, nil is always returned. |