Portable folder can now be set to any arbitrary path, not just subfolders

of "portable". Fixes #4103
This commit is contained in:
Federico Fissore 2015-11-19 13:43:49 +01:00
parent 907af81ff9
commit 1862827c25
4 changed files with 12 additions and 19 deletions

View File

@ -556,12 +556,6 @@ public class Preferences extends javax.swing.JDialog {
File file = Base.selectFolder(tr("Select new sketchbook location"), dflt, this);
if (file != null) {
String path = file.getAbsolutePath();
if (BaseNoGui.getPortableFolder() != null) {
path = FileUtils.relativePath(BaseNoGui.getPortableFolder().toString(), path);
if (path == null) {
path = BaseNoGui.getPortableSketchbookFolder();
}
}
sketchbookLocationField.setText(path);
}
}//GEN-LAST:event_browseButtonActionPerformed

View File

@ -523,7 +523,7 @@ public class Base {
if (path == null) {
continue;
}
if (BaseNoGui.getPortableFolder() != null) {
if (BaseNoGui.getPortableFolder() != null && !new File(path).isAbsolute()) {
File absolute = new File(BaseNoGui.getPortableFolder(), path);
try {
path = absolute.getCanonicalPath();
@ -570,12 +570,6 @@ public class Base {
if (path.startsWith(untitledPath) && !editor.getSketch().isModified()) {
continue;
}
if (BaseNoGui.getPortableFolder() != null) {
path = FileUtils.relativePath(BaseNoGui.getPortableFolder().toString(), path);
if (path == null) {
continue;
}
}
PreferencesData.set("last.sketch" + index + ".path", path);
int[] location = editor.getPlacement();

View File

@ -267,9 +267,11 @@ public class BaseNoGui {
}
static public File getSketchbookFolder() {
if (portableFolder != null)
return new File(portableFolder, PreferencesData.get("sketchbook.path"));
return absoluteFile(PreferencesData.get("sketchbook.path"));
String sketchBookPath = PreferencesData.get("sketchbook.path");
if (getPortableFolder() != null && !new File(sketchBookPath).isAbsolute()) {
return new File(getPortableFolder(), sketchBookPath);
}
return absoluteFile(sketchBookPath);
}
static public File getSketchbookHardwareFolder() {
@ -301,10 +303,11 @@ public class BaseNoGui {
// If it doesn't, warn the user that the sketchbook folder is being reset.
if (sketchbookPath != null) {
File sketchbookFolder;
if (getPortableFolder() != null)
if (getPortableFolder() != null && !new File(sketchbookPath).isAbsolute()) {
sketchbookFolder = new File(getPortableFolder(), sketchbookPath);
else
} else {
sketchbookFolder = absoluteFile(sketchbookPath);
}
if (!sketchbookFolder.exists()) {
showWarning(tr("Sketchbook folder disappeared"),
tr("The sketchbook folder no longer exists.\n" +
@ -658,8 +661,9 @@ public class BaseNoGui {
static public void initPortableFolder() {
// Portable folder
portableFolder = getContentFile("portable");
if (!portableFolder.exists())
if (!portableFolder.exists()) {
portableFolder = null;
}
}
static public void initVersion() {

View File

@ -5,6 +5,7 @@ ARDUINO 1.6.7
* Serial plotter now allows to plot multiple values at once. Thanks @henningpohl
* New translations
* Added support to file:// protocol for boards manager URLs
* Portable sketchbook folder can now be any arbitrary location
[libraries]
* SPI: Added SPI.transfer16(...) function to SAM core.