User forums > Help
Rename file functionality
skirby:
Hi rickg22,
I know this way (hopefully for me) :P
But, do you think it could be integrated into C::B?
It works with Visual C++ Express IDE so I am sure it could be done into C::B.
Do you want me to add a feature request on BerliOS?
rickg22:
Yes, please.
Biplab:
--- Quote from: skirby on July 04, 2007, 03:48:52 pm ---Do you want me to add a feature request on BerliOS?
--- End quote ---
You should put the request to wx devs.
C::B uses ::wxRenameFile() function to rename a file. If it returns false C::B throws that error message. So this function should be able to detect such cases.
raph:
--- Quote from: Biplab on July 04, 2007, 05:53:08 pm ---C::B uses ::wxRenameFile() function to rename a file. If it returns false C::B throws that error message. So this function should be able to detect such cases.
--- End quote ---
Just set the overwrite flag in this case and you are fine.
I've submitted a patch (#002089).
thomas:
There is nothing to fix, as this is intended behaviour. I don't know why it's intended, but it is.
The way I had originally implemented that function would just rename the file, overwriting a possibly existing file. This of course assumes a basic amount of diligence from the user's part, but I did not deem that as a problem.
Code::Blocks is not thought to replace Windows Explorer, it only contains that function to make your life easier when you need to rename files in your project (so renaming on the file system and in the project is one operation).
Later, it was found that if you provide users with a way to rename files and allow them to overwrite an existing file, they will do it 20 times per day, and they will never learn it. Neither will they see that they're doing something wrong. Thus, functionality was added to check for existence before overwriting a file (therefore, setting the overwrite flag is not an option).
Now, the problem is, Main.h and main.h are really the same file under Windows. I don't know why, it does not make sense to me, but this is intended behaviour ever since the days of DOS.
If you ask for Main.h, and main.h exists, you get main.h.
The only possibility to work around this (which is probably what Explorer and Visual Studio do, too) is to add an extra case-insensitive comparison, and silently overwrite files if that comparison returns equality.
But... no thank you! I think we'll rather live with the fact that Main.h can't be renamed into main.h under Windows than add such nasty hacks to work around deliberately wrong behaviour :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version