()
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public void run() { |
| 90 | String path = console.getNavigator().getCurrentDirectory(); |
| 91 | Document doc = ExitParser.getDocFromZip(console.getNavigator().getSystem()); |
| 92 | NodeList dataList = doc.getElementsByTagName("info"); |
| 93 | if (body.trim().equals("~")) { |
| 94 | body = console.getNavigator().getHome().get(1); |
| 95 | } else if (body.trim().equals("..")) { |
| 96 | if (path.length() > 1) { |
| 97 | if (path.contains("/")) { |
| 98 | int lastIndexOf = path.lastIndexOf("/"); |
| 99 | String substring1 = path.substring(0, lastIndexOf); |
| 100 | String substring2 = path.substring(lastIndexOf+1, path.length()); |
| 101 | if (substring1.trim().equals("")) { |
| 102 | body = ExitParser.getAttributeValue(dataList, "top", "dir"); |
| 103 | } else { |
| 104 | body = substring1; |
| 105 | } |
| 106 | } else { |
| 107 | Console.printText(termArea, "cd: error"); |
| 108 | } |
| 109 | } else { |
| 110 | Console.printText(termArea, "cd: cannot move higher"); |
| 111 | return; |
| 112 | } |
| 113 | } |
| 114 | if (!body.trim().equals("/")) { |
| 115 | if (body.trim().endsWith("/")) { |
| 116 | StringBuilder builder = new StringBuilder(body); |
| 117 | builder.replace(body.lastIndexOf(","), body.lastIndexOf(",") + 1, ")" ); |
| 118 | body = builder.toString(); |
| 119 | } |
| 120 | } |
| 121 | if (!path.equals(body.trim())) { |
| 122 | if (!body.trim().startsWith(ExitParser.getAttributeValue(dataList, "top", "dir"))) { |
| 123 | String path2 = path; |
| 124 | if (!path2.startsWith(ExitParser.getAttributeValue(dataList, "top", "dir"))) { |
| 125 | path2 = ExitParser.getAttributeValue(dataList, "top", "dir") + path2; |
| 126 | } |
| 127 | if (!path2.endsWith("/")) { |
| 128 | path2 = path2 + "/"; |
| 129 | } |
| 130 | if (console.getNavigator().checkDirectory(path2 + body.trim())) { |
| 131 | console.getNavigator().setDirectory(path2 + body.trim()); |
| 132 | } else { |
| 133 | Console.printText(termArea, String.format("cd: \"%s\" is not a valid location/path", body)); |
| 134 | } |
| 135 | } else if (console.getNavigator().checkDirectory(body.trim())) { |
| 136 | console.getNavigator().setDirectory(body.trim()); |
| 137 | } else { |
| 138 | Console.printText(termArea, String.format("cd: \"%s\" is not a valid location/path", body)); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | } |
| 143 | |
| 144 | } |
| 145 |
nothing calls this directly
no test coverage detected