summaryrefslogtreecommitdiff
path: root/src/com/sneed/pkrandom/ctr/NCCH.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/sneed/pkrandom/ctr/NCCH.java')
-rw-r--r--src/com/sneed/pkrandom/ctr/NCCH.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/com/sneed/pkrandom/ctr/NCCH.java b/src/com/sneed/pkrandom/ctr/NCCH.java
index 1134095..ccf735c 100644
--- a/src/com/sneed/pkrandom/ctr/NCCH.java
+++ b/src/com/sneed/pkrandom/ctr/NCCH.java
@@ -23,6 +23,7 @@ package com.sneed.pkrandom.ctr;
import com.sneed.pkrandom.FileFunctions;
import com.sneed.pkrandom.SysConstants;
+import com.sneed.pkrandom.exceptions.CannotWriteToLocationException;
import com.sneed.pkrandom.exceptions.EncryptedROMException;
import com.sneed.pkrandom.exceptions.RandomizerIOException;
import cuecompressors.BLZCoder;
@@ -249,8 +250,12 @@ public class NCCH {
public void saveAsNCCH(String filename, String gameAcronym, long seed) throws IOException, NoSuchAlgorithmException {
this.reopenROM();
- // Initialise new ROM
- RandomAccessFile fNew = new RandomAccessFile(filename, "rw");
+ // Initialize new ROM
+ File file = new File(filename);
+ if (!file.canWrite()) {
+ throw new CannotWriteToLocationException("The randomizer cannot write to this location: " + filename);
+ }
+ RandomAccessFile fNew = new RandomAccessFile(file, "rw");
// Read the header and exheader and write it to the output ROM
byte[] header = new byte[header_and_exheader_size];