[BUG] [FIX] [ENH] Directories w/out subdirectories appear as such in FileList2

thierry_reignier <thierry_Reignier at hotmail.com> thierry_Reignier at hotmail.com
Mon Dec 9 10:29:08 UTC 2002


Hi,

> Currently in the hierarchy list FileList2, all folders have 
> toggles that make them appear to have subfolders. 
found a bug running:
    FileList2 modalFileSelectorForSuffixes: #('txt' 'rtf' 'doc').
corrected with this uggly test:
FileDirectoryWrapper>>hasContents
	"Return whether this directory has subfolders. The value is cached to
avoid a performance penalty.
	Also for performance reasons, the code below will just assume that
the directory does indeed have contents in a couple of cases: 
			1. If the item is not a FileDirectory (thus avoiding the cost
			of refreshing directories that are not local)
			2. If it's the root directory of a given volume"

	| parts |
	hasContents isNil ifTrue:[
		hasContents _ true. "default"
		((item isKindOf: FileDirectory) "Best test I could think of for
determining if this is a local directory"
		and: ["test to see that it's not the root directory"
			((parts := item pathParts) size > 1) and: [parts size = 2 and:
[parts last ~= 'System Volume Information']]])
				ifTrue:[hasContents _ self contents notEmpty]].
	^hasContents





More information about the Squeak-dev mailing list