mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
introducing template sketch with empty setup and loop functions. see #1138
This commit is contained in:
parent
ac66cf7ee2
commit
8e00662cb7
@ -652,7 +652,10 @@ public class Base {
|
||||
|
||||
// Make an empty pde file
|
||||
File newbieFile = new File(newbieDir, newbieName + ".ino");
|
||||
new FileOutputStream(newbieFile); // create the file
|
||||
if (!newbieFile.createNewFile()) {
|
||||
throw new IOException();
|
||||
}
|
||||
FileUtils.copyFile(new File(System.getProperty("user.dir"), "TemplateSketch.ino"), newbieFile);
|
||||
return newbieFile.getAbsolutePath();
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,27 @@ public class FileUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void copyFile(File source, File dest) throws IOException {
|
||||
FileInputStream fis = null;
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fis = new FileInputStream(source);
|
||||
fos = new FileOutputStream(dest);
|
||||
byte[] buf = new byte[4096];
|
||||
int readBytes = -1;
|
||||
while ((readBytes = fis.read(buf, 0, buf.length)) != -1) {
|
||||
fos.write(buf, 0, readBytes);
|
||||
}
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
fis.close();
|
||||
}
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void copy(File sourceFolder, File destFolder) throws IOException {
|
||||
for (File file : sourceFolder.listFiles()) {
|
||||
File destFile = new File(destFolder, file.getName());
|
||||
@ -44,24 +65,7 @@ public class FileUtils {
|
||||
}
|
||||
copy(file, destFile);
|
||||
} else {
|
||||
FileInputStream fis = null;
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fis = new FileInputStream(file);
|
||||
fos = new FileOutputStream(destFile);
|
||||
byte[] buf = new byte[4096];
|
||||
int readBytes = -1;
|
||||
while ((readBytes = fis.read(buf, 0, buf.length)) != -1) {
|
||||
fos.write(buf, 0, readBytes);
|
||||
}
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
fis.close();
|
||||
}
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
copyFile(file, destFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,9 @@
|
||||
<fileset dir="shared/examples" />
|
||||
</copy>
|
||||
|
||||
<!-- copy shared template -->
|
||||
<copy file="shared/TemplateSketch.ino" todir="${target.path}/" />
|
||||
|
||||
<!-- Unzip documentation -->
|
||||
<unzip dest="${target.path}" src="shared/reference.zip" overwrite="false"/>
|
||||
|
||||
|
9
build/shared/TemplateSketch.ino
Normal file
9
build/shared/TemplateSketch.ino
Normal file
@ -0,0 +1,9 @@
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user