|
-
July 11th, 2012, 11:15 AM
#1
rename_file vs move_file
I am writing a little OS agnostic library for my team for manipulating files.
One such function is used to move/rename files (only files, not dirs). I got into a little argument with a colleague about naming: "rename" or "move"?
"move" makes more sense, but the c api calls it rename.
Is there any historic (or actual) difference between a "rename" and a "move" we could base ourselves on? Or is this purely an Apples vs Oranges?
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
July 11th, 2012, 11:40 AM
#2
Re: rename_file vs move_file
If you think of it in terms of renaming/moving a file, then whether "rename" or "move" makes more sense depends on whether the file will be in a different directory.
If you think of it in terms of changing a file path, than "rename" makes more sense than "move".
-
July 11th, 2012, 01:21 PM
#3
Re: rename_file vs move_file
Another difference could be if overwriting another file with the same path as the destination is allowed. I don't know how this works on other platforms, but on Windows you cannot overwrite when using rename, but you can overwrite with move.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
-
July 11th, 2012, 01:25 PM
#4
Re: rename_file vs move_file
Another implementation difference is that rename usually can't change the device a file is on, but move can.
-
July 13th, 2012, 11:59 AM
#5
Re: rename_file vs move_file
Hum...
Move it is then!
Thanks
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
July 13th, 2012, 12:46 PM
#6
Re: rename_file vs move_file
Instead of writing your own code, wouldn't the boost::filesystem do the trick?
-
July 13th, 2012, 03:05 PM
#7
Re: rename_file vs move_file
I wish, but this current project has the following restraints:
1) No templates due to compiler limitations.
2) No non in-house code.
EDIT: 3) No exceptions.

It's basically "C with classes here".
That said, I'm not completly re-writing the wheel, my interface is mostly a convenience wrapper to a lower level API.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|