C标准函数,似乎不应该有平台问题:
我们看一下这个程序:
#include
#include
int main()
{
rename(”/tmp/abc”,”/tmp/bcd”);
perror(”why:”);
}
此程序运行一切正常。
自己将路径修改为不同的分区之间移动,或者将同一分区挂载到不同的mount点进行rename。
看看结果会怎么样。
man 2 rename
oldpath and newpath are not on the same mounted filesystem. (Linux permits a filesystem to be
mounted at multiple points, but rename(2) does not work across different mount points, even if the
same filesystem is mounted on both.)
在Windows上尝试:
rename(”C://a.txt”,”D://b.txt”);
works!!
fangjtan:
来自:http://www.linux-ren.org/modules/everestblog/?p=141当rename(oldpath,“1”);则将oldpath的文件移动当前目录,且文件名更名为1;