1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-01 23:29:28 +01:00

introducing template sketch with empty setup and loop functions. see #1138

This commit is contained in:
Federico Fissore 2012-12-17 11:25:45 +01:00
parent ac66cf7ee2
commit 8e00662cb7
4 changed files with 38 additions and 19 deletions

View File

@ -652,7 +652,10 @@ public class Base {
// Make an empty pde file // Make an empty pde file
File newbieFile = new File(newbieDir, newbieName + ".ino"); 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(); return newbieFile.getAbsolutePath();
} }

View File

@ -35,20 +35,12 @@ public class FileUtils {
return false; return false;
} }
public static void copy(File sourceFolder, File destFolder) throws IOException { public static void copyFile(File source, File dest) throws IOException {
for (File file : sourceFolder.listFiles()) {
File destFile = new File(destFolder, file.getName());
if (file.isDirectory()) {
if (!destFile.mkdir()) {
throw new IOException("Unable to create folder: " + destFile);
}
copy(file, destFile);
} else {
FileInputStream fis = null; FileInputStream fis = null;
FileOutputStream fos = null; FileOutputStream fos = null;
try { try {
fis = new FileInputStream(file); fis = new FileInputStream(source);
fos = new FileOutputStream(destFile); fos = new FileOutputStream(dest);
byte[] buf = new byte[4096]; byte[] buf = new byte[4096];
int readBytes = -1; int readBytes = -1;
while ((readBytes = fis.read(buf, 0, buf.length)) != -1) { while ((readBytes = fis.read(buf, 0, buf.length)) != -1) {
@ -63,6 +55,18 @@ public class FileUtils {
} }
} }
} }
public static void copy(File sourceFolder, File destFolder) throws IOException {
for (File file : sourceFolder.listFiles()) {
File destFile = new File(destFolder, file.getName());
if (file.isDirectory()) {
if (!destFile.mkdir()) {
throw new IOException("Unable to create folder: " + destFile);
}
copy(file, destFile);
} else {
copyFile(file, destFile);
}
} }
} }

View File

@ -97,6 +97,9 @@
<fileset dir="shared/examples" /> <fileset dir="shared/examples" />
</copy> </copy>
<!-- copy shared template -->
<copy file="shared/TemplateSketch.ino" todir="${target.path}/" />
<!-- Unzip documentation --> <!-- Unzip documentation -->
<unzip dest="${target.path}" src="shared/reference.zip" overwrite="false"/> <unzip dest="${target.path}" src="shared/reference.zip" overwrite="false"/>

View 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:
}