File tree 3 files changed +22
-26
lines changed
arduino-core/src/processing/app 3 files changed +22
-26
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ protected void nameCode(String newName) {
186
186
} else {
187
187
// Non-primary file, rename just that file
188
188
try {
189
- sketch . renameFileTo ( current , newName );
189
+ current . renameTo ( newName );
190
190
} catch (IOException e ) {
191
191
// This does not pass on e, to prevent showing a backtrace for
192
192
// "normal" errors.
@@ -348,7 +348,7 @@ public boolean save() throws IOException {
348
348
// Do rename of all .pde files to new .ino extension
349
349
for (SketchFile file : oldFiles ) {
350
350
File newName = FileUtils .replaceExtension (file .getFile (), Sketch .DEFAULT_SKETCH_EXTENSION );
351
- file .renameTo (newName );
351
+ file .renameTo (newName . getName () );
352
352
}
353
353
}
354
354
}
Original file line number Diff line number Diff line change @@ -277,27 +277,9 @@ public void renameTo(File newFolder) throws IOException {
277
277
file .renamedTo (new File (newFolder , file .getFileName ()));
278
278
279
279
// And finally, rename the primary file
280
- if (!getPrimaryFile ().renameTo (newPrimary ))
281
- throw new IOException (tr ("Failed to rename primary sketch file" ));
280
+ getPrimaryFile ().renameTo (newPrimary .getName ());
282
281
}
283
282
284
- /**
285
- * Rename the given file to get the given name.
286
- *
287
- * @param sketchfile
288
- * The SketchFile to be renamed.
289
- * @param newName
290
- * The new name, including extension, excluding directory
291
- * name.
292
- * @throws IOException
293
- * When a problem occurs, or is expected to occur. The error
294
- * message should be already translated.
295
- */
296
- public void renameFileTo (SketchFile sketchfile , String newName ) throws IOException {
297
- File newFile = new File (folder , newName );
298
- checkNewFilename (newFile );
299
- sketchfile .renameTo (newFile );
300
- }
301
283
302
284
public SketchFile addFile (String newName ) throws IOException {
303
285
// Check the name will not cause any conflicts
Original file line number Diff line number Diff line change @@ -160,11 +160,25 @@ private boolean deleteCompiledFilesFrom(Path tempBuildFolder) throws IOException
160
160
return true ;
161
161
}
162
162
163
- protected boolean renameTo (File what ) {
164
- boolean success = file .renameTo (what );
165
- if (success )
166
- renamedTo (what );
167
- return success ;
163
+ /**
164
+ * Rename the given file to get the given name.
165
+ *
166
+ * @param newName
167
+ * The new name, including extension, excluding directory
168
+ * name.
169
+ * @throws IOException
170
+ * When a problem occurs, or is expected to occur. The error
171
+ * message should be already translated.
172
+ */
173
+ public void renameTo (String newName ) throws IOException {
174
+ File newFile = new File (file .getParentFile (), newName );
175
+ sketch .checkNewFilename (newFile );
176
+ if (file .renameTo (newFile )) {
177
+ renamedTo (newFile );
178
+ } else {
179
+ String msg = I18n .format (tr ("Failed to rename \" {0}\" to \" {1}\" " ), file .getName (), newName );
180
+ throw new IOException (msg );
181
+ }
168
182
}
169
183
170
184
/**
You can’t perform that action at this time.
0 commit comments