ossiejhmoore

Exporting Module as Single DMP File Per Object

Aug 20th, 2012
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. BELOW IS WHAT I DID TO ***EXPERIMENTALLY*** EXPORT A OSCRIPT MODULE AS A COLLECTION OF DUMP
  2. FILES (ONE FOR EACH OSPACE OBJECT) RATHER THAN A SINGLE MONOLITHIC DUMP FILE.
  3.  
  4. You can view the Viemo video https://vimeo.com/47891950 to watch a demo of this very crude proof-of-concept quality code.
  5.  
  6.  
  7. 1. Created new Child 'OSUtils' under "[my module] Root"
  8. 2. Copied "Builder Root:Builder Utils" features "NewOSpaceStetup","SystemFeatures","ExportOspace"
  9. 3. Created Integer fCounter, setting initial value to 10000
  10. 4. Created Dynamic fDmpFile, leaving Undefined
  11. 5. Edited ExportOspace to write a new .dmp file for each object by doing this:
  12.  
  13. 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.
  14.  
  15. --- E:/csapps/opentext/module/aabmod_1_0_1/src/ExportOspace_original.txt
  16. +++ E:/csapps/opentext/module/aabmod_1_0_1/src/ExportOspace_modified.txt
  17. @@ -22,6 +22,7 @@
  18. dynamic f
  19. object x
  20.  
  21. + .fCounter = 10000
  22.  
  23. if OS.IsObject( starthere )
  24. root = starthere
  25. @@ -34,6 +35,7 @@
  26. else
  27. outfile = File.StringToFile( filename )
  28. end
  29. + .fDmpFile = outfile
  30.  
  31. $cancelled = false
  32.  
  33. @@ -81,6 +83,7 @@
  34. Dialog.Close( $progress )
  35.  
  36. $outputFile = undefined
  37. + .fCounter = 10000
  38. end
  39. end
  40.  
  41. @@ -99,6 +102,10 @@
  42.  
  43.  
  44. function void PrintObject( object o )
  45. + File outputFile = $outputFile
  46. + File myFile = .GetFileFor(o)
  47. + $outputFile = myFile
  48. + File.Open( $outputFile, "w" )
  49. object obj
  50. boolean featureSet
  51. string featureName
  52. @@ -173,6 +180,8 @@
  53. break
  54. end
  55. end
  56. + File.Close(myFile)
  57. + $outputFile = outputFile
  58. end
  59.  
  60. 6. Created GetFileFor method as follows:
  61.  
  62. function File GetFileFor(Object o)
  63. .fCounter += 1
  64. String s = Str.Format("%1_%2_%3.dmp", File.FileToString(.fDmpFile), .fCounter, o.osName)
  65. File f = File.StringToFile(s)
  66. return f
  67. end
  68.  
  69. 7. Created RebuildDmpFile method as:
  70.  
  71. function File RebuildDmpFile(File dmpfile)
  72.  
  73.  
  74. String name = File.GetName(dmpFile)
  75. String tmpname = Str.Format("%1.tmp", name)
  76. String dir = File.GetPath(dmpFile)
  77. File fTmpFile = File.StringToFile(Str.Format("%1%2%3", dir, File.Separator(), tmpname))
  78. File.Delete(fTmpFile)
  79. File.Open(fTmpFile, File.WriteMode)
  80. File fRead
  81.  
  82. List lFiles
  83. String msg, sFile, line
  84.  
  85. msg = Str.Format("Reassemble %1.* into %2", name, tmpname)
  86. echo(msg)
  87.  
  88. lFiles = List.Sort(File.FileList(dir))
  89. for sFile in lFiles
  90. if (sFile != File.FileToString(fTmpFile))
  91. if (Str.Locate(sFile, File.FileToString(dmpfile)) == 1)
  92. echo(" Processing ", sFile)
  93. fRead = File.Open( sFile, File.ReadMode )
  94.  
  95.  
  96. for ( line = File.Read(fRead) ; \
  97. line != File.E_Eof ; \
  98. line = File.Read(fRead) )
  99.  
  100. File.Write(fTmpFile, line)
  101.  
  102. end
  103. File.Close(fRead)
  104. end
  105. end
  106. end
  107.  
  108. File.Close(fTmpFile)
  109. return fTmpFile
  110.  
  111. end
  112.  
  113. 8. Wrote _test_export function as follows:
  114.  
  115. function _test_export()
  116. .ExportOSpace(Undefined, OS.Root('aabmod'))
  117. end
  118.  
  119. 9. Wrote _test_reconstruct function as follows:
  120.  
  121. function _test_reconstruct()
  122. File dmp = File.StringToFile("E:\csapps\opentext\module\aabmod_1_0_1\src\aabmod.dmp")
  123. File tmp = .RebuildDmpFile(dmp)
  124. echo("Ok, import " , File.FileToString(tmp))
  125. end
Advertisement
Add Comment
Please, Sign In to add comment