def from_file(cls, filename):
st = os.stat(filename)
isdir = stat.S_ISDIR(st.st_mode)
arcname = os.path.normpath(os.path.splitdrive(filename)[1])[-16:]
while arcname[0] in (os.sep, os.altsep):
arcname = arcname[1:]
if isdir:
raise RuntimeError('WadFile expects a file, got a directory')
info = cls(arcname)
info.type = TYPE_LUMP
info.file_size = st.st_size
info.disk_size = st.st_size
info.filename = os.path.basename(arcname)[-16:]
return info
评论列表
文章目录