AbstractSourceCodeManager.st
changeset 63 abf51a9ae873
parent 61 a0cdaff5ceb3
child 64 d8d43638d803
--- a/AbstractSourceCodeManager.st	Mon Nov 06 17:49:05 1995 +0100
+++ b/AbstractSourceCodeManager.st	Mon Nov 06 20:11:48 1995 +0100
@@ -23,7 +23,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.6 1995-11-06 16:01:03 cg Exp $
+$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.7 1995-11-06 19:11:45 cg Exp $
 "
 !
 
@@ -51,6 +51,21 @@
 "
 ! !
 
+!AbstractSourceCodeManager class methodsFor:'initialization'!
+
+initCacheDirPath
+    |path|
+
+    path := OperatingSystem getEnvironment:'ST_TMPPATH'.
+    path isNil ifTrue:[
+	path := OperatingSystem getEnvironment:'TMPPATH'.
+	path isNil ifTrue:[
+	    path := '/tmp'
+	]
+    ].
+    CacheDirectoryName := path , 'stx_sourceCache'.
+! !
+
 !AbstractSourceCodeManager class methodsFor:'source code access'!
 
 sourceStreamFor:aClass
@@ -95,7 +110,7 @@
     classFileName := Smalltalk fileNameForClass:aClassOrClassName.
     packageDir := Smalltalk sourceDirectoryNameOfClass:aClassOrClassName.
     moduleDir := 'stx'.
-    moduleDir isNil ifTrue:[^ nil].
+    packageDir isNil ifTrue:[^ nil].
 
     ^ self 
 	streamForClass:nil
@@ -105,7 +120,51 @@
 	module:moduleDir
 
     "Created: 6.11.1995 / 16:09:06 / cg"
-    "Modified: 6.11.1995 / 16:52:50 / cg"
+    "Modified: 6.11.1995 / 18:45:58 / cg"
+!
+
+checkinClass:aClass
+    |cls sourceInfo tempDir packageDir moduleDir tempFile classFileName|
+
+    cls := aClass.
+    cls isMeta ifTrue:[
+	cls := cls soleInstance
+    ].
+
+    sourceInfo := cls sourceCodeInfo.
+    sourceInfo isNil ifTrue:[
+	'SOURCEMGR: cannot extract classes sourceInfo' infoPrintNL.
+	^ nil
+    ].
+
+    packageDir := sourceInfo at:#directory.
+    moduleDir := sourceInfo at:#module.  "/ use the modules name as CVS module
+    classFileName := Smalltalk fileNameForClass:cls.
+
+    tempDir := (Filename newTemporaryIn:nil) makeDirectory.
+    [
+	aClass fileOutIn:tempDir.
+
+	(tempFile := tempDir construct:(classFileName,'.st')) exists ifFalse:[
+	    'SOURCEMG: temporary fileout failed' infoPrintNL.
+	].
+
+	^ self 
+	    checkinClass:cls
+	    fileName:classFileName 
+	    directory:packageDir 
+	    module:moduleDir
+	    source:(tempFile name)
+    ] valueNowOrOnUnwindDo:[
+	OperatingSystem recursiveRemoveDirectory:tempDir name
+    ].
+
+    "
+     SourceCodeManager checkinClass:Array
+    "
+
+    "Created: 6.11.1995 / 18:56:00 / cg"
+    "Modified: 6.11.1995 / 20:05:17 / cg"
 ! !
 
 !AbstractSourceCodeManager class methodsFor:'private'!