MCPcopy
hub / github.com/arduino/Arduino / isReadOnly

Method isReadOnly

app/src/processing/app/SketchController.java:794–805  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

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);

Callers 10

handleNewCodeMethod · 0.95
handleRenameCodeMethod · 0.95
handleDeleteCodeMethod · 0.95
saveMethod · 0.95
saveAsMethod · 0.95
handleAddFileMethod · 0.95
testMethod · 0.80
testMethod · 0.80
handleSave2Method · 0.80
handleExportMethod · 0.80

Calls 8

getExamplesPathMethod · 0.95
sketchIsSystemExampleMethod · 0.95
getInstalledLibrariesMethod · 0.80
onGoingDevelopmentMethod · 0.80
getFolderMethod · 0.65
getMethod · 0.65
getInstalledFolderMethod · 0.45

Tested by

no test coverage detected