rename linux 函數

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.