20

我正在使用 boost 文件系统来替换 Windows C++ 函数,如 CopyFile 和 MoveFile,以获得 Windows 和 linux 之间的某种可移植性。我正在使用 copy_file,但我找不到任何像“move_file”函数这样移动文件的东西。boost有移动文件功能吗?

我非常喜欢使用 boost,但欢迎提供其他建议。

4

2 回答 2

37

它被称为rename,请参阅手册。与相应的操作系统功能一样,如果源路径和目标路径位于不同的文件系统上,这可能会或可能不会起作用。如果它不起作用,请使用复制操作,然后执行删除操作。

于 2010-06-30T12:38:37.330 回答
-6
void add_time(ptime& gen_time, int seconds) {
    boost::posix_time::millisec_posix_time_system_config::time_duration_type time_elapse(0, 0, seconds);
    //time_elapse = p2 - p1;
    gen_time = gen_time + time_elapse;
}
于 2013-09-25T11:49:23.303 回答