MCPcopy
hub / github.com/arduino/Arduino / renameTo

Method renameTo

arduino-core/src/processing/app/SketchFile.java:177–186  ·  view source on GitHub ↗

Rename the given file to get the given name. @param newName The new name, including extension, excluding directory name. @throws IOException When a problem occurs, or is expected to occur. The error message should be already translated.

(String newName)

Source from the content-addressed store, hash-verified

175 * message should be already translated.
176 */
177 public void renameTo(String newName) throws IOException {
178 File newFile = new File(file.getParentFile(), newName);
179 sketch.checkNewFilename(newFile);
180 if (!file.exists() || file.renameTo(newFile)) {
181 renamedTo(newFile);
182 } else {
183 String msg = I18n.format(tr("Failed to rename \"{0}\" to \"{1}\""), file.getName(), newName);
184 throw new IOException(msg);
185 }
186 }
187
188 /**
189 * Should be called when this file was renamed and renameTo could not

Callers 1

nameCodeMethod · 0.95

Calls 6

renamedToMethod · 0.95
formatMethod · 0.95
checkNewFilenameMethod · 0.80
trMethod · 0.80
getNameMethod · 0.65
existsMethod · 0.45

Tested by

no test coverage detected