Skip to content

Commit

Permalink
format change
Browse files Browse the repository at this point in the history
  • Loading branch information
PhoenixZeng committed Apr 24, 2020
1 parent 3c20720 commit 1dd94d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
19 changes: 9 additions & 10 deletions src/main/java/systems/crigges/jmpq3/JMpqEditor.java
Expand Up @@ -616,13 +616,12 @@ public MpqFile getMpqFile(String name) throws IOException {

return new MpqFile(buffer, b, discBlockSize, name);
}

/**
* Gets the mpq file.
*
* @param block a block
* @return the mpq file
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public MpqFile getMpqFileByBlock(BlockTable.Block block) throws IOException {
Expand All @@ -633,25 +632,25 @@ public MpqFile getMpqFileByBlock(BlockTable.Block block) throws IOException {
fc.position(headerOffset + block.getFilePos());
readFully(buffer, fc);
buffer.rewind();

return new MpqFile(buffer, block, discBlockSize, "");
}

/**
* Gets the mpq files.
*
* @return the mpq files
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public List<MpqFile> getMpqFilesByBlockTable() throws IOException {
List<MpqFile> mpqFiles = new ArrayList<>();
ArrayList<Block> list = blockTable.getAllVaildBlocks();
for (Block block : list) {
try{
try {
MpqFile mpqFile = getMpqFileByBlock(block);
mpqFiles.add(mpqFile);
} catch (IOException ignore) {}
} catch (IOException ignore) {
}
}
return mpqFiles;
}
Expand Down Expand Up @@ -682,8 +681,8 @@ public void deleteFile(String name) {
* @throws NonWritableChannelException the non writable channel exception
* @throws IllegalArgumentException when the mpq has filename and not override
*/
public void insertByteArray(String name, byte[] input,boolean override) throws NonWritableChannelException,
IllegalArgumentException {
public void insertByteArray(String name, byte[] input, boolean override) throws NonWritableChannelException,
IllegalArgumentException {
if (!canWrite) {
throw new NonWritableChannelException();
}
Expand All @@ -696,7 +695,7 @@ public void insertByteArray(String name, byte[] input,boolean override) throws N
ByteBuffer data = ByteBuffer.wrap(input);
filenameToData.put(name, data);
}

/**
* Inserts the specified byte array into the mpq once you close the editor.
*
Expand Down Expand Up @@ -743,7 +742,7 @@ public void insertFile(String name, File file, boolean backupFile, boolean overr
if ((!override) && listFile.containsFile(name)) {
throw new IllegalArgumentException("Archive already contains file with name: " + name);
}

try{
listFile.addFile(name);
if (backupFile) {
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/systems/crigges/jmpq3test/MpqTests.java
Expand Up @@ -335,8 +335,8 @@ private void insertAndDelete(File mpq, String filename) throws IOException {
return;
}
//test override
mpqEditor.insertFile(filename, getFile(filename), false,true);
mpqEditor.insertFile(filename, getFile(filename), false,true);
mpqEditor.insertFile(filename, getFile(filename), false, true);
mpqEditor.insertFile(filename, getFile(filename), false, true);

mpqEditor.deleteFile(filename);
}
Expand Down Expand Up @@ -417,12 +417,12 @@ public void testForGetMpqFileByBlock() throws IOException {
continue;
}
try (JMpqEditor mpqEditor = new JMpqEditor(mpq, MPQOpenOption.FORCE_V0)) {

Assert.assertTrue(mpqEditor.getMpqFilesByBlockTable().size() > 0);
BlockTable blockTable = mpqEditor.getBlockTable();
Assert.assertNotNull(blockTable);
for (BlockTable.Block block : blockTable.getAllVaildBlocks())
{

for (BlockTable.Block block : blockTable.getAllVaildBlocks()) {
if (block.hasFlag(MpqFile.ENCRYPTED)) {
continue;
}
Expand Down

0 comments on commit 1dd94d3

Please sign in to comment.