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;