VM Maker: ImageFormat-kks.34.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: ImageFormat-kks.34.mcz

commits-2
 
David T. Lewis uploaded a new version of ImageFormat to project VM Maker:
http://source.squeak.org/VMMaker/ImageFormat-kks.34.mcz

==================== Summary ====================

Name: ImageFormat-kks.34
Author: kks
Time: 10 April 2019, 10:43:56.983339 pm
UUID: b6d8d060-b305-437e-93b7-68e5427a76e0
Ancestors: ImageFormat-dtl.33

Added support for images whose header begins 512 bytes into the file. Expanded comments to explain magic file use.

=============== Diff against ImageFormat-dtl.33 ===============

Item was changed:
  ----- Method: ImageFormat class>>unixMagicFileEntries (in category 'unix magic file entries') -----
  unixMagicFileEntries
+ "Answer a string that can be appended to /etc/magic on a Unix system to support the file(1) utility.
+ For example, the file magic produced by
+ (FileStream newFileNamed: 'magic') in: [:fs |
+ [fs nextPutAll: ImageFormat unixMagicFileEntries ] ensure: [ fs close ]]
+ can be appended to $HOME/.magic and then
+   $ file squeak.image pharo.image  ...
+ will describe the given image files precisely"
- "Answer a string that can be appended to /etc/magic on a Unix system to support the file(1) utility"
 
- "ImageFormat unixMagicFileEntries"
-
- " | fs |
- fs := FileStream newFileNamed: 'magic'.
- [ fs nextPutAll: ImageFormat unixMagicFileEntries ]
- ensure: [ fs close ] "
-
  ^String streamContents: [:s |
  s nextPutAll: '# Smalltalk image file formats'; lf.
  KnownVersionNumbers do: [ :num | | fmt |
  #( 'le' 'be' ) do: [ :endian |
+ #(0 512) do: [ :offset |
+ fmt := self fromInteger: num.
+ (fmt is64Bit and: [ endian = 'be' ])
+ ifTrue: [ s nextPutAll:  (offset+4) asString ]
+ ifFalse: [ s nextPutAll: offset asString ].
+ s tab;
+ nextPutAll: endian;
+ nextPutAll: 'long';
+ tab;
+ nextPutAll: num asString;
+ tab;
+ nextPutAll: 'Smalltalk '.
+ fmt printTerseDescriptionOn: s.
+ s lf.
+ s nextPutAll: '!!:mime application/';
+ nextPutAll: fmt simpleName;
+ nextPutAll: '-image';
+ lf
+ ]
- fmt := self fromInteger: num.
- (fmt is64Bit and: [ endian = 'be' ])
- ifTrue: [ s nextPut: $4 ]
- ifFalse: [ s nextPut: $0 ].
- s tab;
- nextPutAll: endian;
- nextPutAll: 'long';
- tab;
- nextPutAll: num asString;
- tab;
- nextPutAll: 'Smalltalk '.
- fmt printTerseDescriptionOn: s.
- s lf.
- s nextPutAll: '!!:mime application/';
- nextPutAll: fmt simpleName;
- nextPutAll: '-image';
- lf
  ]
  ].
  s lf.
  ]!