diff --git a/bbp_ng/OP_EXPORT_virtools.py b/bbp_ng/OP_EXPORT_virtools.py index 4979b0a..7157c29 100644 --- a/bbp_ng/OP_EXPORT_virtools.py +++ b/bbp_ng/OP_EXPORT_virtools.py @@ -44,10 +44,16 @@ class BBP_OT_export_virtools(bpy.types.Operator, UTIL_file_browser.ExportVirtool self.report({'ERROR'}, 'You must specify at least one encoding for file saving (e.g. cp1252, gbk)!') return {'CANCELLED'} + # check file name + filename = self.general_get_filename() + if not os.path.isfile(filename): + self.report({'ERROR'}, 'No file was selected!') + return {'CANCELLED'} + # start exporting with UTIL_ioport_shared.ExportEditModeBackup() as editmode_guard: _export_virtools( - self.general_get_filename(), + filename, encodings, texture_save_opt, self.general_get_use_compress(), @@ -74,7 +80,7 @@ _TTexturePair = tuple[bpy.types.Image, bmap.BMTexture] def _export_virtools( file_name_: str, - encodings_: tuple[str], + encodings_: tuple[str, ...], texture_save_opt_: UTIL_virtools_types.CK_TEXTURE_SAVEOPTIONS, use_compress_: bool, compress_level_: int, diff --git a/bbp_ng/OP_IMPORT_virtools.py b/bbp_ng/OP_IMPORT_virtools.py index 611cef8..58e3b07 100644 --- a/bbp_ng/OP_IMPORT_virtools.py +++ b/bbp_ng/OP_IMPORT_virtools.py @@ -32,8 +32,14 @@ class BBP_OT_import_virtools(bpy.types.Operator, UTIL_file_browser.ImportVirtool self.report({'ERROR'}, 'You must specify at least one encoding for file loading (e.g. cp1252, gbk)!') return {'CANCELLED'} + # check file name + filename = self.general_get_filename() + if not os.path.isfile(filename): + self.report({'ERROR'}, 'No file was selected!') + return {'CANCELLED'} + _import_virtools( - self.general_get_filename(), + filename, encodings, self.general_get_conflict_resolver() ) @@ -46,7 +52,7 @@ class BBP_OT_import_virtools(bpy.types.Operator, UTIL_file_browser.ImportVirtool self.draw_virtools_params(context, layout, True) self.draw_ballance_params(layout, True) -def _import_virtools(file_name_: str, encodings_: tuple[str], resolver: UTIL_ioport_shared.ConflictResolver) -> None: +def _import_virtools(file_name_: str, encodings_: tuple[str, ...], resolver: UTIL_ioport_shared.ConflictResolver) -> None: # create temp folder with tempfile.TemporaryDirectory() as vt_temp_folder: tr_text: str = bpy.app.translations.pgettext_rpt(