Skip to content

Commit 4e657ba

Browse files
committed
Automatically create sketchbook libraries/ folder and readme (Paul Stoffregen and Limor Fried).
http://code.google.com/p/arduino/issues/detail?id=986
1 parent 9d21154 commit 4e657ba

File tree

1 file changed

+76
-1
lines changed

1 file changed

+76
-1
lines changed

app/src/processing/app/Base.java

+76-1
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,82 @@ static public File getSketchbookFolder() {
15681568

15691569

15701570
static public File getSketchbookLibrariesFolder() {
1571-
return new File(getSketchbookFolder(), "libraries");
1571+
File libdir = new File(getSketchbookFolder(), "libraries");
1572+
if (!libdir.exists()) {
1573+
try {
1574+
libdir.mkdirs();
1575+
File readme = new File(libdir, "readme.txt");
1576+
FileWriter freadme = new FileWriter(readme);
1577+
freadme.write(_(
1578+
"Installing Additional Arduino Libraries\n" +
1579+
"----------------------------------------\n" +
1580+
"Once you are comfortable with the Arduino software and using the\n" +
1581+
"built-in functions, you may want to extend the ability of your Arduino\n" +
1582+
"with additional libraries.\n" +
1583+
"\n" +
1584+
"What are Libraries?\n" +
1585+
"----------------------------------------\n" +
1586+
"Libraries are a collection of code that makes it easy for you to connect \n" +
1587+
"to a sensor, display, module, etc. For example, the built-in \n" +
1588+
"LiquidCrystal library makes it easy to talk to character LCD displays. \n" +
1589+
"There are hundreds of additional libraries available on the Internet for \n" +
1590+
"download. The built-in libraries and some of these additional libraries\n" +
1591+
"are listed here: http://arduino.cc/en/Reference/Libraries. To use the\n" +
1592+
"additional libraries, you will need to install them.\n" +
1593+
"\n" +
1594+
"How to Install a Library\n" +
1595+
"----------------------------------------\n" +
1596+
"Libraries are often distributed as a ZIP file or folder. The name of the \n" +
1597+
"folder is the name of the library. Inside the folder will be a .cpp \n" +
1598+
"file, a .h file and often a keywords.txt file, examples folder, and other\n" +
1599+
"files required by the library.\n" +
1600+
"\n" +
1601+
"To install the library, first quit the Arduino application.\n" +
1602+
"\n" +
1603+
"Then uncompress the ZIP file containing the library. For example, if\n" +
1604+
"you're installing a library called \"ArduinoParty\", uncompress\n" +
1605+
"ArduinoParty.zip. It should contain a folder called ArduinoParty, with\n" +
1606+
"files like ArduinoParty.cpp and ArduinoParty.h inside. (If the .cpp and\n" +
1607+
".h files aren't in a folder, you'll need to create one. In this case,\n" +
1608+
"you'd make a folder called \"ArduinoParty\" and move into it all the files\n" +
1609+
"that were in the ZIP file, like ArduinoParty.cpp and ArduinoParty.h.) \n" +
1610+
"\n" +
1611+
"Drag the ArduinoParty folder into this folder (your libraries folder).\n" +
1612+
"Under Windows, it will likely be called \"My Documents\\Arduino\\libraries\".\n" +
1613+
"For Mac users, it will likely be called \"Documents/Arduino/libraries\".\n" +
1614+
"On Linux, it will be the \"libraries\" folder in your sketchbook.\n" +
1615+
"\n" +
1616+
"Your Arduino library folder should now look like this (on Windows):\n" +
1617+
" My Documents\\Arduino\\libraries\\ArduinoParty\\ArduinoParty.cpp\n" +
1618+
" My Documents\\Arduino\\libraries\\ArduinoParty\\ArduinoParty.h\n" +
1619+
" My Documents\\Arduino\\libraries\\ArduinoParty\\examples\n" +
1620+
" ....\n" +
1621+
"or like this (on Mac):\n" +
1622+
" Documents/Arduino/libraries/ArduinoParty/ArduinoParty.cpp\n" +
1623+
" Documents/Arduino/libraries/ArduinoParty/ArduinoParty.h\n" +
1624+
" Documents/Arduino/libraries/ArduinoParty/examples\n" +
1625+
" ...\n" +
1626+
"or similarly for Linux.\n" +
1627+
"\n" +
1628+
"There may be more files than just the .cpp and .h files, just make sure \n" +
1629+
"they're all there.\n" +
1630+
"\n" +
1631+
"(The library won't work if you put the .cpp and .h files directly into\n" +
1632+
"the libraries folder or if they're nested in an extra folder. For \n" +
1633+
"example:\n" +
1634+
" Documents\\Arduino\\libraries\\ArduinoParty.cpp and\n" +
1635+
" Documents\\Arduino\\libraries\\ArduinoParty\\ArduinoParty\\ArduinoParty.cpp\n" +
1636+
"won't work.)\n" +
1637+
"\n" +
1638+
"Restart the Arduino application. Make sure the new library appears in the \n" +
1639+
"Sketch->Import Library menu item of the software.\n" +
1640+
"\n" +
1641+
"That's it! You've installed a library!\n"));
1642+
freadme.close();
1643+
} catch (Exception e) {
1644+
}
1645+
}
1646+
return libdir;
15721647
}
15731648

15741649

0 commit comments

Comments
 (0)