Remove object files that have been collected and not been used
authorStefan Vogel <sv@exept.de>
Wed, 25 Jul 2001 16:01:27 +0200
changeset 1163 242ec57c2f27
parent 1162 f5f00d3d8821
child 1164 cc5e06212815
Remove object files that have been collected and not been used by an image.
ObjectFileHandle.st
--- a/ObjectFileHandle.st	Tue Jul 24 19:17:38 2001 +0200
+++ b/ObjectFileHandle.st	Wed Jul 25 16:01:27 2001 +0200
@@ -14,7 +14,7 @@
 
 Object subclass:#ObjectFileHandle
 	instanceVariableNames:'sysHandle1 sysHandle2 pathName moduleID handleType weakMethodRef
-		weakClassRefs weakFunctionRefs'
+		weakClassRefs weakFunctionRefs snapshot'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'System-Compiler'
@@ -52,6 +52,15 @@
 "
 ! !
 
+!ObjectFileHandle class methodsFor:'change & update'!
+
+preSnapshot
+    "about to write a snapshot.
+     Mark all the current instances as beeing snapshotted"
+
+    self allInstancesDo:[:i| i snapshot:true].
+! !
+
 !ObjectFileHandle methodsFor:'accessing'!
 
 classes
@@ -156,6 +165,18 @@
     "Created: 14.9.1995 / 21:13:12 / claus"
 !
 
+snapshot
+    "return the value of the instance variable 'snapshot' (automatically generated)"
+
+    ^ snapshot
+!
+
+snapshot:something
+    "set the value of the instance variable 'snapshot' (automatically generated)"
+
+    snapshot := something.
+!
+
 sysHandle1
     "return sysHandle1"
 
@@ -215,7 +236,13 @@
             weakMethodRef := nil.
         ].
         ('ObjectFileHandle [info]: unloading ' , pathName , '  (method/classes were garbageCollected)') infoPrintCR.
-        ObjectFileLoader unloadObjectFile:pathName
+        ObjectFileLoader unloadObjectFile:pathName.
+        snapshot == true ifFalse:[
+            "This object file has never been saved in a snapshot,
+             so it can be savely removed"
+
+            pathName asFilename remove.
+        ].
     ].
 
     "Created: 5.12.1995 / 18:05:08 / cg"
@@ -414,5 +441,5 @@
 !ObjectFileHandle class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileHandle.st,v 1.28 2000-08-31 10:03:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileHandle.st,v 1.29 2001-07-25 14:01:27 stefan Exp $'
 ! !