Skip to content

Commit 22d1066

Browse files
author
jan
committed
When converting to sloeber project cope with "wrong" locations
The SLOEBER_HOME folder may have moved. As Sloeber V4 does not do a great job at identifying SLOEBER_HOMEit is likely (and it was durting tests) that the boards.txt points to a valid boards.txt (valid in the sense of: valid path on the original computer and valid if it had been stored with ${SLOEBER_HOME} Therefore I added code searching for the ArduinoPlugin folder and go from there.
1 parent de79fcf commit 22d1066

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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

+18-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.eclipse.core.runtime.IPath;
3131
import org.eclipse.core.runtime.IProgressMonitor;
3232
import org.eclipse.core.runtime.IStatus;
33+
import org.eclipse.core.runtime.Path;
3334
import org.eclipse.core.runtime.Status;
3435
import org.eclipse.core.runtime.SubMonitor;
3536

@@ -267,14 +268,30 @@ private static BoardDescription getBoardDescription(KeyValueTree oldConfig) {
267268
if(boardsFileString.isBlank() || boardID.isBlank()) {
268269
return new BoardDescription();
269270
}
271+
Path readBoardsFilePath=new Path(boardsFileString);
272+
IPath foundBoardsFilePath=null;
273+
String[] segments =readBoardsFilePath.segments();
274+
for(String curSegment:segments) {
275+
276+
if(foundBoardsFilePath!=null) {
277+
foundBoardsFilePath=foundBoardsFilePath.append(curSegment);
278+
}else {
279+
if(SLOEBER_HOME_SUB_FOLDER.equals( curSegment)) {
280+
foundBoardsFilePath=new Path(sloeberHome).append(curSegment);
281+
}
282+
}
283+
}
284+
if (foundBoardsFilePath == null) {
285+
return new BoardDescription();
286+
}
270287

271288
KeyValueTree optionsHolder=oldConfig.getChild("board.BOARD.MENU"); //$NON-NLS-1$
272289

273290
Map<String, String> options=new HashMap<>();
274291
for(KeyValueTree curOption:optionsHolder.getChildren().values()) {
275292
options.put(curOption.getKey(), curOption.getValue());
276293
}
277-
File boardsFile=new File(boardsFileString);
294+
File boardsFile=foundBoardsFilePath.toFile();// new File(boardsFileString);
278295

279296
BoardDescription ret= new BoardDescription( boardsFile, boardID, options);
280297
String uploadPort=oldConfig.getValue("board.UPLOAD.PORT"); //$NON-NLS-1$

0 commit comments

Comments
 (0)