Class File
Com\Tecnick\File\File
Function to read byte-level data
Methods summary
public Returns |
# fopenLocal( string
$filename, string $mode
)
Wrapper to use fopen only with local files
Wrapper to use fopen only with local files
Parameters
- $filename
- Name of the file to open
- $mode
- The fopen mode parameter specifies the type of access you
require to the stream
Returns
Returns
a file pointer resource on success
Throws
|
public 4-byte |
# fReadInt( resource
$handle )
Read a 4-byte (32 bit) integer from file.
Read a 4-byte (32 bit) integer from file.
Parameters
- $handle
- A file system pointer resource that is typically created using
fopen().
Returns
4-byte
integer
|
public string |
# rfRead( resource
$handle, integer $length
)
Binary-safe file read. Reads up to length bytes from the file
pointer referenced by handle. Reading stops as soon as one of the
following conditions is met: length bytes have been read; EOF (end
of file) is reached.
Binary-safe file read. Reads up to length bytes from the file
pointer referenced by handle. Reading stops as soon as one of the
following conditions is met: length bytes have been read; EOF (end
of file) is reached.
Parameters
- $handle
- A file system pointer resource that is typically created using
fopen().
- $length
- Number of bytes to read.
Returns
string
Throws
|
public string |
#
fileGetContents( string
$file )
Reads entire file into a string. The file can be also an
URL.
Reads entire file into a string. The file can be also an
URL.
Parameters
- $file
- Name of the file or URL to read.
Returns
string
File content
|
public string |
# getFileData( string
$file )
Reads entire file into a string. The file can be also an URL if
the URL wrappers are enabled.
Reads entire file into a string. The file can be also an URL if
the URL wrappers are enabled.
Parameters
- $file
- Name of the file or URL to read.
Returns
string
File content or FALSE in case the file is unreadable
|
public string |
# getUrlData( string
$url )
Reads entire remote file into a string using CURL
Reads entire remote file into a string using CURL
Parameters
Returns
string
File content or FALSE in case the file is unreadable or curl is not
available
|
public array |
#
getAltFilePaths( string
$file )
Returns an array of possible alternative file paths or URLs
Returns an array of possible alternative file paths or URLs
Parameters
- $file
- Name of the file or URL to read.
Returns
array
|
protected string |
#
getAltLocalUrlPath( string
$file )
Replace URL relative path with full real server path
Replace URL relative path with full real server path
Parameters
- $file
- $path Relative URL path
Returns
string
|
protected string |
#
getAltMissingUrlProtocol(
string $file )
Add missing local URL protocol
Add missing local URL protocol
Parameters
Returns
string
local path or original $file
|
protected string |
#
getDefaultUrlProtocol( )
Get the default URL protocol (http or https)
Get the default URL protocol (http or https)
Returns
string
|
protected string |
#
getAltPathFromUrl( string
$url )
Add missing local URL protocol
Add missing local URL protocol
Parameters
- $url
- $file Relative URL path
Returns
string
local path or original $file
|
protected string |
#
getAltUrlFromPath( string
$file )
Get an alternate URL from a file path
Get an alternate URL from a file path
Parameters
Returns
string
|