|
|
@ -207,18 +207,27 @@ class OutputFiles: |
|
|
|
|
|
|
|
|
|
|
|
@contextmanager |
|
|
|
@contextmanager |
|
|
|
def generate_dat_file(self, filename, **kwargs): |
|
|
|
def generate_dat_file(self, filename, **kwargs): |
|
|
|
if self._is_zip: |
|
|
|
dat_only = self._exporter().dat_only |
|
|
|
|
|
|
|
dirname = kwargs.get("dirname", "dat") |
|
|
|
|
|
|
|
bogus = dat_only and dirname != "dat" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self._is_zip or bogus: |
|
|
|
stream = hsRAMStream(self._version) |
|
|
|
stream = hsRAMStream(self._version) |
|
|
|
else: |
|
|
|
else: |
|
|
|
file_path = str(self._export_file.parent / filename) |
|
|
|
if dat_only: |
|
|
|
|
|
|
|
file_path = str(self._export_file.parent / filename) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
file_path = str(self._export_path / dirname / filename) |
|
|
|
stream = hsFileStream(self._version) |
|
|
|
stream = hsFileStream(self._version) |
|
|
|
stream.open(file_path, fmCreate) |
|
|
|
stream.open(file_path, fmCreate) |
|
|
|
backing_stream = stream |
|
|
|
backing_stream = stream |
|
|
|
|
|
|
|
|
|
|
|
enc = kwargs.get("enc", None) |
|
|
|
# No sense in wasting time encrypting data that isn't going to be used in the export |
|
|
|
if enc is not None: |
|
|
|
if not bogus: |
|
|
|
stream = plEncryptedStream(self._version) |
|
|
|
enc = kwargs.get("enc", None) |
|
|
|
stream.open(backing_stream, fmCreate, enc) |
|
|
|
if enc is not None: |
|
|
|
|
|
|
|
stream = plEncryptedStream(self._version) |
|
|
|
|
|
|
|
stream.open(backing_stream, fmCreate, enc) |
|
|
|
|
|
|
|
|
|
|
|
# The actual export code is run at the "yield" statement. If an error occurs, we |
|
|
|
# The actual export code is run at the "yield" statement. If an error occurs, we |
|
|
|
# do not want to track this file. Note that the except block is required for the |
|
|
|
# do not want to track this file. Note that the except block is required for the |
|
|
@ -236,20 +245,20 @@ class OutputFiles: |
|
|
|
# Not passing enc as a keyword argument to the output file definition. It makes more |
|
|
|
# Not passing enc as a keyword argument to the output file definition. It makes more |
|
|
|
# sense to yield an encrypted stream from this context manager and encrypt as we go |
|
|
|
# sense to yield an encrypted stream from this context manager and encrypt as we go |
|
|
|
# instead of doing lots of buffer copying to encrypt as a post step. |
|
|
|
# instead of doing lots of buffer copying to encrypt as a post step. |
|
|
|
dirname = kwargs.get("dirname", "dat") |
|
|
|
if not bogus: |
|
|
|
kwargs = { |
|
|
|
kwargs = { |
|
|
|
"file_type": _FileType.generated_dat if dirname == "dat" else |
|
|
|
"file_type": _FileType.generated_dat if dirname == "dat" else |
|
|
|
_FileType.generated_ancillary, |
|
|
|
_FileType.generated_ancillary, |
|
|
|
"dirname": dirname, |
|
|
|
"dirname": dirname, |
|
|
|
"filename": filename, |
|
|
|
"filename": filename, |
|
|
|
"skip_hash": kwargs.get("skip_hash", False), |
|
|
|
"skip_hash": kwargs.get("skip_hash", False), |
|
|
|
"internal": kwargs.get("internal", False), |
|
|
|
"internal": kwargs.get("internal", False), |
|
|
|
} |
|
|
|
} |
|
|
|
if isinstance(backing_stream, hsRAMStream): |
|
|
|
if isinstance(backing_stream, hsRAMStream): |
|
|
|
kwargs["file_data"] = backing_stream.buffer |
|
|
|
kwargs["file_data"] = backing_stream.buffer |
|
|
|
else: |
|
|
|
else: |
|
|
|
kwargs["file_path"] = file_path |
|
|
|
kwargs["file_path"] = file_path |
|
|
|
self._files.add(_OutputFile(**kwargs)) |
|
|
|
self._files.add(_OutputFile(**kwargs)) |
|
|
|
|
|
|
|
|
|
|
|
def _generate_files(self, func=None): |
|
|
|
def _generate_files(self, func=None): |
|
|
|
dat_only = self._exporter().dat_only |
|
|
|
dat_only = self._exporter().dat_only |
|
|
|