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

Method checkNewFoldername

arduino-core/src/processing/app/Sketch.java:242–257  ·  view source on GitHub ↗

Check if renaming/saving this sketch to the given folder would cause a problem because: 1. The new folder already exists 2. Renaming the primary file would cause a conflict with an existing file. If so, an IOEXception is thrown. If not, the name of the new primary file is returned.

(File newFolder)

Source from the content-addressed store, hash-verified

240 * primary file is returned.
241 */
242 protected File checkNewFoldername(File newFolder) throws IOException {
243 String newPrimary = FileUtils.addExtension(newFolder.getName(), DEFAULT_SKETCH_EXTENSION);
244 // Verify the new folder does not exist yet
245 if (newFolder.exists()) {
246 String msg = I18n.format(tr("Sorry, the folder \"{0}\" already exists."), newFolder.getAbsoluteFile());
247 throw new IOException(msg);
248 }
249
250 // If the folder is actually renamed (as opposed to moved somewhere
251 // else), check for conflicts using the new filename, but the
252 // existing folder name.
253 if (!newFolder.getName().equals(folder.getName()))
254 checkNewFilename(new File(folder, newPrimary));
255
256 return new File(newFolder, newPrimary);
257 }
258
259 /**
260 * Check if renaming or adding a file would cause a problem because

Callers 2

renameToMethod · 0.95
saveAsMethod · 0.95

Calls 7

addExtensionMethod · 0.95
formatMethod · 0.95
checkNewFilenameMethod · 0.95
trMethod · 0.80
getNameMethod · 0.65
existsMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected