Request: File::reName()

bool rename (const String& newName)

File::moveFileTo() also can rename a file/dir, but it’s a little bit inconvenient…


But this would be exactly the same as moveFileTo… What’s so inconvenient?

  1. Semantic ambiguity. moveFileTo() more likes the ‘cut, paste, then rename’ operates in nature.
  2. Different object(s). moveFileTo() involves 2 file objects while rename() is one. What we need just a new name (a string).
  3. Certainty and uncertainty. Especially when spanned volume operate of moveFileto() happened on Windows (refer to the comments of this method). rename() will nothing about that.
  4. For the integrality of the File class.


I don’t agree that this would be a good addition - I think two methods that do the same thing would be confusing. But remember you don’t always need us to update the library in order to get the function you need, e.g. this is a one-liner for you to write yourself:

bool renameFile (const File& f, const String& newName)  { return f.moveFileTo (f.getSiblingFile (newName); }