Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there no boost::filesystem::move_file?

Tags:

I'm using boost filesystem to replace windows C++ functions like CopyFile and MoveFile to get some kind of portability between windows and linux. I'm using copy_file but I have not been able to find anything that moves files like a 'move_file' function. Do boost have a move file function?

I would very much prefer to use boost, but alternative suggestions are welcome.

like image 362
molholm Avatar asked Jun 30 '10 12:06

molholm


People also ask

What is boost :: filesystem :: path?

boost::filesystem::path is the central class in Boost. Filesystem for representing and processing paths. Definitions can be found in the namespace boost::filesystem and in the header file boost/filesystem. hpp . Paths can be built by passing a string to the constructor of boost::filesystem::path (see Example 35.1).

What is Boost Filesystem?

The Boost Filesystem Library provides portable facilities to query and manipulate paths, files, and directories. The motivation for the library is the need to be able to perform portable script-like operations from within C++ programs.


1 Answers

It's called rename, see the manual. Like the corresponding OS functions, this might or might not work if the source and destination paths are on different file systems. If it doesn't work, use a copy operation followed by a delete operation.

like image 88
Philipp Avatar answered Sep 30 '22 16:09

Philipp