Sasquatch wrote:I described these steps in case the user wasn't too sure if it would work properly. I'm sure it will.
I can fully understand anyones reluctance to do something so obviously crazy as to write to the same file you are reading from.
In fact I was busy writing code to detect this case and give the traditional error message, but then I thought... instead of the error, why not just find a way to do what the user wants?!
Obviously, given the apparant danger, the feature has been thoroughly tested.
For future reference: when you do this it writes the clone to a temp file first. If the cloning process is completed without errors then it renames the original file to "Original <name>", then renames the temp file to <name>. If the cloning process fails then the temp file is deleted and the original is left in the folder untouched. The only thing that can trip me up is if "Original <name>" already existed, meaning I can't do the first rename. In that case you will get an error message, but the clone will be left in the folder with its temp name. You then have to sort out the filenames yourself manually, but the clone itself is good.