try{
input_file = new File( getImportFile()).getCanonicalFile();
}catch( IOException e ){
MessageBox mb = new MessageBox(getWizardWindow(),SWT.ICON_ERROR | SWT.OK );
mb.setText(MessageText.getString("importTorrentWizard.process.inputfilebad.title"));
mb.setMessage( MessageText.getString("importTorrentWizard.process.inputfilebad.message")+"\n" +
e.toString());
mb.open();
return( false );
}
File output_file = new File( getTorrentFile() );
if ( output_file.exists()){
MessageBox mb = new MessageBox(this.getWizardWindow(),SWT.ICON_QUESTION | SWT.YES | SWT.NO);
mb.setText(MessageText.getString("importTorrentWizard.process.outputfileexists.title"));
mb.setMessage(MessageText.getString("importTorrentWizard.process.outputfileexists.message"));
int result = mb.open();
if(result == SWT.NO) {
return( false );
}
}
String error_title;
String error_detail;
try{
TOTorrent torrent;
try{
torrent = TOTorrentFactory.deserialiseFromXMLFile( input_file );
try{
torrent.serialiseToBEncodedFile( output_file );
return( true );
}catch( TOTorrentException e ){
//e.printStackTrace();
error_title = MessageText.getString("importTorrentWizard.process.torrentfail.title");
error_detail = TorrentUtils.exceptionToText( e );
}
}catch( TOTorrentException e ){
// e.printStackTrace();
error_title = MessageText.getString("importTorrentWizard.process.importfail.title");
error_detail = TorrentUtils.exceptionToText( e );
}
}catch( Throwable e ){
error_title = MessageText.getString("importTorrentWizard.process.unknownfail.title");
Debug.printStackTrace( e );
error_detail = e.toString();
}
MessageBox mb = new MessageBox(this.getWizardWindow(),SWT.ICON_ERROR | SWT.OK );
mb.setText(error_title);
mb.setMessage(error_detail);
mb.open();
return( false );
}