(String name)
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public void setName(String name) { |
| 104 | FileType t = FileType.UNKNOWN; |
| 105 | int offset = 0; |
| 106 | String prodosName = name; |
| 107 | if (name.matches("^.*?#[0-9A-Fa-f]{6}$")) { |
| 108 | int type = Integer.parseInt(name.substring(name.length() - 6, name.length() - 4), 16); |
| 109 | offset = Integer.parseInt(name.substring(name.length() - 4), 16); |
| 110 | t = FileType.findByCode(type); |
| 111 | prodosName = name.substring(0, name.length()-7).replaceAll("[^A-Za-z0-9#]", ".").toUpperCase(); |
| 112 | } else { |
| 113 | String[] parts = name.replaceAll("[^A-Za-z0-9#]", ".").split("\\."); |
| 114 | if (parts.length > 1) { |
| 115 | String extension = parts[parts.length - 1].toUpperCase(); |
| 116 | String[] extParts = extension.split("\\#"); |
| 117 | if (extParts.length == 2) { |
| 118 | offset = Integer.parseInt(extParts[1], 16); |
| 119 | extension = extParts[0]; |
| 120 | } |
| 121 | try { |
| 122 | t = FileType.valueOf(extension); |
| 123 | } catch (IllegalArgumentException ex) { |
| 124 | System.out.println("Not sure what extension " + extension + " is!"); |
| 125 | } |
| 126 | prodosName = ""; |
| 127 | for (int i = 0; i < parts.length - 1; i++) { |
| 128 | prodosName += (i > 0 ? "." + parts[i] : parts[i]); |
| 129 | } |
| 130 | if (extParts[extParts.length - 1].equals("SYSTEM")) { |
| 131 | prodosName += ".SYSTEM"; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | if (offset == 0) { |
| 136 | offset = t.defaultLoadAddress; |
| 137 | } |
| 138 | fileType = t.code; |
| 139 | loadAddress = offset; |
| 140 | |
| 141 | // Pass usable name (stripped of file extension and other type info) as name |
| 142 | super.setName(prodosName); |
| 143 | } |
| 144 | |
| 145 | public FileNode(ProdosVirtualDisk ownerFilesystem, File file) throws IOException { |
| 146 | super(ownerFilesystem); |
no test coverage detected