44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
namespace nulib\file;
|
|
|
|
use nulib\os\EOFException;
|
|
use nulib\os\IOException;
|
|
|
|
/**
|
|
* Interface IReader: un objet depuis lequel on peut lire des données
|
|
*/
|
|
interface IReader extends _IFile {
|
|
/** @throws IOException */
|
|
function fread(int $length): string;
|
|
|
|
/** @throws IOException */
|
|
function fgets(): string;
|
|
|
|
/** @throws IOException */
|
|
function fpassthru(): int;
|
|
|
|
function fgetcsv(): ?array;
|
|
|
|
/**
|
|
* lire la prochaine ligne. la ligne est retournée *sans* le caractère de fin
|
|
* de ligne [\r]\n
|
|
*
|
|
* @throws EOFException si plus aucune ligne n'est disponible
|
|
* @throws IOException si une autre erreur se produit
|
|
*/
|
|
function readLine(): ?string;
|
|
|
|
/**
|
|
* lire tout le contenu du fichier en une seule fois, puis, si $close==true,
|
|
* le fermer
|
|
*
|
|
* @throws IOException si une erreur se produit
|
|
*/
|
|
function getContents(bool $close=true, bool $alreadyLocked=false): string;
|
|
|
|
/** désérialiser le contenu du fichier, puis, si $close===true, le fermer */
|
|
function unserialize(?array $options=null, bool $close=true, bool $alreadyLocked=false);
|
|
|
|
function copyTo(IWriter $dest, bool $closeWriter=false, bool $closeReader=true): void;
|
|
}
|