Skip to content

Get the list of open files

Dr. Nicola Mingotti edited this page Dec 11, 2021 · 1 revision

Problem. If you forget to close streams they remain open, even if the associated variables were garbadge collected. So, it is important to be able to see which streams are open. See Smalltalk by Example pg.116 for a brief discussion of the problem.

Solution. You must look into StandardFileStream registry.

"open a Stream, then we look for it in a couple of ways "
s1 _ '/tmp/foobar-123.txt' asFileEntry forceWriteStream . 

s1 class.                       "=> StandardFileStream "

s1 class allInstances .         " here you will find foobar-123.txt"

StandardFileStream registry .   " also here you will find foobar-123.txt"

s1 close.                       " let's close the stream and see what happens "

StandardFileStream registry .   "from here foobar-123.txt is gone "

s1 class allInstances .         "instead here you can still find it"
Clone this wiki locally