rename linux 函数

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:

当rename(oldpath,“1”);则将oldpath的文件移动当前目录,且文件名更名为1;

来自:http://www.linux-ren.org/modules/everestblog/?p=141
发布了37 篇原创文章 · 获赞 4 · 访问量 7万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章