日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux服务器编程之:truncate()函数+案例说明

發布時間:2024/9/27 linux 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux服务器编程之:truncate()函数+案例说明 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.依賴頭文件

#include<unistd.h>

#include<sys/types.h>

2.函數定義:

int truncate(const char *path,off_t length);

int ftruncate(int fd,off_t length);

函數說明:

The? truncate()? and ftruncate() functions cause the regular file named
?????? by path or referenced by fd to be truncated? to? a? size? of? precisely
?????? length bytes.

?????? 翻譯:truncate()和ftruncate()函數導致一個名稱為path或者被文件描述符fd引用的常規文件被截斷成一個大小精為length字節的文件。

If? the? file? previously? was larger than this size, the extra data is
?????? lost.? If the file previously was shorter,? it? is? extended,? and? the
?????? extended part reads as null bytes ('\0').

???????翻譯:如果先前的文件大于這個大小,額外的數據丟失。如果先前的文件小于當前定義的大小,那么,這個文件將會被擴展,擴展的部分將補以null,也就是‘\0’

If? the? size? changed,? then the st_ctime and st_mtime fields (respec‐
?????? tively, time of last status change and time of last? modification;? see
?????? stat(2)) for the file are updated, and the set-user-ID and set-group-ID
?????? permission bits may be cleared.

???????翻譯:如果大小發生變化,那么這個st_ctime(訪問時間)和st_mtime()修改時間將會被更新。

With ftruncate(), the file must be open for writing;? with? truncate(),
?????? the file must be writable.

??????翻譯:使用ftruncate(),這個文件必須被打開用以寫操作。使用truncate函數的文件必須能夠被寫

3.案例說明:

?







總結

以上是生活随笔為你收集整理的Linux服务器编程之:truncate()函数+案例说明的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。