spacepaste

  1.  
  2. ## reading a 2GB bitstream file, already read in as f via chunking method.
  3. ## wpextract.log is a listing of the file header offset locations within the bitstream file
  4. ## wpfilesize.log is a listing of filesizes obtained from a struct.unpack method.
  5. ## Trying to create and write to a sequential list of files "on the fly" and extract data blocks that constitute WordPerfect files
  6. ## the out_block data is not being written to the series of empty .wp files, once created. Idle just hangs.
  7. g = open("images\\wpextract.log", "r") # reads header position file
  8. header_pos = g.readlines()
  9. h = open("images\\wpfilesize.log", "r") # reads in the list of file sizes for application in carve interation
  10. filesize_len = h.readlines()
  11. n=70 ##arbitrary figure - roughly 64 files, in truth
  12. for i in range(n):
  13. open('wpdocs\\file' + str(i) + '.wp', 'wb').close()
  14. root = "wpdocs"
  15. while f:
  16. for header in header_pos:
  17. f.seek(int(header), 0)
  18. for carved in filesize_len:
  19. out_block = f.read(int(carved))
  20. while out_block:
  21. listing = os.listdir(root)
  22. out_block = f.read(int(carved))
  23. for each_file in listing:
  24. path = os.path.join(root,each_file)
  25. doc_wp = open('path', 'wb')
  26. doc_wp.write("%s" % (out_block))
  27.