_Rupfb () -提供前次 I/O 作業的相關資訊
格式
#include <recio.h>
_RIOFB_T *_Rupfb(_RFILE *fp);語言層次
ILE C 延伸
安全執行緒
是
不過,如果在執行緒之間傳遞檔案指標,則會在那些執行緒之間共用 I/O 回饋區域。
說明
_Rupfb() 函數會以前次 I/O 作業的相關資訊來更新與 fp 所指定檔案相關聯的回饋結構。 即使在開啟檔案時指定 riofb = N ,也會更新 _RIOFB_T 結構。 將不會更新 _RIOFB_T 結構的 num_bytes 欄位。 如需 _RIOFB_T 結構的說明,請參閱 <recio.h> 。
_Rupfb() 函數適用於所有類型的檔案。
回覆值
範例
#include <stdio.h>
#include <recio.h>
#include <stdlib.h>
int main(void)
{
_RFILE *fp;
_RIOFB_T *fb;
/* Create a physical file */
system("CRTPF FILE(QTEMP/MY_FILE) RCDLEN(80)");
/* Open the file for write */
if ( (fp = _Ropen("QTEMP/MY_FILE", "wr")) == NULL )
{
printf("open for write fails\n");
exit(1);
}
/* Write some records into the file */
_Rwrite(fp, "This is record 1", 16);
_Rwrite(fp, "This is record 2", 16);
_Rwrite(fp, "This is record 3", 16);
_Rwrite(fp, "This is record 4", 16);
_Rwrite(fp, "This is record 5", 16);
_Rwrite(fp, "This is record 6", 16);
_Rwrite(fp, "This is record 7", 16);
_Rwrite(fp, "This is record 8", 16);
_Rwrite(fp, "This is record 9", 16);
/* Close the file */
_Rclose(fp);
/* Open the file for read */
if ( (fp = _Ropen("QTEMP/MY_FILE", "rr, blkrcd = y")) == NULL )
{
printf("open for read fails\n");
exit(2);
}
/* Read some records */
_Rreadn(fp, NULL, 80, __DFT);
_Rreadn(fp, NULL, 80, __DFT);
/* Call _Rupfb and print feed back information */
fb = _Rupfb(fp);
printf("record number -------------------------- %d\n",
fb->rrn);
printf("number of bytes read ------------------- %d\n",
fb->num_bytes);
printf("number of records remaining in block --- %hd\n",
fb->blk_count);
if ( fb->blk_filled_by == __READ_NEXT )
{
printf("block filled by ------------------------ __READ_NEXT\n");
}
else
{
printf("block filled by ------------------------ __READ_PREV\n");
}
/* Close the file */
_Rclose(fp);
}