Oihana Php Ftp

FtpFile

A typed description of a single entry in a remote directory listing.

Instances are produced either from a structured MLSD entry (fromMlsd()) or by parsing a raw ls -l line (see RawListParser).

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$group  : string|null
$modifiedTime  : int|null
$name  : string
$owner  : string|null
$permissions  : string|null
$size  : int
$target  : string|null
$type  : string

Methods

__construct()  : mixed
Creates a new listing entry.
fromMlsd()  : self
Builds an entry from a structured MLSD record (as returned by `ftp_mlsd`).
isDirectory()  : bool
Indicates whether the entry is a directory.
isFile()  : bool
Indicates whether the entry is a regular file.
isLink()  : bool
Indicates whether the entry is a symbolic link.
parseMlsdTime()  : int|null
Parses an MLSD `modify` fact (`YYYYMMDDHHMMSS`, UTC) into a Unix timestamp.

Properties

$group

public string|null $group = null

$modifiedTime

public int|null $modifiedTime = null

$owner

public string|null $owner = null

$permissions

public string|null $permissions = null

$target

public string|null $target = null

$type

public string $type = FtpFileType::UNKNOWN

Methods

__construct()

Creates a new listing entry.

public __construct([string $name = '' ][, string $type = FtpFileType::UNKNOWN ][, int $size = 0 ][, int|null $modifiedTime = null ][, string|null $permissions = null ][, string|null $owner = null ][, string|null $group = null ][, string|null $target = null ]) : mixed
Parameters
$name : string = ''

The entry name.

$type : string = FtpFileType::UNKNOWN

One of the FtpFileType constants.

$size : int = 0

The size in bytes (0 when unknown).

$modifiedTime : int|null = null

The last-modified Unix timestamp, or null when unknown.

$permissions : string|null = null

The permission string (e.g. drwxr-xr-x) or mode, when known.

$owner : string|null = null

The owner, when known.

$group : string|null = null

The group, when known.

$target : string|null = null

The link target for a symbolic link, when known.

fromMlsd()

Builds an entry from a structured MLSD record (as returned by `ftp_mlsd`).

public static fromMlsd(array<string, mixed> $entry) : self
Parameters
$entry : array<string, mixed>

The MLSD facts (name, type, size, modify, …).

Return values
self

The hydrated entry.

isDirectory()

Indicates whether the entry is a directory.

public isDirectory() : bool
Return values
bool

True for a directory.

isFile()

Indicates whether the entry is a regular file.

public isFile() : bool
Return values
bool

True for a file.

Indicates whether the entry is a symbolic link.

public isLink() : bool
Return values
bool

True for a symbolic link.

parseMlsdTime()

Parses an MLSD `modify` fact (`YYYYMMDDHHMMSS`, UTC) into a Unix timestamp.

private static parseMlsdTime(string $modify) : int|null
Parameters
$modify : string

The MLSD modify fact.

Return values
int|null

The Unix timestamp, or null when the value cannot be parsed.

On this page

Search results