Skip to content

Commit

Permalink
Added: Windows support
Browse files Browse the repository at this point in the history
One day Windows will embrace / for directories rather than \\
  • Loading branch information
UnderMybrella committed Apr 6, 2016
1 parent 030ddea commit 5f75c36
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/org/abimon/mods/danganronpa/launcher/DDFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public void write(File newWad, ZipFile... modsToAdd) throws IOException{
System.out.println("Writing modded files");

for(String s : patches.keySet()){
File moddedFile = new File(dir, s);
File moddedFile = new File(dir, s.replace("/", File.separator).replace("\\", File.separator));

System.out.println(moddedFile);

Expand Down
6 changes: 5 additions & 1 deletion src/org/abimon/mods/danganronpa/launcher/DanganLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public static void main(String[] args) throws IOException{
if(!modsDir.exists())
modsDir.mkdir();

if(EnumOS.determineOS() == EnumOS.WINDOWS){}
if(EnumOS.determineOS() == EnumOS.WINDOWS){
wadFileDR1 = new File("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Danganronpa Trigger Happy Havoc\\dr1_data.wad");
if(!wadFileDR1.exists())
wadFileDR1 = new File("C:\\Program Files\\Steam\\steamapps\\common\\Danganronpa Trigger Happy Havoc\\dr1_data.wad");
}
else if(EnumOS.determineOS() == EnumOS.MACOSX)
wadFileDR1 = new File(EnumOS.determineOS().getStorageLocation("Steam") + "/steamapps/common/Danganronpa Trigger Happy Havoc/Danganronpa.app/Contents/Resources/dr1_data.wad");

Expand Down
9 changes: 6 additions & 3 deletions src/org/abimon/mods/danganronpa/launcher/DanganModding.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class DanganModding {
public static LinkedList<DRFile> files = new LinkedList<DRFile>();

public static void extract(File wad, File extractDir, PrintStream out) throws Throwable{
files.clear();
long start = System.currentTimeMillis();

DataInputStream in = new DataInputStream(new FileInputStream(wad));
Expand Down Expand Up @@ -78,12 +79,14 @@ public static void extract(File wad, File extractDir, PrintStream out) throws Th
for(int i = 0; i < DanganModding.files.size(); i++){
DRFile drfile = DanganModding.files.get(i);

out.println("Extracting " + drfile.name);

byte[] data = new byte[(int) drfile.size];
in.read(data);

File dirs = new File(extractDir.getAbsolutePath() + File.separator + drfile.name.substring(0, drfile.name.length() - drfile.name.split("/")[drfile.name.split("/").length - 1].length()));
File dirs = new File(extractDir.getAbsolutePath() + File.separator + drfile.name.substring(0, drfile.name.length() - drfile.name.split("/")[drfile.name.split("/").length - 1].length()).replace("/", File.separator).replace("\\", File.separator));
dirs.mkdirs();
File output = new File(extractDir.getAbsolutePath() + File.separator + drfile.name);
File output = new File(extractDir.getAbsolutePath() + File.separator + drfile.name.replace("/", File.separator).replace("\\", File.separator));

FileOutputStream fos = new FileOutputStream(output);
fos.write(data);
Expand Down Expand Up @@ -181,7 +184,7 @@ public static void extract(File wad, File extractDir, PrintStream out) throws Th
public static void makeWad(File newWad, File wadDir, PrintStream pOut) throws IOException{
if(!wadDir.exists())
throw new IOException("WAD Directory does not exist");

files.clear();
FileOutputStream out = new FileOutputStream(newWad);

out.write("AGAR".getBytes());
Expand Down

0 comments on commit 5f75c36

Please sign in to comment.