939 ! |
939 ! |
940 |
940 |
941 updateList |
941 updateList |
942 "set the lists contents to the filenames in the directory" |
942 "set the lists contents to the filenames in the directory" |
943 |
943 |
944 |oldCursor files newList index obsolete |
944 |newList newTypes index obsolete |
945 matching patternList dir ignoreCase| |
945 matching dir ignoreCase| |
946 |
946 |
947 directory isNil ifTrue:[ |
947 directory isNil ifTrue:[ |
948 super list:nil. |
948 self list:nil. |
949 files := newList := nil. |
|
950 ^ self |
949 ^ self |
951 ]. |
950 ]. |
952 |
951 |
953 oldCursor := cursor. |
952 self withCursor:(Cursor read) do:[ |
954 self cursor:(Cursor read). |
953 " |
955 |
954 if the directory-id changed, MUST update. |
956 " |
955 (can happen after a restart, when a file is no longer |
957 if the directory-id changed, MUST update. |
956 there, has moved or is NFS-mounted differently) |
958 (can happen after a restart, when a file is no longer |
957 " |
959 there, has moved or is NFS-mounted differently) |
958 obsolete := directoryId ~~ directory id |
960 " |
959 or:[directoryName ~= directory pathName |
961 obsolete := directoryId ~~ directory id |
960 or:[timeStamp notNil |
962 or:[directoryName ~= directory pathName |
961 and:[directory modificationTime > timeStamp]]]. |
963 or:[timeStamp notNil |
962 |
964 and:[directory modificationTime > timeStamp]]]. |
963 obsolete ifTrue:[ |
965 |
964 timeStamp := directory modificationTime. |
966 obsolete ifTrue:[ |
965 directoryId := directory id. |
967 timeStamp := directory modificationTime. |
966 directoryName := directory pathName. |
968 directoryId := directory id. |
967 directoryContents := (directory fullDirectoryContents ? #()) sort. |
969 directoryName := directory pathName. |
|
970 directoryContents := (directory fullDirectoryContents ? #()) sort. |
|
971 directoryFileTypes := OrderedCollection new. |
|
972 directoryContents do:[:name | |
|
973 |f| |
|
974 |
|
975 f := directory construct:name. |
|
976 directoryFileTypes add:(f isDirectory) |
|
977 ]. |
968 ]. |
978 ]. |
969 |
979 |
970 newList := OrderedCollection new. |
980 files := directoryContents. |
971 newTypes := OrderedCollection new. |
981 newList := OrderedCollection new. |
972 index := 1. |
982 index := 1. |
973 |
983 |
974 ignoreCase := ignoreCaseInPattern ? (Filename isCaseSensitive not). |
984 ignoreCase := ignoreCaseInPattern ? (Filename isCaseSensitive not). |
975 |
985 |
976 dir := directory pathName asFilename. |
986 dir := directory pathName asFilename. |
977 directoryContents do:[:name | |
987 files do:[:name | |
978 |type fn fullName isDirectory ignore| |
988 |type fullName| |
979 |
989 |
980 fn := dir construct:name. |
990 fullName := dir constructString:name. |
981 fullName := dir constructString:name. |
991 (matchBlock isNil or:[matchBlock value:fullName]) ifTrue:[ |
982 isDirectory := fn isDirectory. |
992 (directoryFileTypes at:index) == true ifTrue:[ |
983 ignore := true. |
993 ignoreDirectories ifFalse:[ |
984 |
994 name = '..' ifTrue:[ |
985 (matchBlock isNil or:[matchBlock value:fullName]) ifTrue:[ |
995 ignoreParentDirectory ifFalse:[ |
986 isDirectory ifTrue:[ |
996 newList add:name. |
987 ignoreDirectories ifFalse:[ |
997 ] |
988 name = '..' ifTrue:[ |
998 ] ifFalse:[ |
989 ignoreParentDirectory ifFalse:[ |
999 name = '.' ifTrue:[ |
990 ignore := false. |
1000 "ignore" |
991 ] |
1001 ] ifFalse:[ |
992 ] ifFalse:[ |
1002 newList add:(name ", ' ...'"). |
993 name = '.' ifTrue:[ |
|
994 "ignore" |
|
995 ] ifFalse:[ |
|
996 ignore := false. |
|
997 ] |
1003 ] |
998 ] |
1004 ] |
999 ] |
1005 ] |
1000 ] ifFalse:[ |
1006 ] ifFalse:[ |
1001 ignoreFiles ifFalse:[ |
1007 ignoreFiles ifFalse:[ |
1002 matching := true. |
1008 matching := true. |
1003 |
1009 |
1004 (pattern size > 0) ifTrue:[ |
1010 (pattern size > 0) ifTrue:[ |
1005 pattern ~= '*' ifTrue:[ |
1011 pattern ~= '*' ifTrue:[ |
1006 matching := pattern compoundMatch:name ignoreCase:ignoreCase |
1012 matching := pattern compoundMatch:name ignoreCase:ignoreCase |
1007 ] |
|
1008 ]. |
|
1009 |
|
1010 matching ifTrue:[ |
|
1011 ignore := false. |
1013 ] |
1012 ] |
1014 ]. |
|
1015 |
|
1016 matching ifTrue:[ |
|
1017 newList add:name. |
|
1018 ] |
1013 ] |
1019 ] |
1014 ]. |
1020 ]. |
1015 ]. |
|
1016 ignore ifFalse:[ |
|
1017 newList add:name. |
|
1018 newTypes add:isDirectory. |
|
1019 ]. |
|
1020 index := index + 1 |
1021 ]. |
1021 ]. |
1022 index := index + 1 |
1022 directoryFileTypes := newTypes. |
1023 ]. |
1023 self list:newList. |
1024 super list:newList. |
1024 ]. |
1025 |
|
1026 self cursor:oldCursor. |
|
1027 |
1025 |
1028 "Modified: / 18.9.1997 / 23:43:52 / stefan" |
1026 "Modified: / 18.9.1997 / 23:43:52 / stefan" |
1029 "Modified: / 16.12.1999 / 01:23:41 / cg" |
1027 "Modified: / 16.12.1999 / 01:23:41 / cg" |
1030 ! |
1028 ! |
1031 |
1029 |