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.
()
| 1639 | * volumes or folders without appropriate permissions. |
| 1640 | */ |
| 1641 | public boolean isReadOnly() { |
| 1642 | String path = folder.getAbsolutePath(); |
| 1643 | List<Mode> modes = editor.getBase().getModeList(); |
| 1644 | // Make sure it's not read-only for another Mode besides this one |
| 1645 | // https://github.com/processing/processing/issues/773 |
| 1646 | for (Mode mode : modes) { |
| 1647 | if (path.startsWith(mode.getExamplesFolder().getAbsolutePath()) || |
| 1648 | path.startsWith(mode.getLibrariesFolder().getAbsolutePath())) { |
| 1649 | return true; |
| 1650 | } |
| 1651 | } |
| 1652 | |
| 1653 | // Check to see if each modified code file can be written. |
| 1654 | // Note: canWrite() does not work on directories. |
| 1655 | for (int i = 0; i < codeCount; i++) { |
| 1656 | if (code[i].isModified() && |
| 1657 | code[i].fileReadOnly() && |
| 1658 | code[i].fileExists()) { |
| 1659 | return true; |
| 1660 | } |
| 1661 | } |
| 1662 | |
| 1663 | return false; |
| 1664 | } |
| 1665 | |
| 1666 | |
| 1667 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
no test coverage detected