Directory validation and creation

pull/53/head
Zlatin Balevsky 2020-05-29 01:51:13 +01:00
parent 8c4bafda82
commit c9c5e8617a
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 18 additions and 4 deletions

View File

@ -36,14 +36,28 @@ class DirectoriesStep extends WizardStep {
@Override
protected List<String> validate() {
// TODO Auto-generated method stub
return null
def rv = []
if (!canWrite(downloadLocationField.text))
rv << "Download location not writeable"
if (!canWrite(incompleteLocationField.text))
rv << "Incomplete location not writeable"
rv
}
private static boolean canWrite(String location) {
File f = new File(location)
if (f.exists())
return f.isDirectory() && f.canWrite()
canWrite(f.getParentFile().getAbsolutePath())
}
@Override
protected void apply(MuWireSettings muSettings, Properties i2pSettings) {
// TODO Auto-generated method stub
muSettings.downloadLocation = new File(downloadLocationField.text)
muSettings.incompleteLocation = new File(incompleteLocationField.text)
muSettings.downloadLocation.mkdirs()
muSettings.incompleteLocation.mkdirs()
}
def showDownloadChooser = {