Class NintendoDsRom

java.lang.Object
io.github.turtleisaac.nds4j.NintendoDsRom

public class NintendoDsRom extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NintendoDsRom(byte[] data)
    Creates a NintendoDsRom object from a provided byte[] representing the bytes of a ROM file
  • Method Summary

    Modifier and Type
    Method
    Description
    fromFile(File file)
    Reads a NintendoDsRom from a ROM file on disk
    Reads a NintendoDsRom from a ROM file on disk
    Creates a NintendoDsRom from an unpacked ROM on disk
    Creates a NintendoDsRom from an unpacked ROM on disk
    byte[]
    Return the data for the file with the given filename (path).
    byte[]
    save(boolean updateDeviceCapacity)
    Generate a byte[] representation of this ROM
    void
    saveToFile(File filePath, boolean updateDeviceCapacity)
    Generate binary file representing this ROM, and save it to the file specified by filePath.
    void
    saveToFile(String filePath, boolean updateDeviceCapacity)
    Generate binary file representing this ROM, and save it to the file specified by filePath.
    void
    setFileByName(String filename, byte[] data)
    Set the data for the file with the given filename (path).
     
    void
    unpack(File dir)
    Unpacks the rom to the target directory on disk
    void
    Unpacks the rom to the target directory on disk

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • NintendoDsRom

      public NintendoDsRom(byte[] data)
      Creates a NintendoDsRom object from a provided byte[] representing the bytes of a ROM file
      Parameters:
      data - a byte[]
  • Method Details

    • fromFile

      public static NintendoDsRom fromFile(String file)
      Reads a NintendoDsRom from a ROM file on disk
      Parameters:
      file - a String containing the path to a ROM file on disk
      Returns:
      a NintendoDsRom
    • fromFile

      public static NintendoDsRom fromFile(File file)
      Reads a NintendoDsRom from a ROM file on disk
      Parameters:
      file - a File containing the path to a ROM file on disk
      Returns:
      a NintendoDsRom
    • save

      public byte[] save(boolean updateDeviceCapacity)
      Generate a byte[] representation of this ROM
      Parameters:
      updateDeviceCapacity - whether the rom capacity code in the header will be changed (boolean)
      Returns:
      a byte[]
    • saveToFile

      public void saveToFile(String filePath, boolean updateDeviceCapacity) throws IOException
      Generate binary file representing this ROM, and save it to the file specified by filePath.
      Parameters:
      filePath - String containing path to file on disk where the rom will be saved
      updateDeviceCapacity - whether the rom capacity code in the header will be changed (boolean)
      Throws:
      IOException - if the specified file's parent directory does not exist.
    • saveToFile

      public void saveToFile(File filePath, boolean updateDeviceCapacity) throws IOException
      Generate binary file representing this ROM, and save it to the file specified by filePath.
      Parameters:
      filePath - File containing path to file on disk where the rom will be saved
      updateDeviceCapacity - whether the rom capacity code in the header will be changed (boolean)
      Throws:
      IOException - if the specified file's parent directory does not exist.
    • fromUnpacked

      public static NintendoDsRom fromUnpacked(String dir)
      Creates a NintendoDsRom from an unpacked ROM on disk
      Parameters:
      dir - a String containing the path to an unpacked ROM on disk
      Returns:
      a NintendoDsRom
    • fromUnpacked

      public static NintendoDsRom fromUnpacked(File dir)
      Creates a NintendoDsRom from an unpacked ROM on disk
      Parameters:
      dir - a File containing the path to an unpacked ROM on disk
      Returns:
      a NintendoDsRom
    • unpack

      public void unpack(String dir) throws IOException
      Unpacks the rom to the target directory on disk
      Parameters:
      dir - a String containing the path to the target directory
      Throws:
      IOException - if any of the output files fail to be written
    • unpack

      public void unpack(File dir) throws IOException
      Unpacks the rom to the target directory on disk
      Parameters:
      dir - a File object containing the path to the target directory
      Throws:
      IOException - if any of the output files fail to be written
    • getFileByName

      public byte[] getFileByName(String filename)
      Return the data for the file with the given filename (path).
      Parameters:
      filename - a String path to a file in the ROM
      Returns:
      a byte[] representing the file contents
    • setFileByName

      public void setFileByName(String filename, byte[] data)
      Set the data for the file with the given filename (path).
      Parameters:
      filename - a String path to a file in the ROM
      data - a byte[] containing the new file contents
    • toString

      public String toString()
      Overrides:
      toString in class Object