Renaming and moving a file from a plugin

Hi,

I'd like to rename and move a file inside a plugin I'm developing. I was thinking of using the methods available on the VirtualFile ap instead of refactoring. Renaming a file is pretty straight forward, but moving seems kind of complicated. I have a path and a file name, and the new path may not yet exist. Do I have to write code to check to see if all the intermediate directories exist before moving? I was thinking of using FilenameIndex.getFilesByName to test to see if a directory exists, if not move up until I get one that does and then create the missing intermediate directories, and then once I have the final directory I need to move to, use the move method on VirtualFile. Is that the way to do it? Would be nice if one could just give a full path to rename and it both moved the file and renamed it and created any missing intermediate directories. I don't think that exists though.

---
Original message URL: http://devnet.jetbrains.net/message/5507047#5507047

Please sign in to leave a comment.