unlink()函數說明

來源:互聯網
上載者:User
功能描述:
從檔案系統中刪除一個名稱。如果名稱是檔案的最後一個串連,並且沒有其它進程將檔案開啟,名稱對應的檔案會實際被刪除。
 

用法: 
#include <unistd.h>

int unlink(const char *pathname);

參數:  
pathname:指向需解除串連的檔案名稱。 
 
   
返回說明:  
成功執行時,返回0。失敗返回-1,errno被設為以下的某個值  
EACCES:權能不足
EFAULT: 記憶體空間不可訪問
EIO:發生輸入輸出錯誤
EISDIR:pathname索引的是目錄
ELOOP :路徑解析的過程中存在太多的符號串連
ENAMETOOLONG:路徑名超出可允許的長度
ENOENT:路徑名部分內容表示的目錄不存在,或者是懸浮的串連
ENOMEM: 核心記憶體不足
ENOTDIR:路徑名的部分內容不是目錄
EPERM : 檔案系統不支援檔案或者目錄的解除串連,也有可能是許可權步允許
EROFS    :檔案系統唯讀

 

#include
#include

int main(void)
{
FILE *fp = fopen("junk.jnk","w");
int status;

fprintf(fp,"junk");

status = access("junk.jnk",0);
if (status == 0)
printf("File exists/n");
else
printf("File doesn't exist/n");

fclose(fp);
unlink("junk.jnk");
status = access("junk.jnk",0);
if (status == 0)
printf("File exists/n");
else
printf("File doesn't exist/n");

return 0;
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.