Oihana Php Ftp

RawListParser

Parses the raw, Unix-style (`ls -l`) output of `ftp_rawlist` into {@see FtpFile} entries.

Only the common Unix long-listing format is understood; total N headers and lines that do not match are skipped. The listing date is intentionally not converted to a timestamp (its format is locale- and server-dependent and ambiguous on year boundaries) — prefer MLSD (ftp_mlsd) when the server supports it.

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Constants

PATTERN  : string = '/^([\-dlbcps])([rwxsStT\-]{9})\s+\d+\s+(\S+)\s...
The Unix long-listing line pattern.

Methods

parse()  : array<int, FtpFile>
Parses a list of raw listing lines into entries.
parseLine()  : FtpFile|null
Parses a single raw listing line.

Constants

PATTERN

The Unix long-listing line pattern.

private string PATTERN = '/^([\-dlbcps])([rwxsStT\-]{9})\s+\d+\s+(\S+)\s+(\S+)\s+(\d+)\s+(\w{3}\s+\d{1,2}\s+[\d:]+)\s+(.+)$/'

Methods

parse()

Parses a list of raw listing lines into entries.

public static parse(array<int, string> $lines) : array<int, FtpFile>
Parameters
$lines : array<int, string>

The raw lines returned by ftp_rawlist.

Return values
array<int, FtpFile>

The parsed entries (unparseable lines are skipped).

parseLine()

Parses a single raw listing line.

public static parseLine(string $line) : FtpFile|null
Parameters
$line : string

The raw line.

Return values
FtpFile|null

The parsed entry, or null when the line is a header or cannot be parsed.

On this page

Search results