Remove all the {{{ and }}} folding

This commit is contained in:
2022-11-25 20:34:27 +01:00
parent b723f47a44
commit 2d6df0d5f0
35 changed files with 0 additions and 1124 deletions

View File

@@ -34,7 +34,6 @@ class File
* @throws If directory not exists, or the directory is not executable
*/
public function chdir ($directory)
// {{{
{
$this->debug (2, "chdir ($directory)");
$tmpdirectory = $this->realpath ($directory);
@@ -46,7 +45,6 @@ class File
$this->debug (1, "chdir $directory -> $this->cwd");
return true;
}
// }}}
/** Change the group for a file/dir...
* @param string $filename The file/directory to change
@@ -54,7 +52,6 @@ class File
* @throws If filename not exists, or the directory is not RW
*/
public function chgrp ($filename, $group)
// {{{
{
$this->debug (2, "chgrp ($filename, $group)");
$filename = $this->realpath ($filename);
@@ -71,7 +68,6 @@ class File
$this->debug (1, "chgrp ($filename, $group) => $rc");
return $rc;
}
// }}}
/** Change the rights mode for a file/dir...
* @param string $filename The file/directory to change
@@ -79,7 +75,6 @@ class File
* @throws If filename not exists, or the directory is not RW
*/
public function chmod ($filename, $mode)
// {{{
{
$this->debug (2, "chmod ($filename, $mode)");
$filename = $this->realpath ($filename);
@@ -96,7 +91,6 @@ class File
$this->debug (1, "chmod ($filename, $mode) => $rc");
return $rc;
}
// }}}
/** Change the owner for a file/dir...
* @param string $filename The file/directory to change
@@ -104,7 +98,6 @@ class File
* @throws If filename not exists, or the directory is not RW
*/
public function chown ($filename, $user)
// {{{
{
$this->debug (2, "chown ($filename, $user)");
if (posix_getuid () !== 0 &&
@@ -127,7 +120,6 @@ class File
$this->debug (1, "chown ($filename, $user) => $rc");
return $rc;
}
// }}}
/** Chroot in the provided directory
* @param string $directory The directory to chroot
@@ -135,7 +127,6 @@ class File
* @throws If directory not exists, or the directory is not executable
*/
public function chroot ($directory)
// {{{
{
// Use the checkPathRO (using the $this->baseDir) to not allow to go away of
// the chroot.
@@ -147,7 +138,6 @@ class File
$this->debug (1, "chroot $directory -> $this->baseDir");
return true;
}
// }}}
/** Get the file contents in an array (like 'file' function, but can not
* have the same name as the class...)
@@ -157,7 +147,6 @@ class File
* exists or is not readable
*/
public function fileArray ($filename)
// {{{
{
$this->debug (2, "file ($filename)");
$filename = $this->realpath ($filename);
@@ -174,7 +163,6 @@ class File
$this->debug (1, "file ($filename) => ". count ($contents). " rows");
return $contents;
}
// }}}
/** Checks whether a file or directory exists
* @param string $filename The file or directory to verify
@@ -182,7 +170,6 @@ class File
* @throws If parent directory not exists, or is not executable
*/
public function file_exists ($filename)
// {{{
{
$this->debug (2, "file_exists ($filename)");
$filename = $this->realpath ($filename);
@@ -199,7 +186,6 @@ class File
return true;
return false;
}
// }}}
/** Get the file contents
* @param string $filename Name of the file to read
@@ -208,7 +194,6 @@ class File
* exists or is not readable
*/
public function file_get_contents ($filename)
// {{{
{
$this->debug (2, "file_get_contents ($filename)");
$filename = $this->realpath ($filename);
@@ -226,7 +211,6 @@ class File
" bytes");
return $contents;
}
// }}}
/** Write a string to a file
* @param string $filename Path to the file where to write the data
@@ -237,7 +221,6 @@ class File
* exists and is not writeable
*/
public function file_put_contents ($filename, $data, $flags=0)
// {{{
{
$this->debug (2, "file_put_contents ($filename)");
$filename = $this->realpath ($filename);
@@ -256,7 +239,6 @@ class File
return $contents;
}
// }}}
/** Get the file modification time of a file
* @param string $filename Path to the file
@@ -266,14 +248,12 @@ class File
* @throws If parent directory not exists, is not writeable
*/
public function filemtime ($filename)
// {{{
{
$this->debug (2, "filemtime ($filename)");
$filename = $this->realpath ($filename);
$this->checkPathRO (dirname ($filename));
return filemtime ($filename);
}
// }}}
/** Get the file size
* @param string $filename Path to the file
@@ -281,14 +261,12 @@ class File
* @throws If parent directory not exists, is not writeable
*/
public function filesize ($filename)
// {{{
{
$this->debug (2, "filesize ($filename)");
$filename = $this->realpath ($filename);
$this->checkPathRO (dirname ($filename));
return filesize ($filename);
}
// }}}
/** Get the file info of the provided filename
* @param string $filename Path to the file
@@ -296,7 +274,6 @@ class File
* @throws If parent directory not exists, is not writeable
*/
public function fileinfoMimeType ($filename)
// {{{
{
$this->debug (2, "filesize ($filename)");
$filename = $this->realpath ($filename);
@@ -304,17 +281,14 @@ class File
$finfo = new \finfo (FILEINFO_MIME_TYPE);
return $finfo->file ($filename);
}
// }}}
/** Return the current working directory
* @return string the current working directory */
public function getcwd ()
// {{{
{
$this->debug (1, "getcwd $this->cwd");
return $this->cwd;
}
// }}}
/** Find pathnames matching a pattern
* If there is some unreadable files, skip them quietly
@@ -325,7 +299,6 @@ class File
* or if there is one file unreadable
*/
public function glob ($pattern, $flags=0)
// {{{
{
$this->debug (2, "glob ($pattern, $flags)");
$this->checkPathRO ($this->baseDir);
@@ -355,7 +328,6 @@ class File
}
return $files;
}
// }}}
/** Tells whether the given filename is a directory
* @param string $filename The filename to test
@@ -364,7 +336,6 @@ class File
* @throws If parent directory not exists, or is not executable
*/
public function is_dir ($filename)
// {{{
{
$this->debug (2, "is_dir ($filename)");
$filename = $this->realpath ($filename);
@@ -373,7 +344,6 @@ class File
return true;
return false;
}
// }}}
/** Tells whether the given filename is a valid file
* @param string $filename The filename to test
@@ -381,7 +351,6 @@ class File
* @throws If parent directory not exists, or is not executable
*/
public function is_file ($filename)
// {{{
{
$this->debug (2, "is_file ($filename)");
$filename = $this->realpath ($filename);
@@ -390,7 +359,6 @@ class File
return true;
return false;
}
// }}}
/** Tells whether a file exists and is executable
* @param string $filename The filename to test
@@ -398,7 +366,6 @@ class File
* @throws If parent directory not exists, or is not executable
*/
public function is_executable ($filename)
// {{{
{
$this->debug (2, "is_executable ($filename)");
$filename = $this->realpath ($filename);
@@ -407,7 +374,6 @@ class File
return true;
return false;
}
// }}}
/** Tells whether a file exists and is readable
* @param string $filename The filename to test
@@ -415,7 +381,6 @@ class File
* @throws If parent directory not exists, or is not executable
*/
public function is_readable ($filename)
// {{{
{
$this->debug (2, "is_readable ($filename)");
$filename = $this->realpath ($filename);
@@ -424,7 +389,6 @@ class File
return true;
return false;
}
// }}}
/** Tells whether a file exists and is writeable
* @param string $filename The filename to test
@@ -432,7 +396,6 @@ class File
* @throws If parent directory not exists, or is not executable
*/
public function is_writeable ($filename)
// {{{
{
$this->debug (2, "is_writeable ($filename)");
$filename = $this->realpath ($filename);
@@ -441,7 +404,6 @@ class File
return true;
return false;
}
// }}}
/** Lock a file exclusively
* @param string $filename The file to lock
@@ -449,7 +411,6 @@ class File
* @throws If parent directory not exists, or is not writeable
*/
public function lockEX ($filename)
// {{{
{
$this->debug (2, "lockEX ($filename)");
$filename = $this->realpath ($filename);
@@ -465,7 +426,6 @@ class File
$this->locks[$filename] = fopen ($filename, "rt");
return flock ($this->locks[$filename], LOCK_EX);
}
// }}}
/** Lock a file shared (allow multiple read)
* @param string $filename The file to lock
@@ -473,7 +433,6 @@ class File
* @throws If parent directory not exists, or is not writeable
*/
public function lockSH ($filename)
// {{{
{
$this->debug (2, "lockSH ($filename)");
$filename = $this->realpath ($filename);
@@ -489,7 +448,6 @@ class File
$this->locks[$filename] = fopen ($filename, "rt");
return flock ($this->locks[$filename], LOCK_SH);
}
// }}}
/** Unlock a file previously locked
* @param string $filename The file to lock
@@ -497,7 +455,6 @@ class File
* @throws If parent directory not exists, or is not writeable
*/
public function lockUN ($filename)
// {{{
{
$this->debug (2, "lockUN ($filename)");
$filename = $this->realpath ($filename);
@@ -511,7 +468,6 @@ class File
}
return $res;
}
// }}}
/** Calculate the md5 sum of a file
* @param string $filename The file to hash
@@ -519,7 +475,6 @@ class File
* @throws If the file doesn't exists
*/
public function md5_file ($filename)
// {{{
{
$this->debug (2, "md5_file ($filename)");
$filename = $this->realpath ($filename);
@@ -534,7 +489,6 @@ class File
$filename), 500);
return md5_file ($filename);
}
// }}}
/** Create a new directory
* @param string $pathname The directory to create
@@ -545,7 +499,6 @@ class File
* @throws If parent directory not exists, is not writeable
*/
public function mkdir ($pathname, $mode = 0777, $recursive = false)
// {{{
{
$this->debug (2, "mkdir ($pathname, $mode, $recursive)");
$pathname = $this->realpath ($pathname);
@@ -583,7 +536,6 @@ class File
$this->debug (1, "mkdir ($pathname, $mode, $recursive) => $rc");
return $rc;
}
// }}}
/** Copy a file or a directory
* @param string $oldname The file to copy
@@ -592,7 +544,6 @@ class File
* @return bool
*/
public function copy ($oldname, $newname)
// {{{
{
$this->debug (2, "copy ($oldname, $newname)");
$oldname = $this->realpath ($oldname);
@@ -615,7 +566,6 @@ class File
$this->debug (1, "copy ($oldname, $newname) => $rc");
return $rc;
}
// }}}
/** Renames a file or directory
* @param string $oldname The file or directory to rename
@@ -624,7 +574,6 @@ class File
* @return bool
*/
public function rename ($oldname, $newname)
// {{{
{
$this->debug (2, "rename ($oldname, $newname)");
$oldname = $this->realpath ($oldname);
@@ -635,7 +584,6 @@ class File
$this->debug (1, "rename ($oldname, $newname) => $rc");
return $rc;
}
// }}}
/** Return a ini file converted to an array
* @param string $filename The filename of the ini file being parsed.
@@ -643,7 +591,6 @@ class File
* @return array
*/
public function parse_ini_file ($filename, $process_sections = false)
// {{{
{
$this->debug (2, "parse_ini_file ($filename, $process_sections)");
$filename = $this->realpath ($filename);
@@ -658,7 +605,6 @@ class File
$filename), 500);
return parse_ini_file ($filename, $process_sections);
}
// }}}
/** Return the canonical absolute path. Do not check if the directory exists,
* if there is links. Just calculate the realpath based on the chroot value
@@ -666,7 +612,6 @@ class File
* @return string the canonical absolute path
*/
public function realpath ($path)
// {{{
{
$oriPath = $path;
$this->debug (2, "realpath ($oriPath)");
@@ -705,7 +650,6 @@ class File
$this->debug (1, "realpath ($oriPath) => $path");
return $path;
}
// }}}
/** Remove the provided directory
* If the recurse flag is true, remove the content too (files and
@@ -717,7 +661,6 @@ class File
* dir is not writeable
*/
public function rmdir ($dirname, $recursive=false)
// {{{
{
$this->debug (2, "rmdir ($dirname, $recursive)");
$tmpdirname = $this->realpath ($dirname);
@@ -739,7 +682,6 @@ class File
}
return rmdir ($tmpdirname);
}
// }}}
/** Return the list of files and directories in the directory.
* Do not return the . and .. virtual dirs.
@@ -749,7 +691,6 @@ class File
* @throws If directory not exists, or is not executable
*/
public function scandir ($directory)
// {{{
{
$this->debug (2, "scandir ($directory)");
$directory = $this->realpath ($directory);
@@ -758,7 +699,6 @@ class File
natsort ($res);
return $res;
}
// }}}
/** Return the list of files and directories in the directory.
* Do not return the . and .. virtual dirs.
@@ -768,7 +708,6 @@ class File
* @throws If directory not exists, or is not executable
*/
public function scandirNotSorted ($directory)
// {{{
{
$this->debug (2, "scandirNotSorted ($directory)");
$directory = $this->realpath ($directory);
@@ -777,7 +716,6 @@ class File
array('..', '.')));
return $res;
}
// }}}
/** Calculate the sha1 sum of a file
* @param string $filename The file to hash
@@ -785,7 +723,6 @@ class File
* @throws If the file doesn't exists
*/
public function sha1_file ($filename)
// {{{
{
$this->debug (2, "sha1_file ($filename)");
$filename = $this->realpath ($filename);
@@ -800,7 +737,6 @@ class File
$filename), 500);
return sha1_file ($filename);
}
// }}}
/** Create a new file or update the timestamp if the file exists
* @param string $filename the filename
@@ -812,7 +748,6 @@ class File
* @throws If parent directory not exists, is not writeable
*/
public function touch ($filename, $time = null, $atime = null)
// {{{
{
$this->debug (2, "touch ($filename, $time, $atime)");
$filename = $this->realpath ($filename);
@@ -825,7 +760,6 @@ class File
$this->debug (1, "touch ($filename, $time, $atime) => $rc");
return $rc;
}
// }}}
/** Delete an existing file.
* @param string $filename The filename to remove
@@ -833,7 +767,6 @@ class File
* @throws If parent directory not exists, or is not executable
*/
public function unlink ($filename)
// {{{
{
$this->debug (2, "unlink ($filename)");
$filename = $this->realpath ($filename);
@@ -842,7 +775,6 @@ class File
return false;
return unlink ($filename);
}
// }}}
/** Check all the parents of the $directory if they are available, and
* executable. The path must exists.
@@ -854,7 +786,6 @@ class File
* @throws if there is a missing part, or a parent is not executable
*/
private function checkPathRO ($path)
// {{{
{
$this->debug (2, "checkPathRO ($path)");
$path = preg_replace ("#//+#", "/", $path);
@@ -925,7 +856,6 @@ class File
}
return $this->checkExternalPathRO ($path);
}
// }}}
/** Check all the parents of the $directory if they are available, and
* executable. The path must exists.
@@ -937,7 +867,6 @@ class File
* @throws if there is a missing part, or a parent is not executable
*/
private function checkPathRW ($path)
// {{{
{
$this->debug (2, "checkPathRW ($path)");
$this->checkPathRO ($path);
@@ -961,7 +890,6 @@ class File
}
return true;
}
// }}}
/** Save a debug log
* @param integer $prio The message priority. Should be higher than
@@ -970,7 +898,6 @@ class File
* @return null
*/
private function debug ($prio, $message)
// {{{
{
if ($this->debug === false || $this->debug === 0)
return;
@@ -982,7 +909,6 @@ class File
// FILE_APPEND);
}
}
// }}}
/** External function allowed to be overloaded to test the RO access to a
* resource
@@ -990,11 +916,9 @@ class File
* @return boolean true if RO access, false if not
*/
public function checkExternalPathRO ($path)
// {{{
{
return true;
}
// }}}
/** External function allowed to be overloaded to test the RW access to a
* resource
@@ -1002,9 +926,7 @@ class File
* @return boolean true if RW access, false if not
*/
public function checkExternalPathRW ($path)
// {{{
{
return true;
}
// }}}
}