classes-Com-Tecnick-File-File

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.

File

Com\Tecnick\File\File

Function to read byte-level data

Tags
since
2015-07-28
category

Library

author

Nicola Asuni info@tecnick.com

copyright

2015-2015 Nicola Asuni - Tecnick.com LTD

license

http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)

link
https://github.com/tecnickcom/tc-lib-file

Table of Contents

fileGetContents()  : string
Reads entire file into a string.
fopenLocal()  : resource
Wrapper to use fopen only with local files
fReadInt()  : int
Read a 4-byte (32 bit) integer from file.
getAltFilePaths()  : array<string|int, mixed>
Returns an array of possible alternative file paths or URLs
getFileData()  : string
Reads entire file into a string.
getUrlData()  : string
Reads entire remote file into a string using CURL
rfRead()  : string
Binary-safe file read.
getAltLocalUrlPath()  : string
Replace URL relative path with full real server path
getAltMissingUrlProtocol()  : string
Add missing local URL protocol
getAltPathFromUrl()  : string
Add missing local URL protocol
getAltUrlFromPath()  : string
Get an alternate URL from a file path
getDefaultUrlProtocol()  : string
Get the default URL protocol (http or https)

Methods

fileGetContents()

Reads entire file into a string.

public fileGetContents(string $file) : string

The file can be also an URL.

Parameters
$file : string

Name of the file or URL to read.

Return values
string

File content

fopenLocal()

Wrapper to use fopen only with local files

public fopenLocal(string $filename, string $mode) : resource
Parameters
$filename : string

Name of the file to open

$mode : string

The fopen mode parameter specifies the type of access you require to the stream

Tags
throws
Exception

in case of error

Return values
resource

Returns a file pointer resource on success

fReadInt()

Read a 4-byte (32 bit) integer from file.

public fReadInt(resource $handle) : int
Parameters
$handle : resource

A file system pointer resource that is typically created using fopen().

Return values
int

4-byte integer

getAltFilePaths()

Returns an array of possible alternative file paths or URLs

public getAltFilePaths(string $file) : array<string|int, mixed>
Parameters
$file : string

Name of the file or URL to read.

Return values
array<string|int, mixed>

getFileData()

Reads entire file into a string.

public getFileData(string $file) : string

The file can be also an URL if the URL wrappers are enabled.

Parameters
$file : string

Name of the file or URL to read.

Return values
string

File content or FALSE in case the file is unreadable

getUrlData()

Reads entire remote file into a string using CURL

public getUrlData(string $url) : string
Parameters
$url : string

URL to read.

Return values
string

File content or FALSE in case the file is unreadable or curl is not available

rfRead()

Binary-safe file read.

public rfRead(resource $handle, int $length) : string

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 : resource

A file system pointer resource that is typically created using fopen().

$length : int

Number of bytes to read.

Tags
throws
Exception

in case of error

Return values
string

getAltLocalUrlPath()

Replace URL relative path with full real server path

protected getAltLocalUrlPath(string $file) : string
Parameters
$file : string

Relative URL path

Return values
string

getAltMissingUrlProtocol()

Add missing local URL protocol

protected getAltMissingUrlProtocol(string $file) : string
Parameters
$file : string

Relative URL path

Return values
string

local path or original $file

getAltPathFromUrl()

Add missing local URL protocol

protected getAltPathFromUrl(string $url) : string
Parameters
$url : string

Relative URL path

Return values
string

local path or original $file

getAltUrlFromPath()

Get an alternate URL from a file path

protected getAltUrlFromPath(string $file) : string
Parameters
$file : string

File name and path

Return values
string

getDefaultUrlProtocol()

Get the default URL protocol (http or https)

protected getDefaultUrlProtocol() : string
Return values
string
 

© 2004-2021 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy