Last active
December 14, 2023 08:05
-
-
Save eliemichel/0cc410e7a928e9ff289fb7765af18004 to your computer and use it in GitHub Desktop.
List the items contained in a Marmoset Viewer's .mview archive file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
def readCString(f): | |
"""This is the most naive implementation possible, don't use in prod""" | |
str = "" | |
c = f.read(1) | |
while c != '\0': | |
str += c | |
c = f.read(1) | |
return str | |
def getFileSize(f): | |
pos = f.tell() | |
f.seek(0, 2) | |
end = f.tell() | |
f.seek(pos, 0) | |
return end | |
with open("vivfox.mview", 'rb') as f: | |
end = getFileSize(f) | |
fmt = "{:<18} {:<18} {:>10} {:>10} {:>10}" # Output table format | |
print(fmt.format("Name", "MIME type", "Compressed", "Size", "Raw size")) | |
while True: | |
name = readCString(f) | |
mime = readCString(f) | |
compressed, size, rawSize = struct.unpack("III", f.read(3*4)) | |
print(fmt.format(name, mime, str(bool(compressed & 1)), hex(size), hex(rawSize))) | |
if f.tell() + size >= end: | |
break | |
f.seek(size, 1) # move forward by "size" bytes in the file |
Thanks for the feedback :) Might be a matter of Python 2 vs Python 3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I came from
importing-actual-3d-models-from-google-maps
. Thanks for the article.Because I got stuck at
f.read(1)
, I post a notec = f.read(1).decode('ascii')
helped my case.