Пример #1
0
 public function sync($cb, $pri = EIO_PRI_DEFAULT)
 {
     if (!FS::$supported) {
         call_user_func($cb, $this, true);
         return;
     }
     return eio_fsync($this->fd, $pri, $cb, $this);
 }
Пример #2
0
 /**
  * Sync()
  * @param  callable $cb Callback
  * @param  integer $pri Priority
  * @return resource|false
  */
 public function sync($cb, $pri = EIO_PRI_DEFAULT)
 {
     $cb = CallbackWrapper::forceWrap($cb);
     if (!$this->fd) {
         if ($cb) {
             $cb($this, false);
         }
         return false;
     }
     if (!FileSystem::$supported) {
         $cb($this, true);
         return false;
     }
     return eio_fsync($this->fd, $pri, $cb, $this);
 }
Пример #3
0
        $datepart = str_replace(' ', '_', $data["datepart"]);
        preg_match_all('/(https?:\\/\\/[^\\s]+)|([@#\\p{L}][\\p{L}]+)/u', $text, $matches, PREG_PATTERN_ORDER);
        foreach ($matches[0] as $word) {
            if (preg_match('/(https?:\\/\\/)/u', $word)) {
                continue;
            }
            if ($lowercase !== 0) {
                $word = mb_strtolower($word);
            }
            fputs($tempfile, "\"{$datepart}\" \"{$word}\"\n");
        }
    }
    mysql_free_result($sqlresults);
}
if (function_exists('eio_fsync')) {
    eio_fsync($tempfile);
} else {
    fflush($tempfile);
}
$tempmeta = stream_get_meta_data($tempfile);
$templocation = $tempmeta["uri"];
// write csv results
// CSV is written by awk here, so we explicitely handle the output format
$filename = get_filename_for_export("wordFrequency");
$csv = fopen($filename, "w");
fputs($csv, chr(239) . chr(187) . chr(191));
if ($outputformat == 'tsv') {
    fputs($csv, "interval\tword\tfrequency\n");
} else {
    fputs($csv, "interval,word,frequency\n");
}
Пример #4
0
 /**
  * Doesn't do anything unless the eio extension is loaded
  *
  * Will block until the sync is complete
  *
  * @throws IOException If the sync fails
  * @return void
  */
 public function sync()
 {
     if (!$this->file) {
         throw new IOException('Cannot sync file: file is not open');
     }
     if (extension_loaded('eio')) {
         $success = false;
         eio_fsync($this->file, null, function ($data, $result) use(&$success) {
             if ($result === 0) {
                 $success = true;
             }
         });
         eio_event_loop();
         if (!$success) {
             throw new IOException('Failed to sync file to disk');
         }
     }
 }