_Rupfb () -最後の入出力操作に関する情報の提供
形式
#include <recio.h>
_RIOFB_T *_Rupfb(_RFILE *fp);言語レベル
ILE C Extension
スレッド・セーフ
はい
ただし、スレッド間でファイル・ポインターが渡された場合、入出力フィードバック域はそれらのスレッド間で共有されます。
説明
_Rupfb() 関数は、 fp で指定されたファイルに関連したフィードバック構造体を、最後の入出力操作に関する情報で更新します。 _RIOFB_T 構造体は、ファイルのオープン時に riofb=N が指定された場合であっても更新されます。 _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);
}