Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added getSuffix method

This method will prevent errors being thrown if the file has no suffix
when running the method scanAndDeleteOldFiles.  This is especially
apparent on Linux.
  • Loading branch information...
commit 0fe08aabd8b1c322fb2a34e36b9aafb12eee064d 1 parent 85974ea
@Sammidysam authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/gamepatcher/Downloader.java
View
7 src/gamepatcher/Downloader.java
@@ -47,8 +47,8 @@ public void constructor(String fileName, String dateName, String fileSite, Strin
datePath = System.getProperty("user.dir") + File.separatorChar + dateName;
this.fileSite = fileSite;
this.dateSite = dateSite;
- scanAndDeleteOldFiles("tempDate", datePath.substring(datePath.lastIndexOf('.'), datePath.length()));
- scanAndDeleteOldFiles("tempFile", filePath.substring(filePath.lastIndexOf('.'), filePath.length()));
+ scanAndDeleteOldFiles("tempDate", getSuffix(datePath));
+ scanAndDeleteOldFiles("tempFile", getSuffix(filePath));
}
public boolean isUpdateNecessary(){
if(new File(filePath).exists() && new File(datePath).exists()){
@@ -129,6 +129,9 @@ private Calendar fileToCalendar(String path){
calendar.set(values[0], values[1] - 1, values[2], values[3], values[4], values[5]);
return calendar;
}
+ private String getSuffix(String fileName){
+ return fileName.contains(".") ? fileName.substring(fileName.lastIndexOf('.'), fileName.length()) : "";
+ }
private void scanAndDeleteOldFiles(String name, String suffix){
// if the download is aborted, a temporary file will be left behind. this method deletes all temporary files left behind in the past
DirectoryStream<Path> ds = null;
Please sign in to comment.
Something went wrong with that request. Please try again.