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, 11 Apr 2008

view this page in

dio_open

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

dio_open — Apre un nuovo file nella modalità specificata da flags e i permessi indicati in mode

Descrizione

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

La funzione dio_open() apre un file e restituisce un nuovo descrittore di file per questo.

Elenco dei parametri

filename

Il file aperto.

flags

Il parametro flags può contenere qualsiasi combinazione dei seguenti valori:

  • O_CREAT - crea un file, se questo non esiste già.

  • O_EXCL - se sono impostati sia O_CREAT e sia O_EXCL, la funzione dio_open() fallisce se il file esiste.

  • O_TRUNC - se il file esiste, ed è aperto in scrittura, il file verrà portato a lunghezza zero.

  • O_APPEND - nelle operazioni di scrittura, scrive i dati alla fine del file.

  • O_NONBLOCK - imposta la modalità non blocking.

mode

Se flags vale O_CREAT, allora il parametro mode imposta la modalità del file (permessi di creazione).

  • O_RDONLY - apre il file per accessi in lettura.

  • O_WRONLY - apre il file in scrittura.

  • O_RDWR - apre il file sia in lettura sia in scrittura.

Valori restituiti

Restituisce un descrittore di file, oppure FALSE in caso di errore.

Esempi

Example #1 Apertura di un descrittore di file

<?php

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

dio_close($fd);
?>

Vedere anche:



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, 11 Apr 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites