Overview

Packages

  • akismet
  • None
  • PHP
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • plugins
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Signatures
    • Signed
    • Transport
  • wa-apps
    • blog
      • actions
        • backend
        • blog
        • comment
        • cron
        • design
        • frontend
        • page
        • plugin
        • post
      • api
        • v1
      • cli
      • layout
      • model
      • plugin
        • aksimet
        • category
        • emailsubscription
        • favorite
        • gravatar
        • import
        • markdown
        • myposts
        • tag
        • troll
      • settings
    • checklists
      • backend
      • json
    • contacts
      • backend
    • developer
    • dummy
    • guestbook
    • guestbook2
    • photos
      • album
      • api
        • v1
      • backend
      • design
      • dialog
      • frontend
      • page
      • photo
      • plugin
        • comment
        • imageeffects
        • import
        • publicgallery
        • watermark
      • search
      • settings
      • stack
      • tag
      • upload
    • site
      • backend
      • blocks
      • config
      • design
      • domains
      • files
      • frontend
      • helper
      • layout
      • pages
      • routing
      • setting
    • stickies
      • api
        • v1
      • sheet
      • stiky
  • wa-plugin
    • payment
    • shipping
    • sms
  • wa-plugins
    • shipping
      • usps
  • wa-system
    • API
    • Auth
      • Adapters
    • Autoload
    • Cache
      • Adapter
    • Captcha
    • Config
    • Contact
    • controller
    • currency
    • database
    • datetime
    • design
    • event
    • exception
    • files
    • image
    • layout
    • locale
    • log
    • mail
    • page
      • action
      • model
    • payment
    • plugin
    • request
    • response
    • routing
    • shipping
    • sms
    • storage
    • user
    • util
    • validator
    • view
    • webasyst
      • api
      • backend
      • cli
      • config
      • layout
      • login
      • model
      • password
      • payment
      • profile
      • settings
      • shipment
    • widget
    • workflow
  • waPlugins
    • Payment
  • webasyst
    • wa-system
      • helper

Classes

  • waFiles
  • waTheme
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class waFiles

Collection of helper functions to work with files.

Package: wa-system\files
Copyright: 2011 Webasyst LLC
Author: Webasyst LLC
Located at wa-system/file/waFiles.class.php
Methods summary
private
# __construct( )
public static string|boolean
# create( string $path, boolean $is_dir = false )

Creates a new file or directory.

Creates a new file or directory.

Parameters

$path
string
$path Path for the new file or directory
$is_dir
boolean
$is_dir Flag requiring to create a directory rather than a file. By default (false), a file is created.

Returns

string|boolean
Specified $path value on success, or false on failure
public static
# copy( string $source_path, string $target_path, string|array $skip_pattern = null )

Copies a file or directory contents.

Copies a file or directory contents.

Parameters

$source_path
string
$source_path Path to the original file or directory. If path to a directory is specified, then the contents of that directory are copied to the specified location. Subdirectories are copied recursively.
$target_path
string
$target_path Path for saving a copy.
$skip_pattern
string|array
$skip_pattern Regular expression string describing the format of file and subdirectory names which must not be copied if a path to a subdirectory is specified in $source_path parameter (otherwise this regular expression is ignored).

Throws

Exception
public static boolean
# move( string $source_path, string $target_path )

Moves a file or a directory to specified parent directory. Can be used for renaming.

Moves a file or a directory to specified parent directory. Can be used for renaming.

Parameters

$source_path
string
$source_path Path to original file or directory
$target_path
string
$target_path Path to which the specified file or directory must be copied

Returns

boolean
Whether moved (renamed) successfully
public static
# write( string $path, string $content )

Writes data to specified file. If file does not exist, it will be created.

Writes data to specified file. If file does not exist, it will be created.

Parameters

$path
string
$path Path for saving a file. An existing file will be overwritten.
$content
string
$content Data to be written to the file.
public static array
# listdir( string $dir, boolean $recursive = false )

Returns array of files and subdirectories in specified directory.

Returns array of files and subdirectories in specified directory.

Parameters

$dir
string
$dir Path to directory
$recursive
boolean
$recursive Flag requiring to return the contents of subdirectories. By default (false) subdirectories' contents are not returned. When true, only the list of files contained in specified parent directory is returned, without the names of subdirectories.

Returns

array
public static boolean
# delete( string $path, boolean $ignore_dir_errors = false )

Deletes a file or a directory. A directory containing subdirectories is deleted recursively.

Deletes a file or a directory. A directory containing subdirectories is deleted recursively.

Parameters

$path
string
$path Path to a file or directory.
$ignore_dir_errors
boolean
$ignore_dir_errors Flag requiring to ignore any errors which may occur during the deletion of directories. By default (false), errors are not ignored — an exception is thrown.

Returns

boolean
True, if deleted successfully

Throws

waException
Exception
public static string
# extension( string $file )

Returns file name extension.

Returns file name extension.

Parameters

$file
string
$file Path to file or directory

Returns

string
public static string
# getMimeType( string $filename )

Determines the MIME type of a file by its name extension.

Determines the MIME type of a file by its name extension.

Parameters

$filename
string
$filename File name

Returns

string
public static string
# convert( string $file, string $from, string $to = 'UTF-8', string $target = null )

Changes text file character encoding.

Parameters

$file
string
$file Path to file
$from
string
$from Original encoding
$to
string
$to Target encoding
$target
string
$target Optional path to save encoded file to

Returns

string
Path to file containing converted text

Throws

waException
private static
# curlInit( mixed $url, mixed $curl_options = array() )
private static integer
# curlWriteHandler( mixed $ch, mixed $chunk )

Parameters

$ch
mixed
$ch
$chunk
mixed
$chunk

Returns

integer

Throws

Exception

Used by

waFiles::curlInit()
public static integer
# upload( string $url, string $path )

Uploads a file from specified URL to a server directory.

Uploads a file from specified URL to a server directory.

Parameters

$url
string
$url URL from which a file must be retrieved
$path
string
$path Path for saving the downloaded file

Returns

integer
Size of saved file in bytes

Throws

waException
public static
# readFile( string $file, string|null $attach = null, boolean $exit = true, boolean $md5 = false )

Reads file contents and outputs it to browser with appropriate headers.

Reads file contents and outputs it to browser with appropriate headers.

Parameters

$file
string
$file File to path
$attach
string|null
$attach Name, which will be suggested to user when he requests to download the file. If not specified, browser's auto-suggestion will be used.
$exit
boolean
$exit Flag requiring to send file transfer headers to user's browser. By default (true) headers are sent.
$md5
boolean
$md5 Flag requiring to send the Content-MD5 header. By default (false) this header is not sent.

Throws

waException
If file does not exist
public static
# protect( string $path )

Protect a directory by creating .htaccess with 'Deny from all', if it does not exist.

Protect a directory by creating .htaccess with 'Deny from all', if it does not exist.

Parameters

$path
string
$path Path to directory
public static string
# formatSize( integer $file_size, string $format = '%0.2f', string|mixed $dimensions = 'Bytes,KBytes,MBytes,GBytes' )

Returns formatted file size value.

Returns formatted file size value.

Parameters

$file_size
integer
$file_size Numerical file size value.
$format
string
$format Format string for displaying file size value, which must be acceptable for PHP function sprintf().
$dimensions
string|mixed
$dimensions String of comma-separated file size measure units.

Returns

string
Properties summary
private static mixed $fp
#
private static mixed $size
#
My fork of Webasyst Framework API documentation generated by ApiGen 2.8.0