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.
()
| 1548 | * volumes or folders without appropriate permissions. |
| 1549 | */ |
| 1550 | public boolean isReadOnly() { |
| 1551 | String apath = folder.getAbsolutePath(); |
| 1552 | List<Mode> modes = editor.getBase().getModeList(); |
| 1553 | // Make sure it's not read-only for another Mode besides this one |
| 1554 | // https://github.com/processing/processing/issues/773 |
| 1555 | for (Mode mode : modes) { |
| 1556 | if (apath.startsWith(mode.getExamplesFolder().getAbsolutePath()) || |
| 1557 | apath.startsWith(mode.getLibrariesFolder().getAbsolutePath())) { |
| 1558 | return true; |
| 1559 | } |
| 1560 | } |
| 1561 | |
| 1562 | // check to see if each modified code file can be written to |
| 1563 | // canWrite() doesn't work on directories |
| 1564 | for (int i = 0; i < codeCount; i++) { |
| 1565 | if (code[i].isModified() && |
| 1566 | code[i].fileReadOnly() && |
| 1567 | code[i].fileExists()) { |
| 1568 | //System.err.println("found a read-only file " + code[i].file); |
| 1569 | return true; |
| 1570 | } |
| 1571 | } |
| 1572 | |
| 1573 | return false; |
| 1574 | } |
| 1575 | |
| 1576 | |
| 1577 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
no test coverage detected