Returns true if this is a read-only sketch. Used for the examples directory, or when sketches are loaded from read-only volumes or folders without appropriate permissions.
()
| 792 | * volumes or folders without appropriate permissions. |
| 793 | */ |
| 794 | public boolean isReadOnly() { |
| 795 | LibraryList libraries = BaseNoGui.librariesIndexer.getInstalledLibraries(); |
| 796 | String examplesPath = BaseNoGui.getExamplesPath(); |
| 797 | String apath = sketch.getFolder().getAbsolutePath(); |
| 798 | |
| 799 | Optional<UserLibrary> libraryThatIncludesSketch = libraries.stream().filter(lib -> apath.startsWith(lib.getInstalledFolder().getAbsolutePath())).findFirst(); |
| 800 | if (libraryThatIncludesSketch.isPresent() && !libraryThatIncludesSketch.get().onGoingDevelopment()) { |
| 801 | return true; |
| 802 | } |
| 803 | |
| 804 | return sketchIsSystemExample(apath, examplesPath) || sketchFilesAreReadOnly(); |
| 805 | } |
| 806 | |
| 807 | private boolean sketchIsSystemExample(String apath, String examplesPath) { |
| 808 | return apath.startsWith(examplesPath); |
no test coverage detected