popen
string string
popen は、取り消し不可能、照会不可能、および編集不可能です。
fopen と同様、popen は二番目のモード引数(「r」または「w」)に応じて、ファイルを読み出しまたは書き込み用に開きます。このコマンドは、system 関数コールを使用して実行され、コマンドの入力または出力からパイプが作成されます。popen が 0 を返した場合、何か問題があった事を示します。ファイルからの読み込み、ファイルの書き出しのための標準ファイル関数を popen で開いたパイプについて使用することができます(fprint、fgetword、fgetline など)。| int | パイプ ID 番号 |
// Unix specific example. Note: if you really want to get a directory
// listing, please use the "getFileList" command instead. This is just
// used as a simple example.
//
$pipe = popen( "ls -1", "r" );
string $dirList[];
while ( !feof( $pipe ) ) {
$dirList[size( $dirList )] = fgetline( $pipe );
}
pclose( $pipe );
// Windows specific example. Note: if you really want to get a directory
// listing, please use the "getFileList" command instead. This is just
// used as a simple example.
//
$pipe = popen( "DIR /B", "r" );
string $dirList[];
while ( !feof( $pipe ) ) {
$dirList[size( $dirList )] = fgetline( $pipe );
}
pclose( $pipe );