From 75ad35f786fcc5ca0d0654217b93db4126ccb084 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 2 May 2012 16:37:00 +0100 Subject: [PATCH] Improved File::moveFileTo and made file renaming in the introjucer more robust. --- extras/Introjucer/Source/Project/jucer_Project.cpp | 3 ++- modules/juce_core/files/juce_File.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/extras/Introjucer/Source/Project/jucer_Project.cpp b/extras/Introjucer/Source/Project/jucer_Project.cpp index 6bcb6bc830..69c4d6ad56 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.cpp +++ b/extras/Introjucer/Source/Project/jucer_Project.cpp @@ -542,7 +542,8 @@ bool Project::Item::renameFile (const File& newFile) { const File oldFile (getFile()); - if (oldFile.moveFileTo (newFile)) + if (oldFile.moveFileTo (newFile) + || (newFile.exists() && ! oldFile.exists())) { setFile (newFile); OpenDocumentManager::getInstance()->fileHasBeenRenamed (oldFile, newFile); diff --git a/modules/juce_core/files/juce_File.cpp b/modules/juce_core/files/juce_File.cpp index 33da2531aa..f61d5aeff6 100644 --- a/modules/juce_core/files/juce_File.cpp +++ b/modules/juce_core/files/juce_File.cpp @@ -229,6 +229,9 @@ bool File::moveFileTo (const File& newFile) const if (newFile.fullPath == fullPath) return true; + if (! exists()) + return false; + #if ! NAMES_ARE_CASE_SENSITIVE if (*this != newFile) #endif