41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
|
<?php
|
||
|
namespace nulib\file;
|
||
|
|
||
|
use nulib\os\IOException;
|
||
|
|
||
|
/**
|
||
|
* Interface IWriter: un objet dans lequel on peut écrire des données
|
||
|
*/
|
||
|
interface IWriter extends _IFile {
|
||
|
/** @throws IOException */
|
||
|
function fwrite(string $data, int $length=0): int;
|
||
|
|
||
|
/** @throws IOException */
|
||
|
function fflush(): self;
|
||
|
|
||
|
/** @throws IOException */
|
||
|
function ftruncate(int $size): self;
|
||
|
|
||
|
/** afficher les lignes */
|
||
|
function writeLines(?iterable $lines): self;
|
||
|
|
||
|
/**
|
||
|
* essayer de verrouiller le fichier en écriture. retourner true si l'opération
|
||
|
* réussit. dans ce cas, il faut appeler {@link getWriter()} avec l'argument
|
||
|
* true
|
||
|
*/
|
||
|
function canWrite(): bool;
|
||
|
|
||
|
/**
|
||
|
* verrouiller en mode exclusif puis retourner un objet permettant d'écrire
|
||
|
* dans le fichier
|
||
|
*/
|
||
|
function getWriter(bool $lockedByCanWrite=false): IWriter;
|
||
|
|
||
|
/** écrire le contenu spécifié dans le fichier */
|
||
|
function putContents(string $contents, bool $close=true, bool $lockedByCanWrite=false): void;
|
||
|
|
||
|
/** sérialiser l'objet dans la destination */
|
||
|
function serialize($object, bool $close=true, bool $lockedByCanWrite=false): void;
|
||
|
}
|