Skip to content

Commit aaafc15

Browse files
author
jantje
committed
Support for empty template folders
Added a extra null test
1 parent ce773cc commit aaafc15

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

io.sloeber.core/src/io/sloeber/core/api/CodeDescriptor.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
import org.eclipse.core.runtime.CoreException;
1111
import org.eclipse.core.runtime.IPath;
1212
import org.eclipse.core.runtime.IProgressMonitor;
13+
import org.eclipse.core.runtime.IStatus;
1314
import org.eclipse.core.runtime.Path;
15+
import org.eclipse.core.runtime.Status;
1416

17+
import io.sloeber.common.Common;
1518
import io.sloeber.common.Const;
1619
import io.sloeber.common.InstancePreferences;
1720
import io.sloeber.core.tools.Helpers;
@@ -122,12 +125,17 @@ public void createFiles(IProject project, IProgressMonitor monitor) throws CoreE
122125
case CustomTemplate:
123126
IPath folderName = this.myTemPlateFoldername;
124127
String files[] = folderName.toFile().list();
125-
for (String file : files) {
126-
if (!(file.equals(".") || file.equals(".."))) {
127-
File sourceFile = folderName.append(file).toFile();
128-
Helpers.addFileToProject(project, new Path(file),
129-
Stream.openContentStream(project.getName(), Include, sourceFile.toString(), true), monitor,
130-
false);
128+
if (files == null) {
129+
Common.log(new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID,
130+
"No files found in template folder :" + folderName, null));
131+
} else {
132+
for (String file : files) {
133+
if (!(file.equals(".") || file.equals(".."))) {
134+
File sourceFile = folderName.append(file).toFile();
135+
Helpers.addFileToProject(project, new Path(file),
136+
Stream.openContentStream(project.getName(), Include, sourceFile.toString(), true),
137+
monitor, false);
138+
}
131139
}
132140
}
133141

0 commit comments

Comments
 (0)