Overview

Namespaces

  • None
  • Peg
    • Cli
      • Commands
    • Config
    • Custom
      • Command
        • Action
          • Generate
          • Parse
      • CommandLine
      • Config
      • Localization
      • Utilities
    • Lib
      • Definitions
        • Element
      • Generator
      • Lexers
      • Plugins
      • Signals
        • Data
          • Definitions
          • Lexers
        • Type
  • PHP

Classes

  • FileSystem
  • Json
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo

Class FileSystem

Function to manage files and directories

Namespace: Peg\Custom\Utilities
Located at src/Utilities/FileSystem.php
Methods summary
public static array
# GetDirContent( string $path )

Get all the files and directories available on a specified path.

Get all the files and directories available on a specified path.

Parameters

$path
string
$path

Returns

array
List of files found.
public static boolean
# MakeDir( string $directory, integer $mode = 0755, boolean $recursive = false )

Same as php mkdir() but adds Operating system check and replaces every / by \ on windows.

Same as php mkdir() but adds Operating system check and replaces every / by \ on windows.

Parameters

$directory
string
$directory The directory to create.
$mode
integer
$mode the permissions granted to the directory.
$recursive
boolean
$recursive Recurse in to the path creating neccesary directories.

Returns

boolean
true on success false on fail.
public static boolean
# RecursiveCopyDir( string $source, string $target )

Copy a directory and its content to another directory replacing any file on the target directory if already exist.

Copy a directory and its content to another directory replacing any file on the target directory if already exist.

Parameters

$source
string
$source The directory to copy.
$target
string
$target The copy destination.

Returns

boolean
true on success or false on fail.
public static boolean
# RecursiveRemoveDir( string $directory, string $empty = false )

Remove a directory that is not empty by deleting all its content.

Remove a directory that is not empty by deleting all its content.

Parameters

$directory
string
$directory The directory to delete with all its content.
$empty
string
$empty Removes all directory contents keeping only itself.

Returns

boolean
True on success or false.
public boolean
# WriteFileIfDifferent( string $file, string & $contents )

Only saves content to a file if the new content is not the same as the original. This is helpful to prevent an unneccesary timestamp modification which is used by compilers to decide wether the file needs recompilation.

Only saves content to a file if the new content is not the same as the original. This is helpful to prevent an unneccesary timestamp modification which is used by compilers to decide wether the file needs recompilation.

Parameters

$file
string
$file Path to file.
$contents
string
$content New content of file.

Returns

boolean
True on success or false if file content is the same.
PEG Api API documentation generated by ApiGen 2.8.0