Move to JRE8, store/restore CD or DVD user selection, fix issue when file was not actually deleted till application closed, add few cosmetic changes to pom.xml, insert screenshot to README.md
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

master v1.1
Dmitry Isaenko 2022-09-18 01:18:39 +03:00
parent dc6e3151d0
commit 4b748e62f7
9 changed files with 64 additions and 41 deletions

View File

@ -4,6 +4,8 @@
OPL-compatible PS2 tool for making split files. Sort of ul.cfg manager or USBUtil. OPL-compatible PS2 tool for making split files. Sort of ul.cfg manager or USBUtil.
![Application screenshot](screenshots/1.png)
#### Let's stay in touch #### Let's stay in touch
GitHubs are arising and passing, cozy mirrors are eternal: https://git.redrise.ru/desu/Tihwin GitHubs are arising and passing, cozy mirrors are eternal: https://git.redrise.ru/desu/Tihwin

View File

@ -4,15 +4,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>loper</groupId> <groupId>ru.redrise</groupId>
<name>Tihwin</name> <name>Tihwin</name>
<artifactId>Tihwin</artifactId> <artifactId>Tihwin</artifactId>
<version>1.0</version> <version>1.1</version>
<url>https://github.com/developersu/${project.artifactId}/</url> <url>https://github.com/developersu/${project.artifactId}/</url>
<description> <description>
NS Atmosphere dongle flash tool OPL-compatible PS2 tool for making split files. Sort of ul.cfg manager or USBUtil.
</description> </description>
<inceptionYear>2022</inceptionYear> <inceptionYear>2022</inceptionYear>
<organization> <organization>
@ -36,7 +36,7 @@
<role>Developer</role> <role>Developer</role>
</roles> </roles>
<timezone>+3</timezone> <timezone>+3</timezone>
<url>https://developersu.blogspot.com/</url> <url>https://redrise.ru/</url>
</developer> </developer>
</developers> </developers>

BIN
screenshots/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -72,7 +72,10 @@ public class MainAppUi extends JFrame {
destinationSelectBtn.addActionListener(actionEvent -> destinationSelectEventHandler()); destinationSelectBtn.addActionListener(actionEvent -> destinationSelectEventHandler());
convertBtn.addActionListener(actionEvent -> convertButtonAction()); convertBtn.addActionListener(actionEvent -> convertButtonAction());
((AbstractDocument) titleField.getDocument()).setDocumentFilter(new TitleFieldFilter()); ((AbstractDocument) titleField.getDocument()).setDocumentFilter(new TitleFieldFilter());
if (Settings.INSTANCE.getDvdSelected())
DVDRadioButton.setSelected(true);
else
CDRadioButton.setSelected(true);
recentRomLocation = Settings.INSTANCE.getRomLocation(); recentRomLocation = Settings.INSTANCE.getRomLocation();
destinationDirectoryLbl.setText(FilesHelper.getRealFolder(Settings.INSTANCE.getDestination())); destinationDirectoryLbl.setText(FilesHelper.getRealFolder(Settings.INSTANCE.getDestination()));
@ -90,6 +93,7 @@ public class MainAppUi extends JFrame {
public void windowClosing(WindowEvent windowEvent) { public void windowClosing(WindowEvent windowEvent) {
Settings.INSTANCE.setRomLocation(recentRomLocation); Settings.INSTANCE.setRomLocation(recentRomLocation);
Settings.INSTANCE.setDestination(destinationDirectoryLbl.getText()); Settings.INSTANCE.setDestination(destinationDirectoryLbl.getText());
Settings.INSTANCE.setDvdSelected(DVDRadioButton.isSelected());
} }
@Override @Override

View File

@ -35,6 +35,9 @@ public class Settings {
public String getDestination(){ public String getDestination(){
return preferences.get("destination", System.getProperty("user.home")); return preferences.get("destination", System.getProperty("user.home"));
} }
public boolean getDvdSelected(){
return preferences.getBoolean("dvd_selected", true);
}
public void setDestination(String location){ public void setDestination(String location){
preferences.put("destination", location); preferences.put("destination", location);
@ -42,4 +45,7 @@ public class Settings {
public void setRomLocation(String location){ public void setRomLocation(String location){
preferences.put("rom_location", location); preferences.put("rom_location", location);
} }
public void setDvdSelected(boolean value) {
preferences.putBoolean("dvd_selected", value);
}
} }

View File

@ -20,6 +20,7 @@
*/ */
package tihwin.ul; package tihwin.ul;
import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.Arrays;
@ -85,14 +86,14 @@ public class UlConfiguration {
public byte[] generateUlConfig(){ public byte[] generateUlConfig(){
ByteBuffer byteBuffer = ByteBuffer.allocate(0x40); ByteBuffer byteBuffer = ByteBuffer.allocate(0x40);
byteBuffer.put(title.getBytes(StandardCharsets.US_ASCII)); byteBuffer.put(title.getBytes(StandardCharsets.US_ASCII));
byteBuffer.position(32); ((Buffer) byteBuffer).position(32);
byteBuffer.put(("ul."+publisherTitle).getBytes()); byteBuffer.put(("ul."+publisherTitle).getBytes());
byteBuffer.position(32+15); ((Buffer) byteBuffer).position(32+15);
byteBuffer.put(chunksCount); byteBuffer.put(chunksCount);
byteBuffer.put(cdDvdFlag); byteBuffer.put(cdDvdFlag);
byteBuffer.position(53); ((Buffer) byteBuffer).position(53);
byteBuffer.put((byte) 0x8); // weird. no idea why it's here byteBuffer.put((byte) 0x8); // weird. no idea why it's here
byteBuffer.flip(); ((Buffer) byteBuffer).flip();
return byteBuffer.array(); return byteBuffer.array();
} }
} }

View File

@ -69,35 +69,44 @@ public class UlMaker implements Runnable{
safeShutdown(); safeShutdown();
} }
catch (Exception e){ catch (Exception e){
updater.setStatus(resourceBundle.getString("FailedText")+" "+e.getMessage());
e.printStackTrace(); e.printStackTrace();
if (! interrupted()) {
updater.setStatus(resourceBundle.getString("FailedText") + " " + e.getMessage());
return;
}
safeShutdown();
} }
finally { finally {
updater.close(); updater.close();
} }
} }
private void safeShutdown(){ private void safeShutdown() {
boolean isDeleted = true; updater.setStatus(resourceBundle.getString("PleaseWaitText"));
for (int i = 0; i < ulConfiguration.getChunksCount(); i++) { try{
File chunkFile = new File(String.format(locationPattern, i)); boolean isDeleted = true;
if (chunkFile.exists()) for (int i = 0; i < ulConfiguration.getChunksCount(); i++) {
isDeleted &= chunkFile.delete(); isDeleted &= Files.deleteIfExists(Paths.get(String.format(locationPattern, i)));
} }
if (isDeleted) if (isDeleted)
updater.setStatus(resourceBundle.getString("InterruptedAndFilesDeletedText")); updater.setStatus(resourceBundle.getString("InterruptedAndFilesDeletedText"));
else else
updater.setStatus(resourceBundle.getString("InterruptedAndFilesNotDeletedText")); updater.setStatus(resourceBundle.getString("InterruptedAndFilesNotDeletedText"));
}
catch (Exception e){
updater.setStatus(resourceBundle.getString("FailedText") + " " + e.getMessage());
e.printStackTrace();
}
} }
private void makeUlFile() throws Exception { private void makeUlFile() throws Exception {
byte[] config = ulConfiguration.generateUlConfig(); byte[] config = ulConfiguration.generateUlConfig();
RandomAccessFile raf = new RandomAccessFile(ulLocation+File.separator+"ul.cfg", "rw"); try (RandomAccessFile raf = new RandomAccessFile(ulLocation+File.separator+"ul.cfg", "rw")){
raf.seek(raf.length()); raf.seek(raf.length());
raf.write(config); raf.write(config);
raf.close(); }
} }
private void splitToChunks() throws Exception{ private void splitToChunks() throws Exception{
@ -109,28 +118,27 @@ public class UlMaker implements Runnable{
main_loop: main_loop:
for (int chunkNumber = 0; ; chunkNumber++){ for (int chunkNumber = 0; ; chunkNumber++){
String pathname = String.format(locationPattern, chunkNumber); String pathname = String.format(locationPattern, chunkNumber);
BufferedOutputStream fragmentBos = new BufferedOutputStream(Files.newOutputStream(Paths.get(pathname))); try (BufferedOutputStream fragmentBos = new BufferedOutputStream(Files.newOutputStream(Paths.get(pathname)))){
long counter = 0;
long counter = 0; while (counter < 256){
byte[] chunk = new byte[4194304];
while (counter < 256){ if ((readBytesCount = bis.read(chunk)) < 4194304){
byte[] chunk = new byte[4194304]; if (readBytesCount > 0)
fragmentBos.write(chunk, 0, readBytesCount);
fragmentBos.close();
updater.updateProgressBySize(readBytesCount);
break main_loop;
}
if (interrupted())
throw new InterruptedException();
if ((readBytesCount = bis.read(chunk)) < 4194304){ fragmentBos.write(chunk);
if (readBytesCount > 0) counter++;
fragmentBos.write(chunk, 0, readBytesCount);
fragmentBos.close();
updater.updateProgressBySize(readBytesCount); updater.updateProgressBySize(readBytesCount);
break main_loop;
} }
if (interrupted())
throw new InterruptedException();
fragmentBos.write(chunk);
counter++;
updater.updateProgressBySize(readBytesCount);
} }
fragmentBos.close();
} }
} }
} }

View File

@ -21,3 +21,4 @@ ISO_NotSupportedCdDvd=Not supported CD/DVD format
ISO_CantReadRootDescriptor=Can't read CD/DVD directory entry for the root directory ISO_CantReadRootDescriptor=Can't read CD/DVD directory entry for the root directory
ISO_NoSystemCnf=SYSTEM.CNF not found in this CD/DVD. Is it a PS2 Disk? ISO_NoSystemCnf=SYSTEM.CNF not found in this CD/DVD. Is it a PS2 Disk?
ISO_PublisherTitleNotFound=Title not found. SYSTEM.CNF file is next: ISO_PublisherTitleNotFound=Title not found. SYSTEM.CNF file is next:
PleaseWaitText=Please wait while useless file fragments removing...

View File

@ -21,3 +21,4 @@ ISO_NotSupportedCdDvd=\u041D\u0435\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u04
ISO_CantReadRootDescriptor=\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u043F\u0440\u043E\u0447\u0435\u0441\u0442\u044C \u0437\u0430\u043F\u0438\u0441\u044C \u043A\u043E\u0440\u043D\u0435\u0432\u043E\u0433\u043E \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 CD/DVD \u0434\u0438\u0441\u043A\u0430 ISO_CantReadRootDescriptor=\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u043F\u0440\u043E\u0447\u0435\u0441\u0442\u044C \u0437\u0430\u043F\u0438\u0441\u044C \u043A\u043E\u0440\u043D\u0435\u0432\u043E\u0433\u043E \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 CD/DVD \u0434\u0438\u0441\u043A\u0430
ISO_NoSystemCnf=\u041D\u0430 \u044D\u0442\u043E\u043C CD/DVD \u043D\u0435\u0442 \u0444\u0430\u0439\u043B\u0430 SYSTEM.CNF. \u042D\u0442\u043E \u0442\u043E\u0447\u043D\u043E \u0434\u0438\u0441\u043A \u0434\u043B\u044F PS2? ISO_NoSystemCnf=\u041D\u0430 \u044D\u0442\u043E\u043C CD/DVD \u043D\u0435\u0442 \u0444\u0430\u0439\u043B\u0430 SYSTEM.CNF. \u042D\u0442\u043E \u0442\u043E\u0447\u043D\u043E \u0434\u0438\u0441\u043A \u0434\u043B\u044F PS2?
ISO_PublisherTitleNotFound=\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E. SYSTEM.CNF \u0432\u044B\u0433\u043B\u044F\u0434\u0438\u0442 \u0442\u0430\u043A: ISO_PublisherTitleNotFound=\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E. SYSTEM.CNF \u0432\u044B\u0433\u043B\u044F\u0434\u0438\u0442 \u0442\u0430\u043A:
PleaseWaitText=\u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u043F\u043E\u0434\u043E\u0436\u0434\u0438\u0442\u0435 \u043F\u043E\u043A\u0430 \u0443\u0434\u0430\u043B\u044F\u044E\u0442\u0441\u044F \u043D\u0435\u043D\u0443\u0436\u043D\u044B\u0435 \u0444\u0440\u0430\u0433\u043C\u0435\u043D\u0442\u044B \u0444\u0430\u0439\u043B\u0430...