Fixed a wrong default type and a crash.

The create_file() function was crashing when the user was not selecting any file because and empty path cant be opened.
This commit is contained in:
The Wobbler 2024-11-30 22:38:45 +01:00
parent c838b99946
commit f80fbc8348

View file

@ -28,13 +28,16 @@ class FileActions:
self.app.open_files[file_path] = File(self.app, file_path, file_path.split("/")[-1]) self.app.open_files[file_path] = File(self.app, file_path, file_path.split("/")[-1])
def create_file(self, content: str=""): def create_file(self, content: bin=b""):
file_path, extension = QFileDialog.getSaveFileName( file_path, extension = QFileDialog.getSaveFileName(
caption="New File", caption="New File",
directory=self.app.utils.home_path, directory=self.app.utils.home_path,
filter="Binary (*.bin);;Any (*)", filter="Binary (*.bin);;Any (*)",
) )
if file_path == "":
return
if "Binary" in extension: if "Binary" in extension:
file_path = file_path.split(".")[0] + ".bin" # make sure it has the right extension file_path = file_path.split(".")[0] + ".bin" # make sure it has the right extension