Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BELOW IS WHAT I DID TO ***EXPERIMENTALLY*** EXPORT A OSCRIPT MODULE AS A COLLECTION OF DUMP
- FILES (ONE FOR EACH OSPACE OBJECT) RATHER THAN A SINGLE MONOLITHIC DUMP FILE.
- You can view the Viemo video https://vimeo.com/47891950 to watch a demo of this very crude proof-of-concept quality code.
- 1. Created new Child 'OSUtils' under "[my module] Root"
- 2. Copied "Builder Root:Builder Utils" features "NewOSpaceStetup","SystemFeatures","ExportOspace"
- 3. Created Integer fCounter, setting initial value to 10000
- 4. Created Dynamic fDmpFile, leaving Undefined
- 5. Edited ExportOspace to write a new .dmp file for each object by doing this:
- Note: I am not posting the source for my modified ExportOspace method because I did not write the original method and don't want to post code I did not write. However, below is a unified diff showing the changes I made.
- --- E:/csapps/opentext/module/aabmod_1_0_1/src/ExportOspace_original.txt
- +++ E:/csapps/opentext/module/aabmod_1_0_1/src/ExportOspace_modified.txt
- @@ -22,6 +22,7 @@
- dynamic f
- object x
- + .fCounter = 10000
- if OS.IsObject( starthere )
- root = starthere
- @@ -34,6 +35,7 @@
- else
- outfile = File.StringToFile( filename )
- end
- + .fDmpFile = outfile
- $cancelled = false
- @@ -81,6 +83,7 @@
- Dialog.Close( $progress )
- $outputFile = undefined
- + .fCounter = 10000
- end
- end
- @@ -99,6 +102,10 @@
- function void PrintObject( object o )
- + File outputFile = $outputFile
- + File myFile = .GetFileFor(o)
- + $outputFile = myFile
- + File.Open( $outputFile, "w" )
- object obj
- boolean featureSet
- string featureName
- @@ -173,6 +180,8 @@
- break
- end
- end
- + File.Close(myFile)
- + $outputFile = outputFile
- end
- 6. Created GetFileFor method as follows:
- function File GetFileFor(Object o)
- .fCounter += 1
- String s = Str.Format("%1_%2_%3.dmp", File.FileToString(.fDmpFile), .fCounter, o.osName)
- File f = File.StringToFile(s)
- return f
- end
- 7. Created RebuildDmpFile method as:
- function File RebuildDmpFile(File dmpfile)
- String name = File.GetName(dmpFile)
- String tmpname = Str.Format("%1.tmp", name)
- String dir = File.GetPath(dmpFile)
- File fTmpFile = File.StringToFile(Str.Format("%1%2%3", dir, File.Separator(), tmpname))
- File.Delete(fTmpFile)
- File.Open(fTmpFile, File.WriteMode)
- File fRead
- List lFiles
- String msg, sFile, line
- msg = Str.Format("Reassemble %1.* into %2", name, tmpname)
- echo(msg)
- lFiles = List.Sort(File.FileList(dir))
- for sFile in lFiles
- if (sFile != File.FileToString(fTmpFile))
- if (Str.Locate(sFile, File.FileToString(dmpfile)) == 1)
- echo(" Processing ", sFile)
- fRead = File.Open( sFile, File.ReadMode )
- for ( line = File.Read(fRead) ; \
- line != File.E_Eof ; \
- line = File.Read(fRead) )
- File.Write(fTmpFile, line)
- end
- File.Close(fRead)
- end
- end
- end
- File.Close(fTmpFile)
- return fTmpFile
- end
- 8. Wrote _test_export function as follows:
- function _test_export()
- .ExportOSpace(Undefined, OS.Root('aabmod'))
- end
- 9. Wrote _test_reconstruct function as follows:
- function _test_reconstruct()
- File dmp = File.StringToFile("E:\csapps\opentext\module\aabmod_1_0_1\src\aabmod.dmp")
- File tmp = .RebuildDmpFile(dmp)
- echo("Ok, import " , File.FileToString(tmp))
- end
Advertisement
Add Comment
Please, Sign In to add comment