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

in package

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-2024 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
SuppressWarnings

(PHPMD.ExcessiveClassComplexity)

Table of Contents

Methods

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, string>
Returns an array of possible alternative file paths or URLs
getFileData()  : string|false
Reads entire file into a string.
getUrlData()  : string|false
Reads entire remote file into a string using CURL
rfRead()  : string
Binary-safe file read.

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

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 $resource) : int
Parameters
$resource : 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, string>
Parameters
$file : string

Name of the file or URL to read.

Return values
array<string|int, string>

List of possible alternative file paths or URLs.

getFileData()

Reads entire file into a string.

public getFileData(string $file) : string|false

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|false

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|false
Parameters
$url : string

URL to read.

Tags
SuppressWarnings

(PHPMD.CyclomaticComplexity)

Return values
string|false

rfRead()

Binary-safe file read.

public rfRead(resource|null $resource, int<0, max> $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
$resource : resource|null

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

$length : int<0, max>

Number of bytes to read.

Tags
throws
Exception

in case of error

Return values
string
On this page
 

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