Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • AppFileUtil
  • CommandUtil
  • CrontabUtil
  • EncryptUtil
  • FileUtil
  • Overview
  • Package
  • Class
  • Tree

Class FileUtil

Standalone file manipulation class.

Miscellaneous file system utilities. It is not a child class of CComponent or the like in order to be portable/stand-alone (so it can be used outside the app, i.e. by the installer).

Package: application\components\util
Author: Demitri Morgan <demitri@x2engine.com>
Located at x2engine/protected/components/util/FileUtil.php
Methods summary
public static boolean
# ccopy( string $source, string $target, boolean $relTarget = false, boolean $contents = true )

Copies a file or directory recursively.

Copies a file or directory recursively.

If the local filesystem directory to where the file will be copied does not exist yet, it will be created automatically. Furthermore, if a remote URL is being accessed and allow_url_fopen isn't set, it will attempt to use CURL instead.

Parameters

$source
string
$source The source file.
$target
string
$target The destination path.
$relTarget
boolean
$relTarget Transform the target to a relative path. This option must be false unless the target is an absolute path.
$contents
boolean
$contents If true, and the source is a directory, its contents will be copied to the destination; otherwise, the whole directory will be copied into the destination directory.

Returns

boolean
public static
# cdftp( string $target )

Change to a given directory relative to the FTP stream's current working directory

Change to a given directory relative to the FTP stream's current working directory

Parameters

$target
string
$target
public static
# cleanDosPath( mixed $path )

Removes DOS-related junk from an absolute path.

Removes DOS-related junk from an absolute path.

Returns the path as an array of nodes.

public static
# createLockfile( String $lockfile )

Create a lockfile using the appropriate functionality, depending on the selected file operation.

Create a lockfile using the appropriate functionality, depending on the selected file operation.

Parameters

$lockfile
String
$lockfile
public static resource
# curlInit( string $url )

Initializes and returns a CURL resource handle

Initializes and returns a CURL resource handle

Parameters

$url
string
$url

Returns

resource
public static
# ftpClose( )

Closes the current FTP stream and resets the file operation method to 'php'

Closes the current FTP stream and resets the file operation method to 'php'

public static
# ftpInit( String $host, String $user, String $pass, String $dir = null, String $chroot = null )

Initializes the FTP functionality. This connects to the FTP server, logs in, and sets PASV mode. Optionally, you can specify the chroot directory and a directory to change to, e.g.: the web root or the test directory. This is recommended if working with relative paths.

Initializes the FTP functionality. This connects to the FTP server, logs in, and sets PASV mode. Optionally, you can specify the chroot directory and a directory to change to, e.g.: the web root or the test directory. This is recommended if working with relative paths.

Parameters

$host
String
$host The FTP server to connect to
$user
String
$user The FTP user.
$pass
String
$pass Specified FTP user's password.
$dir
String
$dir Initial directory to change to, or null by default to disable.
$chroot
String
$chroot The chosen chroot directory for the user.
public static
# ftpStripChroot( mixed $dir )
public static type
# getContents( type $source, type $use_include_path = false, mixed $context = null )

Wrapper for file_get_contents that attempts to use CURL if allow_url_fopen is disabled.

Wrapper for file_get_contents that attempts to use CURL if allow_url_fopen is disabled.

Parameters

$source
type
$source
$use_include_path
type
$url
$context

Returns

type

Throws

Exception
public static boolean
# isRelative( string $path )

Returns whether the given parameter is a relative path

Returns whether the given parameter is a relative path

Parameters

$path
string
$path

Returns

boolean
Whether the path is relative
public static
# noTraversal( array $path )

Removes redundant up-one-level directory traversal from a path.

Removes redundant up-one-level directory traversal from a path.

Returns an array corresponding to each node in the path, with redundant directory traversal removed. For example, "items/files/stuff/../things" will be returned as array("items","files","things"). Note, however, that "../../stuff/things" will be returned as array("stuff","things"), which does not accurately reflect the actual path from the original working directory. The intention of this function was to clean up absolute paths.

Parameters

$path
array
$path Path to clean
public static
# removeLockfile( String $lockfile )

Remove a lockfile using the appropriate functionality, depending on the selected file operation.

Remove a lockfile using the appropriate functionality, depending on the selected file operation.

Parameters

$lockfile
String
$lockfile
public static string
# rpath( string $path )

Format a path so that it is platform-independent. Doesn't return false if the path doesn't exist (so unlike realpath() it can be used to create new files).

Format a path so that it is platform-independent. Doesn't return false if the path doesn't exist (so unlike realpath() it can be used to create new files).

Parameters

$path
string
$path

Returns

string
public static
# relpath( string $path, string $start = null, string $ds = DIRECTORY_SEPARATOR )

Calculates a relative path between two absolute paths.

Calculates a relative path between two absolute paths.

Parameters

$path
string
$path The path to which the absolute path should be calculated.
$start
string
$start The starting path. Must be absolute, if specified, and must be specified if the path argument is not platform-agnostic.
$ds
string
$ds Directory separator. If the two paths (path and start) use the (almost) ubiquitous convention of forward slashes, but the calculation is to take place on a Windows machine, this must be set to forward slash, so that
public static
# rrmdir( string $path, string $noDelPat = null )

Recursively remove a directory and all its subdirectories.

Recursively remove a directory and all its subdirectories.

Walks a directory structure, removing files recursively. An optional exclusion pattern can be included. If a directory contains a file that matches the exclusion pattern, the directory and its ancestors will not be deleted.

Parameters

$path
string
$path
$noDelPat
string
$noDelPat PCRE pattern for excluding files in deletion.
public static resource
# finfo( )

Create/return finfo resource handle

Create/return finfo resource handle

Returns

resource
public static type
# formatSize( type $bytes, mixed $places = 0 )

Create human-readable size string

Create human-readable size string

Parameters

$bytes
type
$bytes
$places

Returns

type
public static type
# tryCurl( mixed $source )

The criteria for which CURL should be used.

The criteria for which CURL should be used.

Returns

type
Constants summary
integer ERR_FTPOPER 100
#
Properties summary
public static mixed $_finfo
#
public static boolean $alwaysCurl false
#
public static string $fileOper "php"
#
public static boolean $ftpChroot false
#
X2CRM Documentation API documentation generated by ApiGen 2.8.0