@@ -75,7 +75,7 @@ public void handleNewCode() {
75
75
ensureExistence ();
76
76
77
77
// if read-only, give an error
78
- if (isReadOnly (BaseNoGui . librariesIndexer . getInstalledLibraries (), BaseNoGui . getExamplesPath () )) {
78
+ if (isReadOnly ()) {
79
79
// if the files are read-only, need to first do a "save as".
80
80
Base .showMessage (tr ("Sketch is Read-Only" ),
81
81
tr ("Some files are marked \" read-only\" , so you'll\n " +
@@ -107,7 +107,7 @@ public void handleRenameCode() {
107
107
}
108
108
109
109
// if read-only, give an error
110
- if (isReadOnly (BaseNoGui . librariesIndexer . getInstalledLibraries (), BaseNoGui . getExamplesPath () )) {
110
+ if (isReadOnly ()) {
111
111
// if the files are read-only, need to first do a "save as".
112
112
Base .showMessage (tr ("Sketch is Read-Only" ),
113
113
tr ("Some files are marked \" read-only\" , so you'll\n " +
@@ -225,7 +225,7 @@ public void handleDeleteCode() throws IOException {
225
225
ensureExistence ();
226
226
227
227
// if read-only, give an error
228
- if (isReadOnly (BaseNoGui . librariesIndexer . getInstalledLibraries (), BaseNoGui . getExamplesPath () )) {
228
+ if (isReadOnly ()) {
229
229
// if the files are read-only, need to first do a "save as".
230
230
Base .showMessage (tr ("Sketch is Read-Only" ),
231
231
tr ("Some files are marked \" read-only\" , so you'll\n " +
@@ -303,7 +303,7 @@ public boolean save() throws IOException {
303
303
// make sure the user didn't hide the sketch folder
304
304
ensureExistence ();
305
305
306
- if (isReadOnly (BaseNoGui . librariesIndexer . getInstalledLibraries (), BaseNoGui . getExamplesPath () )) {
306
+ if (isReadOnly ()) {
307
307
Base .showMessage (tr ("Sketch is read-only" ),
308
308
tr ("Some files are marked \" read-only\" , so you'll\n " +
309
309
"need to re-save this sketch to another location." ));
@@ -367,7 +367,7 @@ public boolean save() throws IOException {
367
367
protected boolean saveAs () throws IOException {
368
368
// get new name for folder
369
369
FileDialog fd = new FileDialog (editor , tr ("Save sketch folder as..." ), FileDialog .SAVE );
370
- if (isReadOnly (BaseNoGui . librariesIndexer . getInstalledLibraries (), BaseNoGui . getExamplesPath () ) || isUntitled ()) {
370
+ if (isReadOnly () || isUntitled ()) {
371
371
// default to the sketchbook folder
372
372
fd .setDirectory (BaseNoGui .getSketchbookFolder ().getAbsolutePath ());
373
373
} else {
@@ -456,7 +456,7 @@ public void handleAddFile() {
456
456
ensureExistence ();
457
457
458
458
// if read-only, give an error
459
- if (isReadOnly (BaseNoGui . librariesIndexer . getInstalledLibraries (), BaseNoGui . getExamplesPath () )) {
459
+ if (isReadOnly ()) {
460
460
// if the files are read-only, need to first do a "save as".
461
461
Base .showMessage (tr ("Sketch is Read-Only" ),
462
462
tr ("Some files are marked \" read-only\" , so you'll\n " +
@@ -791,7 +791,9 @@ private void ensureExistence() {
791
791
* examples directory, or when sketches are loaded from read-only
792
792
* volumes or folders without appropriate permissions.
793
793
*/
794
- public boolean isReadOnly (LibraryList libraries , String examplesPath ) {
794
+ public boolean isReadOnly () {
795
+ LibraryList libraries = BaseNoGui .librariesIndexer .getInstalledLibraries ();
796
+ String examplesPath = BaseNoGui .getExamplesPath ();
795
797
String apath = sketch .getFolder ().getAbsolutePath ();
796
798
797
799
Optional <UserLibrary > libraryThatIncludesSketch = libraries .stream ().filter (lib -> apath .startsWith (lib .getInstalledFolder ().getAbsolutePath ())).findFirst ();
0 commit comments