Lines Matching refs:file

65  * @param string   $file filename
70 function io_readWikiPage($file, $id, $rev=false) { argument
72 $data = array(array($file, true), getNS($id), noNS($id), $rev);
102 * @param string $file filename
106 function io_readFile($file,$clean=true){ argument
108 if(file_exists($file)){
109 if(substr($file,-3) == '.gz'){
111 $ret = gzfile($file);
113 }else if(substr($file,-4) == '.bz2'){
115 $ret = bzfile($file);
117 $ret = file_get_contents($file);
133 * @param string $file filename
137 function bzfile($file, $array=false) { argument
138 $bz = bzopen($file,"r");
183 * @param string $file filename
189 function io_writeWikiPage($file, $content, $id, $rev=false) { argument
192 $data = array(array($file, $content, false), getNS($id), noNS($id), $rev);
221 * @param string $file filename path to file
226 function _io_saveFile($file, $content, $append) { argument
229 $fileexists = file_exists($file);
231 if(substr($file,-3) == '.gz'){
233 $fh = @gzopen($file,$mode.'9');
237 }else if(substr($file,-4) == '.bz2'){
240 $bzcontent = bzfile($file);
244 $fh = @bzopen($file,'w');
249 $fh = @fopen($file,$mode);
255 if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
270 * @param string $file filename path to file
275 function io_saveFile($file, $content, $append=false) { argument
276 io_makeFileDir($file);
277 io_lock($file);
278 if(!_io_saveFile($file, $content, $append)) {
279 msg("Writing $file failed",-1);
280 io_unlock($file);
283 io_unlock($file);
306 * @param string $file filename
313 function io_replaceInFile($file, $oldline, $newline, $regex=false, $maxlines=0) { argument
319 if (!file_exists($file)) return true;
321 io_lock($file);
324 if(substr($file,-3) == '.gz'){
326 $lines = gzfile($file);
327 }else if(substr($file,-4) == '.bz2'){
329 $lines = bzfile($file, true);
331 $lines = file($file);
359 if(!_io_saveFile($file, join('',$lines), false)) {
360 msg("Removing content from $file failed",-1);
361 io_unlock($file);
365 @unlink($file);
368 io_unlock($file);
379 * @param string $file filename
384 function io_deleteFromFile($file,$badline,$regex=false){ argument
385 return io_replaceInFile($file,$badline,null,$regex,0);
399 * @param string $file filename
401 function io_lock($file){ argument
404 $lockDir = $conf['lockdir'].'/'.md5($file);
425 * @param string $file filename
427 function io_unlock($file){ argument
430 $lockDir = $conf['lockdir'].'/'.md5($file);
459 $tmp = dirname( $file = call_user_func($types[$ns_type], $ns) );
468 io_makeFileDir($file);
482 * @param string $file file name
484 function io_makeFileDir($file){ argument
485 $dir = dirname($file);
552 foreach($files as $file) {
553 if(!@unlink($file)) return false; //abort on any error
601 * @param string $file path to file or directory where to save
608 function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=2097152){ argument
636 $file = $file.$name;
639 $fileexists = file_exists($file);
640 $fp = @fopen($file,"w");
644 if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
706 * @param string $file The file to search
712 function io_grep($file,$pattern,$max=0,$backref=false){ argument
713 $fh = @fopen($file,'r');
746 * @param string $file filename path to file
749 function io_getSizeFile($file) { argument
750 if (!file_exists($file)) return 0;
752 if(substr($file,-3) == '.gz'){
753 $fp = @fopen($file, "rb");
761 }else if(substr($file,-4) == '.bz2'){
764 $bz = bzopen($file,"r");
777 $uncompressedsize = filesize($file);