eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'AutoDeletedFilename':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: AutoDeletedFilename


Inheritance:

   Object
   |
   +--Filename
      |
      +--AutoDeletedFilename

Package:
stx:libbasic
Category:
System-Support
Version:
rev: 1.16 date: 2017/01/24 10:43:44
user: cg
file: AutoDeletedFilename.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
cg - original code
sv - fixed and enhanced

Description:


Used with temporary files - these will automatically delete themself,
when no longer referenced (i.e. when finalized)

See -> Filename asAutoDeletedFilename


Class protocol:

change and update
o  update: anAspect with: aParameter from: changedObject
when Smalltalk exits, remove all auto deleted files

initialization
o  initialize
inform me when smalltalk exits


Instance protocol:

accessing
o  keep
do not delete the file on finalization

o  setName: aString

copying
o  shallowCopy
when copying, return a real filename
(to avoid mutiple removals)

finalization
o  basicFinalize

o  executor

o  finalizationLobby
answer the registry used for finalization.
we have our own Lobby.

o  finalize
do this in a forked process to avoid blocking

queries
o  species
filenames derived from me should not be autodeleted themself

removing
o  recursiveRemove

o  remove

o  removeDirectory

o  removeFile


Examples:


the following file will be automatically deleted after some time:
|f p|

f := AutoDeletedFilename newTemporary.
f writeStream
    nextPutLine:'hello';
    close.
p := f pathName.
Transcript showCR:p.
f := f asAutoDeletedFilename.
self assert:(p asFilename exists).
ObjectMemory collectGarbage.
Delay waitForSeconds:2.
self assert:(p asFilename exists).
f := nil.
ObjectMemory collectGarbage.
Delay waitForSeconds:2.
self assert:(p asFilename exists not).
you can also delete it manually:
|f p|

f := Filename newTemporary.
f writeStream
    nextPutLine:'hello';
    close.
p := f pathName.
Transcript showCR:p.
f := f asAutoDeletedFilename.
self assert:(p asFilename exists).
ObjectMemory collectGarbage.
Delay waitForSeconds:2.
self assert:(p asFilename exists).
f remove.
f := nil.
ObjectMemory collectGarbage.
Delay waitForSeconds:2.
self assert:(p asFilename exists not).


ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Mon, 04 Aug 2025 14:30:04 GMT