mirror of
https://github.com/developersu/ns-usbloader.git
synced 2025-05-13 22:54:49 -04:00
Cosmetic naming update; removing useless comments.
This commit is contained in:
parent
5838fe3b89
commit
3bfc37a24e
8 changed files with 39 additions and 31 deletions
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
Copyright 2019-2020 Dmitry Isaenko
|
||||
|
||||
This file is part of NS-USBloader.
|
||||
|
||||
NS-USBloader is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
NS-USBloader is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with NS-USBloader. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package nsusbloader.cli;
|
||||
|
||||
import nsusbloader.COM.USB.UsbCommunications;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TinfoilUsb {
|
||||
|
||||
private final String[] arguments;
|
||||
private List<File> filesList;
|
||||
|
||||
public TinfoilUsb(String[] arguments) throws InterruptedException, IncorrectSetupException{
|
||||
this.arguments = arguments;
|
||||
checkArguments();
|
||||
parseFilesArguments();
|
||||
runTinfoilBackend();
|
||||
}
|
||||
|
||||
private void checkArguments() throws IncorrectSetupException{
|
||||
if (arguments == null || arguments.length == 0) {
|
||||
throw new IncorrectSetupException("No files?\n" +
|
||||
"Try 'ns-usbloader -h' for more information.");
|
||||
}
|
||||
}
|
||||
|
||||
private void parseFilesArguments() throws IncorrectSetupException{
|
||||
filesList = new ArrayList<>();
|
||||
File file;
|
||||
|
||||
for (String arg : arguments) {
|
||||
file = new File(arg);
|
||||
if (file.exists())
|
||||
filesList.add(file);
|
||||
}
|
||||
|
||||
if (filesList.size() == 0) {
|
||||
throw new IncorrectSetupException("File(s) doesn't exist.\n" +
|
||||
"Try 'ns-usbloader -n help' for more information.");
|
||||
}
|
||||
}
|
||||
|
||||
private void runTinfoilBackend() throws InterruptedException{
|
||||
Runnable task = new UsbCommunications(filesList, "TinFoil", false);
|
||||
Thread thread = new Thread(task);
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue