Core\FileTransfer\Entry::path
$entry->path(): stringReturns the path of a file or folder on the server. The path starts at the root of the block.
list, walk and metadata give one Core\FileTransfer\Entry for each file, folder or symbolic link (a name that points to another file or folder). $entry->path() is the whole path below the root, even when walk starts in a sub-folder. A walk in reports gives the path reports/2026-01.csv for that file. The parts are separated by / on every system.
The server sends the names in the path, so the path is a tainted string. Tainted means that the value comes from outside your program and must be checked before some uses. You can print it. A program that passes it to Core\IO::write as a local path does not compile. Check it first with Core\IO::within, which checks that a path stays inside a folder you name. A program that passes it to a method of the connection, such as remove, does not compile either. Check the path yourself, then pass it through Core\Taint::assertTrusted.
relativePath() gives the path below the folder that list or walk started in. name() gives the last part of the path.
Return value
Returns string. The path, with / between folders.
Changelog
| Version | Change |
|---|---|
0.0.6 | list and walk return one Core\FileTransfer\Entry for each file or folder, and it has the same methods as Core\IO\Entry. Its size, modifiedAt and permissions methods return null when the server does not send the value. Every string it returns is tainted: the server chose it, so the methods of the connection do not accept it until your program checks it. |
Examples
The examples below run with this configuration file.
# The `partner` block reads the folder `partner` beside this file. It needs no server.[file_transfer.partner]directory = "partner"
# The program may open the `partner` block and read its folder.[capabilities.file_transfer]connect = ["partner"]
[capabilities.fs]read = ["partner"]List every file
<?nvs// Shows the path of each file that `walk` finds on the server.
var $partner = Core\FileTransfer::open('partner');
// `walk` gives every file and folder below the start folder. The `if` skips the folders.// This prints four paths. The last one is "reports/archive/2025-12.csv".foreach ($partner->walk() as Core\FileTransfer\Entry $entry) { if ($entry->isFile()) { echo $entry->path(), "\n"; }}orders.csvreports/2026-01.csvreports/2026-02.csvreports/archive/2025-12.csvA walk in a sub folder
<?nvs// Shows that `path()` always starts at the root of the block, even when the walk starts in a sub-folder.
var $partner = Core\FileTransfer::open('partner');
// Each line shows the path, then the relative path in brackets.// The first line is "reports/2026-01.csv (2026-01.csv)".foreach ($partner->walk('reports') as Core\FileTransfer\Entry $entry) { echo $entry->path(), ' (', $entry->relativePath(), ')', "\n";}
// `metadata` returns the entry of the path you give, and `path()` returns that path.// This prints "reports/archive/2025-12.csv".echo $partner->metadata('reports/archive/2025-12.csv')->path(), "\n";reports/2026-01.csv (2026-01.csv)reports/2026-02.csv (2026-02.csv)reports/archive (archive)reports/archive/2025-12.csv (archive/2025-12.csv)reports/archive/2025-12.csvReport large files
<?nvs// Shows how a nightly check prints the path of each file on the server that is larger than a limit.
var $partner = Core\FileTransfer::open('partner');
// The limit is 20 bytes.uint $limit = 20;uint $count = 0;
foreach ($partner->walk() as Core\FileTransfer\Entry $entry) { // A folder has no size, so `size()` returns `null` for it. `??` replaces `null` with 0. uint $size = $entry->size() ?? 0; if ($size > $limit) { echo $entry->path(), ': ', $size, ' bytes', "\n"; $count = $count + 1; }}
// "orders.csv" has 19 bytes, so it is not in the list. This prints "3 files are too large".echo $count, ' files are too large', "\n";reports/2026-01.csv: 25 bytesreports/2026-02.csv: 25 bytesreports/archive/2025-12.csv: 24 bytes3 files are too large