[ENH][GOODIE] UnixFileDirectoryPlugin

David T. Lewis lewis at mail.msen.com
Tue Jan 15 12:13:10 UTC 2002


On Mon, Jan 14, 2002 at 04:55:47PM -0800, Tim Rowledge wrote:
> 
> Is there any way to speed up the checking for a particular file? The
> current code finds the list of all files in a directory  (can be slow in
> a big directory, like /etc or ~plonker/pics/hidefrommom/porno/wow ) and
> then scans for it; it seems there ought to be a more primitive, faster
> way. 

Try this on the class side of the plugin (I don't have time to test it
right now, but I think it does what you want):
 
getEntry: fileName inDirectoryPath: aDirectoryPath
	"self getEntry: 'hosts' inDirectoryPath: '/etc'"
	"self getEntry: 'hosts' inDirectoryPath: '/noSuchDir'"
	"self getEntry: 'noSuchFile' inDirectoryPath: '/etc'"
	| entName |
	self primSetDirectory: aDirectoryPath.
	[(entName _ self primNextEntry) notNil]
		whileTrue: [(entName = fileName)
			ifTrue:
				[^ DirectoryEntry fromArray: (self primStat: fileName)]].
	^ nil





More information about the Squeak-dev mailing list