PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

dio_read> <dio_fcntl
Last updated: Fri, 29 Aug 2008

view this page in

dio_open

(PHP 4 >= 4.2.0, PHP 5 <= 5.0.5)

dio_open 指定したパーミッション flags と作成許可 mode を指定して 新しいファイルをオープンする

説明

resource dio_open ( string $filename , int $flags [, int $mode ] )

dio_open() は、ファイルをオープンして そのファイル記述子を返します。

パラメータ

filename

オープンするファイル名。

flags

flags パラメータには、 以下のフラグの組み合わせを指定します。

  • O_CREAT - ファイルが存在しなければ 新しいファイルを作成します。

  • O_EXCL - O_CREAT および O_EXCL をともに指定すると、 すでにファイルが存在する場合に dio_open() が失敗します。

  • O_TRUNC - すでにファイルが存在し、書き込み アクセス用にオープンされている場合、ファイルの長さをゼロに切り詰めます。

  • O_APPEND - 書き込み時は、ファイルの終端に 追記します。

  • O_NONBLOCK - 非ブロッキングモードを指定します。

mode

flagsO_CREAT の場合に、mode でファイルのモード (作成許可)を指定します。

  • O_RDONLY - 読み込み専用でファイルをオープンします。

  • O_WRONLY - 書き込み専用でファイルをオープンします。

  • O_RDWR - 読み書き両用でファイルをオープンします。

返り値

ファイル記述子を返します。エラー時には FALSE を返します。

例1 ファイル記述子をオープンする

<?php

$fd 
dio_open('/dev/ttyS0'O_RDWR O_NOCTTY O_NONBLOCK);

dio_close($fd);
?>

参考



add a note add a note User Contributed Notes
dio_open
j at pureftpd dot org
23-Jan-2005 04:13
Please note that dio_open()/dio_write()/dio_close() is *faster* than fopen()/fwrite()/fclose() for files.

fwrite() has to manage a 8k buffer, while dio_write() just issue a single write(). The end result is less system calls and less memory access.

Also, giving the full size to write() as with dio_write() let filesystems properly use preallocation in order to avoid fragmentation.
alla at cyber dot com dot au
22-Mar-2003 07:16
To specify a combination of flags you OR them together.
This was the only way I could get it to append:

$fd = dio_open($file, O_WRONLY | O_APPEND);

dio_read> <dio_fcntl
Last updated: Fri, 29 Aug 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites