Lines Matching refs:file

69  * @param string $file filename
76 function io_readWikiPage($file, $id, $rev = false) argument
81 $data = [[$file, true], getNS($id), noNS($id), $rev];
111 * @param string $file filename
117 function io_readFile($file, $clean = true) argument
120 if (file_exists($file)) {
121 if (str_ends_with($file, '.gz')) {
123 $ret = gzfile_get_contents($file);
125 } elseif (str_ends_with($file, '.bz2')) {
127 $ret = bzfile($file);
129 $ret = file_get_contents($file);
150 * @param string $file filename
155 function gzfile_get_contents($file) argument
157 $fh = @fopen($file, 'rb');
195 * @param string $file filename
202 function bzfile($file, $array = false) argument
204 $bz = bzopen($file, "r");
251 * @param string $file filename
259 function io_writeWikiPage($file, $content, $id, $rev = false) argument
267 $data = [[$file, $content, false], getNS($id), noNS($id), $rev];
296 * @param string $file filename path to file
303 function _io_saveFile($file, $content, $append) argument
307 $fileexists = file_exists($file);
309 if (str_ends_with($file, '.gz')) {
311 $fh = @gzopen($file, $mode . '9');
315 } elseif (str_ends_with($file, '.bz2')) {
318 $bzcontent = bzfile($file);
322 $fh = @bzopen($file, 'w');
327 $fh = @fopen($file, $mode);
334 chmod($file, $conf['fperm']);
348 * @param string $file filename path to file
355 function io_saveFile($file, $content, $append = false) argument
357 io_makeFileDir($file);
358 io_lock($file);
359 if (!_io_saveFile($file, $content, $append)) {
360 msg("Writing $file failed", -1);
361 io_unlock($file);
364 io_unlock($file);
383 * @param string $file filename
394 function io_replaceInFile($file, $oldline, $newline, $regex = false, $maxlines = 0) argument
401 if (!file_exists($file)) return true;
403 io_lock($file);
406 if (str_ends_with($file, '.gz')) {
408 $lines = gzfile($file);
409 } elseif (str_ends_with($file, '.bz2')) {
411 $lines = bzfile($file, true);
413 $lines = file($file);
442 if (!_io_saveFile($file, implode('', $lines), false)) {
443 msg("Removing content from $file failed", -1);
444 io_unlock($file);
448 @unlink($file);
451 io_unlock($file);
460 * @param string $file filename
467 function io_deleteFromFile($file, $badline, $regex = false) argument
469 return io_replaceInFile($file, $badline, '', $regex, 0);
481 * @param string $file filename
485 function io_lock($file) argument
489 $lockDir = $conf['lockdir'] . '/' . md5($file);
510 * @param string $file filename
514 function io_unlock($file) argument
518 $lockDir = $conf['lockdir'] . '/' . md5($file);
548 $tmp = dirname($file = call_user_func($types[$ns_type], $ns));
559 io_makeFileDir($file);
571 * @param string $file file name
575 function io_makeFileDir($file) argument
577 $dir = dirname($file);
647 foreach ($files as $file) {
648 if (!@unlink($file)) return false; //abort on any error
694 * @param string $file path to file or directory where to save
704 function io_download($url, $file, $useAttachment = false, $defaultName = '', $maxSize = 2_097_152) argument
733 $file .= $name;
736 $fileexists = file_exists($file);
737 $fp = @fopen($file, "w");
742 chmod($file, $conf['fperm']);
809 * @param string $file The file to search
817 function io_grep($file, $pattern, $max = 0, $backref = false) argument
819 $fh = @fopen($file, 'r');
850 * @param string $file filename path to file
855 function io_getSizeFile($file) argument
857 if (!file_exists($file)) return 0;
859 if (str_ends_with($file, '.gz')) {
860 $fp = @fopen($file, "rb");
867 } elseif (str_ends_with($file, '.bz2')) {
869 $bz = bzopen($file, "r");
881 $uncompressedsize = filesize($file);