|
Class: AutoDeletedFilename
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
Used with temporary files - these will automatically delete themself,
when no longer referenced (i.e. when finalized)
See -> Filename asAutoDeletedFilename
change and update
-
update: anAspect with: aParameter from: changedObject
-
when Smalltalk exits, remove all auto deleted files
initialization
-
initialize
-
inform me when smalltalk exits
accessing
-
keep
-
do not delete the file on finalization
-
setName: aString
-
copying
-
shallowCopy
-
when copying, return a real filename
(to avoid mutiple removals)
finalization
-
basicFinalize
-
-
executor
-
-
finalizationLobby
-
answer the registry used for finalization.
we have our own Lobby.
-
finalize
-
do this in a forked process to avoid blocking
queries
-
species
-
filenames derived from me should not be autodeleted themself
removing
-
recursiveRemove
-
-
remove
-
-
removeDirectory
-
-
removeFile
-
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).
|
|