Commits

Victor Stinner  committed 53da326

  • Participants
  • Parent commits 629a4c3

Comments (0)

Files changed (1)

File hachoir-editor.wiki

+Hachoir editor is a library based on hachoir-core used to edit binary files.
+
+Today, only one program uses it: [[hachoir-strip]] (remove "useless" information to make a file smaller).
+
+=== Download ===
+
+There is no "stable release" yet, so use Mercurial to download it:
+ hg clone http://bitbucket.org/haypo/hachoir
+
+You can also [[http://bitbucket.org/haypo/hachoir/src/tip/hachoir-editor/|browse hachoir-editor source code online]]. 
+
+=== Example : gzip, remove filename ===
+
+{{{
+from hachoir_parser import createEditor
+from hachoir_core.field import writeIntoFile
+
+editor = createEditor(u"file.gz")
+del editor["filename"]
+editor["has_filename"].value = False
+writeIntoFile(editor, u"noname.gz")
+}}}
+
+=== Example : gzip, add extra ===
+
+{{{
+from hachoir_parser import createEditor
+from hachoir_core.field import writeIntoFile
+from hachoir_core.editor import EditableInteger, EditableBytes
+
+editor = createEditor(u"file.gz")
+extra = "abcd"
+editor["has_extra"].value = True
+editor.insertAfter("os",
+    EditableInteger(editor, "extra_length", False, 16, len(extra)),
+    EditableBytes(editor, "extra", extra))
+writeIntoFile(editor, u"file_extra.gz")
+}}}
+
+=== Example : zip, set comment  ===
+
+{{{
+from hachoir_parser import createEditor
+from hachoir_core.field import writeIntoFile
+
+editor = createEditor(u"file.zip")
+editor["end_central_directory/comment"].value = "new comment"
+writeIntoFile(editor, u"file_comment.zip")
+}}}