【问题标题】:Getting game ID of psx game获取psx游戏的游戏ID
【发布时间】:2018-10-30 17:18:49
【问题描述】:

我想知道从 .iso 或 .cue+.bin 格式的磁盘映像中获取标题的最佳方法是什么, 是否有任何 java 库可以做到这一点,或者我应该从文件头中读取?

更新: 我设法做到了,我对 PSX ISO 的标题特别感兴趣。它有 10 个字节长,这是一个读取它的示例代码:

File f = new File("cdimage2.bin");
FileInputStream fin = new FileInputStream(f);
fin.skip(37696);
int i = 0;
while (i < 10) {
    System.out.print((char) fin.read());
    i++;
}
System.out.println();

UPDATE2:这种方法更好:

private String getPSXId(File f) {
FileInputStream fin;
try {
    fin = new FileInputStream(f);
    fin.skip(32768);
    byte[] buffer = new byte[4096];
    long start = System.currentTimeMillis();
    while (fin.read(buffer) != -1) {
        String buffered = new String(buffer);

        if (buffered.contains("BOOT = cdrom:\\")) {
            String tmp = "";
            int lidx = buffered.lastIndexOf("BOOT = cdrom:\\") + 14;
            for (int i = 0; i < 11; i++) {
                tmp += buffered.charAt(lidx + i);
            }
            long elapsed = System.currentTimeMillis() - start;
            // System.out.println("BOOT = cdrom:\\" + tmp);
            tmp = tmp.toUpperCase().replace(".", "").replace("_", "-");
            fin.close();
            return tmp;
        }

    }
    fin.close();
} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

return null;

}

【问题讨论】:

    标签: java android


    【解决方案1】:

    在 2048 字节块(卷描述符)中的 32768 字节(ISO9660 未使用)后开始读取。第一个字节确定描述符的类型,1 表示Primary Volume Descriptor,其中包含前 7 个字节之后的标题(始终为\x01CD001\x01)。下一个字节是 NUL (\x00),后面是 32 字节的系统和 32 字节的卷标识符,后者通常称为标题并显示为标题。有关更详细的说明,请参阅http://alumnus.caltech.edu/~pje/iso9660.html

    【讨论】:

    • 我对 PSX iso 特别感兴趣,我发现标题有 10 个字节长,从 37696 字节开始
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-11
    • 1970-01-01
    • 2015-06-12
    • 2021-10-09
    • 2014-04-08
    • 2014-01-21
    • 1970-01-01
    相关资源
    最近更新 更多