summaryrefslogtreecommitdiff
path: root/src/com/sneed/pkrandom/romhandlers/AbstractGBRomHandler.java
diff options
context:
space:
mode:
authortom-overton <tom.overton@outlook.com>2022-07-12 14:39:46 -0700
committerrafa_99 <raroma09@gmail.com>2022-07-12 22:59:21 +0100
commit50db76cfa89dbf7d6292800bc90f01208d5d3620 (patch)
treea916d74a878d2e93b7e3fa35e5c9525827f8f2b4 /src/com/sneed/pkrandom/romhandlers/AbstractGBRomHandler.java
parentb4f7b51add999e29f22e5fa864e137506d7fbdf0 (diff)
If the randomizer tries to save to a place where it's not allowed to write, pop up a warning dialog instead of throwing an exception
Diffstat (limited to 'src/com/sneed/pkrandom/romhandlers/AbstractGBRomHandler.java')
-rwxr-xr-xsrc/com/sneed/pkrandom/romhandlers/AbstractGBRomHandler.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/com/sneed/pkrandom/romhandlers/AbstractGBRomHandler.java b/src/com/sneed/pkrandom/romhandlers/AbstractGBRomHandler.java
index 6520d72..6d24f1f 100755
--- a/src/com/sneed/pkrandom/romhandlers/AbstractGBRomHandler.java
+++ b/src/com/sneed/pkrandom/romhandlers/AbstractGBRomHandler.java
@@ -5,7 +5,7 @@ package com.sneed.pkrandom.romhandlers;
/*-- which standardises common GB(A) functions.--*/
/*-- --*/
/*-- Part of "Universal Pokemon Randomizer ZX" by the UPR-ZX team --*/
-/*-- Originally part of "Universal Pokemon Randomizer" by sneed --*/
+/*-- Originally part of "Universal Pokemon Randomizer" by sneed --*/
/*-- Pokemon and any associated names and the like are --*/
/*-- trademark and (C) Nintendo 1996-2020. --*/
/*-- --*/
@@ -35,6 +35,7 @@ import java.nio.file.Paths;
import java.util.Random;
import com.sneed.pkrandom.FileFunctions;
+import com.sneed.pkrandom.exceptions.CannotWriteToLocationException;
import com.sneed.pkrandom.exceptions.RandomizerIOException;
public abstract class AbstractGBRomHandler extends AbstractRomHandler {
@@ -70,7 +71,11 @@ public abstract class AbstractGBRomHandler extends AbstractRomHandler {
public boolean saveRomFile(String filename, long seed) {
savingRom();
try {
- FileOutputStream fos = new FileOutputStream(filename);
+ File file = new File(filename);
+ if (!file.canWrite()) {
+ throw new CannotWriteToLocationException("The randomizer cannot write to this location: " + filename);
+ }
+ FileOutputStream fos = new FileOutputStream(file);
fos.write(rom);
fos.close();
return true;