EvStat::__construct

(PECL ev >= 0.2.0)

EvStat::__constructConstruit un objet EvStat watcher

Description

public function EvStat::__construct(
     string $path ,
     float $interval ,
     callable $callback ,
     mixed $data = null ,
     int $priority = 0
)

Construit un objet EvStat watcher et démarre le watcher automatiquement.

Liste de paramètres

path
Le chemin pour lequel on attend une modification de statut.
interval
Intervalle de détection d'une modification ; devrait valoir normalement 0.0 pour laisser libev choisir la bonne valeur.
callback
Voir les fonctions de rappel Watcher.
data
Données personnalisées à associer avec le watcher.
priority
Les priorités du Watcher

Exemples

Exemple #1 Surveillance des modifications dans le dossier /var/log/messages

<?php
// Utilisation d'un intervalle de 10 secondes.
 $w = new EvStat("/var/log/messages", 10, function ($w) {
 echo "/var/log/messages changed\n";

 $attr = $w->attr();

 if ($attr['nlink']) {
  printf("Current size: %ld\n", $attr['size']);
  printf("Current atime: %ld\n", $attr['atime']);
  printf("Current mtime: %ld\n", $attr['mtime']);
 } else {
  fprintf(STDERR, "Le fichier `messages` est introuvable !");
  $w->stop();
 }
});

?>
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top