(byte[] decrypteddata, TitleMetaData tmd)
| 84 | } |
| 85 | //private Map<Content,List<FEntry>> contentmap = new HashMap<>(); |
| 86 | private void parse(byte[] decrypteddata, TitleMetaData tmd) throws IOException { |
| 87 | |
| 88 | if(!Arrays.equals(Arrays.copyOfRange(decrypteddata, 0, 3), new byte[]{0x46,0x53,0x54})){ |
| 89 | throw new IllegalArgumentException("Not a FST. Maybe a wrong key? Don't worry if you only want to download encrypted files!"); |
| 90 | } |
| 91 | this.totalContentCount = Util.getIntFromBytes(decrypteddata, 8); |
| 92 | int base_offset = 0x20+totalContentCount*0x20; |
| 93 | this.totalEntries = Util.getIntFromBytes(decrypteddata, base_offset+8); |
| 94 | int nameOff = base_offset + totalEntries * 0x10; |
| 95 | |
| 96 | int level=0; |
| 97 | int[] LEntry = new int[16]; |
| 98 | int[] Entry = new int[16]; |
| 99 | |
| 100 | /* |
| 101 | for(int i = 0;i<totalContentCount;i++){ |
| 102 | contentmap.put(tmd.contents[i],new ArrayList<FEntry>()); |
| 103 | int my_offset = 0x20 + (i* 0x20); |
| 104 | int address = Util.getIntFromBytes(decrypteddata, my_offset+ 0) ; |
| 105 | long parentid = Util.getLongFromBytes(decrypteddata, my_offset+ 8) ; |
| 106 | int groupid = Util.getIntFromBytes(decrypteddata, my_offset+ 16) ; |
| 107 | int size = Util.getIntFromBytes(decrypteddata, my_offset+ 4); |
| 108 | byte hashmode = decrypteddata[my_offset+ 20]; |
| 109 | System.out.print(String.format("Content %02X: ", i) + " offset " + String.format("%08X", address)+ " size " + String.format("%08X", size) +" "); |
| 110 | System.out.print(String.format("parent(?) %016X: ", parentid) + " groupid " + String.format("%08X", groupid)+ " hashmode " + String.format("%01X", hashmode) +" "); |
| 111 | System.out.println(String.format("encrypted content size: "+ String.format("%08X", tmd.contents[i].size))); |
| 112 | }*/ |
| 113 | |
| 114 | for(int i = 0;i<this.totalEntries;i++){ |
| 115 | boolean dir = false; |
| 116 | boolean in_nus_title = true; |
| 117 | boolean extract_withHash = false; |
| 118 | |
| 119 | long fileOffset; |
| 120 | long fileLength; |
| 121 | int type; |
| 122 | int contentID; |
| 123 | |
| 124 | String filename = ""; |
| 125 | String path = ""; |
| 126 | |
| 127 | if( level > 0) |
| 128 | { |
| 129 | while( LEntry[level-1] == i ) |
| 130 | { |
| 131 | level--; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | int offset = base_offset + i*0x10; |
| 136 | |
| 137 | //getting the type |
| 138 | type = (int) decrypteddata[offset]+128; |
| 139 | if((type & FEntry.DIR_FLAG) == 1) dir = true; |
| 140 | if((type & FEntry.NOT_IN_NUSTITLE_FLAG) == 0 ) in_nus_title = false; |
| 141 | |
| 142 | |
| 143 | //getting Name |
no test coverage detected