下位入出力Low-Level I/O
これらの関数は、ストリーム入出力の操作より低レベルの操作に対してオペレーティング システムを直接呼び出します。These functions invoke the operating system directly for lower-level operation than that provided by stream I/O. 低レベル入出力の呼び出しでは、データはバッファリングまたは書式設定されません。Low-level input and output calls do not buffer or format data.
低レベル ルーチンでは、次の事前定義済みのファイル記述子を使用して、プログラムの起動時に開かれる標準ストリームにアクセスできます。Low-level routines can access the standard streams opened at program startup using the following predefined file descriptors.
ストリームStream | ファイル記述子File Descriptor |
---|---|
stdinstdin | 00 |
stdoutstdout | 11 |
標準stderr | 22 |
低レベル入出力ルーチンでは、エラー発生時に errno グローバル変数が設定されます。Low-level I/O routines set the errno global variable when an error occurs. ファイルの終端を示すインジケーター (EOF) などの STDIO.H で定義された定数が、お使いのプログラムで必要な場合に限り、低レベル関数を使用する際に STDIO.H をインクルードする必要があります。You must include STDIO.H when you use low-level functions only if your program requires a constant that is defined in STDIO.H, such as the end-of-file indicator (EOF).
低レベル入出力関数Low-Level I/O Functions
機能Function | 使用Use |
---|---|
_close_close | ファイルを閉じるClose file |
_commit_commit | ファイルをディスクにフラッシュするFlush file to disk |
_creat、_wcreat_creat, _wcreat | [ファイルの作成]Create file |
_dup_dup | 指定されたファイルに対して次に使用できるファイル記述子を返すReturn next available file descriptor for given file |
_dup2_dup2 | 指定されたファイルに対して 2 つ目の記述子を作成するCreate second descriptor for given file |
_eof_eof | ファイルの終端をテストするTest for end of file |
_lseek、_lseeki64_lseek, _lseeki64 | ファイル ポインターの位置を指定された場所に変更するReposition file pointer to given location |
_open、_wopen_open, _wopen | ファイルを開くOpen file |
_read_read | ファイルからデータを読み取るRead data from file |
_sopen、_wsopen、_sopen_s、_wsopen_s_sopen, _wsopen, _sopen_s, _wsopen_s | ファイル共有のためにファイルを開くOpen file for file sharing |
_tell、_telli64_tell, _telli64 | 現在のファイル ポインターの位置を取得するGet current file-pointer position |
_umask、_umask_s_umask, _umask_s | ファイル アクセス許可マスクを設定するSet file-permission mask |
_write_write | ファイルにデータを書き込むWrite data to file |
_dup と _dup2 は通常、事前定義済みのファイル記述子を別のファイルと関連付けるために使用します。_dup and _dup2 are typically used to associate the predefined file descriptors with different files.
関連項目See also
入力と出力Input and Output
カテゴリ別ユニバーサル C ランタイム ルーチンUniversal C runtime routines by category
システムコールSystem Calls