Skip to content

Internals Vfs Storage Services LocalFileSystemService

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

vfs\storage\services\LocalFileSystemService

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/vfs/storage/services/LocalFileSystemService.php · Snapshot 8411f4287706.

VFS includes package resource lookup, database-backed file metadata, filesystem collaborators, transient pools and persistent PHP-array caches.

Imports and dependencies

use vfs\storage\interfaces\IFileSystemService;

LocalFileSystemService

Declaration and architectural role

class LocalFileSystemService implements IFileSystemService

Constants, enum cases, traits and properties

No own constants, enum cases, traits or property declarations. Inherited members are documented on the parent reference page.

Method index

Method Signature
move public function move(string $sourcePath, string $destinationPath): bool
copy public function copy(string $sourcePath, string $destinationPath): bool
delete public function delete(string $path): bool
rename public function rename(string $sourcePath, string $destinationPath): bool
fileSize public function fileSize(string $path): int
lastModified public function lastModified(string $path): int
exists public function exists(string $path): bool
makeDirectory public function makeDirectory(string $path, int $permissions = 0755, bool $recursive = true): bool

move

Source line 9

public function move(string $sourcePath, string $destinationPath): bool

Parameters

Parameter Type, modifiers and default Purpose
$sourcePath string $sourcePath Operation input; the exact use, validation and propagation are shown in the implementation trace.
$destinationPath string $destinationPath Operation input; the exact use, validation and propagation are shown in the implementation trace.

Return expressions (including local callbacks): is_file($sourcePath); false; true.

External effects include unlink, copy.

Implementation, validation guards and interaction order
public function move(string $sourcePath, string $destinationPath): bool
    {
        if ($sourcePath === $destinationPath) return is_file($sourcePath);
        if (!is_file($sourcePath) || file_exists($destinationPath) || is_link($destinationPath)) return false;
        // link() creates the destination exclusively, preventing concurrent overwrites.
        if (@link($sourcePath, $destinationPath)) {
            if (@unlink($sourcePath)) return true;
            @unlink($destinationPath);
            return false;
        }
        // Cross-filesystem moves use the same exclusive destination creation.
        $mtime = filemtime($sourcePath);
        if (!$this->copy($sourcePath, $destinationPath)) return false;
        if ($mtime !== false) @touch($destinationPath, $mtime);
        if (@unlink($sourcePath)) return true;
        @unlink($destinationPath);
        return false;
    }

copy

Source line 28

public function copy(string $sourcePath, string $destinationPath): bool

Parameters

Parameter Type, modifiers and default Purpose
$sourcePath string $sourcePath Operation input; the exact use, validation and propagation are shown in the implementation trace.
$destinationPath string $destinationPath Operation input; the exact use, validation and propagation are shown in the implementation trace.

Return expressions (including local callbacks): false; true.

External effects include unlink.

Implementation, validation guards and interaction order
public function copy(string $sourcePath, string $destinationPath): bool
    {
        if (!is_file($sourcePath)) return false;
        $source = @fopen($sourcePath, 'rb');
        if ($source === false) return false;
        $target = @fopen($destinationPath, 'xb');
        if ($target === false) { fclose($source); return false; }
        $expected = fstat($source)['size'];
        $written = @stream_copy_to_stream($source, $target);
        $flushed = @fflush($target);
        fclose($source);
        fclose($target);
        if ($written === false || $written !== $expected || !$flushed) {
            @unlink($destinationPath);
            return false;
        }
        clearstatcache(true, $destinationPath);
        return true;
    }

delete

Source line 48

public function delete(string $path): bool

Parameters

Parameter Type, modifiers and default Purpose
$path string $path Filesystem or route path as defined by the owning component; no universal path normalization is implied.

Return expressions (including local callbacks): @unlink($path).

External effects include unlink.

Implementation, validation guards and interaction order
public function delete(string $path): bool { return @unlink($path); }

rename

Source line 49

public function rename(string $sourcePath, string $destinationPath): bool

Parameters

Parameter Type, modifiers and default Purpose
$sourcePath string $sourcePath Operation input; the exact use, validation and propagation are shown in the implementation trace.
$destinationPath string $destinationPath Operation input; the exact use, validation and propagation are shown in the implementation trace.

Return expressions (including local callbacks): $this->move($sourcePath, $destinationPath).

Implementation, validation guards and interaction order
public function rename(string $sourcePath, string $destinationPath): bool { return $this->move($sourcePath, $destinationPath); }

fileSize

Source line 51

public function fileSize(string $path): int

Parameters

Parameter Type, modifiers and default Purpose
$path string $path Filesystem or route path as defined by the owning component; no universal path normalization is implied.

Return expressions (including local callbacks): $size.

Explicit exceptions: \RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.

Implementation, validation guards and interaction order
public function fileSize(string $path): int
    {
        clearstatcache(true, $path);
        $size = @filesize($path);
        if ($size === false) throw new \RuntimeException("Unable to determine file size for: {$path}");
        return $size;
    }

lastModified

Source line 59

public function lastModified(string $path): int

Parameters

Parameter Type, modifiers and default Purpose
$path string $path Filesystem or route path as defined by the owning component; no universal path normalization is implied.

Return expressions (including local callbacks): $mtime.

Explicit exceptions: \RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.

Implementation, validation guards and interaction order
public function lastModified(string $path): int
    {
        clearstatcache(true, $path);
        $mtime = @filemtime($path);
        if ($mtime === false) throw new \RuntimeException("Unable to determine last modified time for: {$path}");
        return $mtime;
    }

exists

Source line 67

public function exists(string $path): bool

Parameters

Parameter Type, modifiers and default Purpose
$path string $path Filesystem or route path as defined by the owning component; no universal path normalization is implied.

Return expressions (including local callbacks): file_exists($path) || is_link($path).

Implementation, validation guards and interaction order
public function exists(string $path): bool { clearstatcache(true, $path); return file_exists($path) || is_link($path); }

makeDirectory

Source line 69

public function makeDirectory(string $path, int $permissions = 0755, bool $recursive = true): bool

Parameters

Parameter Type, modifiers and default Purpose
$path string $path Filesystem or route path as defined by the owning component; no universal path normalization is implied.
$permissions int $permissions = 0755 Operation input; the exact use, validation and propagation are shown in the implementation trace.
$recursive bool $recursive = true Operation input; the exact use, validation and propagation are shown in the implementation trace.

Return expressions (including local callbacks): true; is_dir($path).

External effects include mkdir.

Implementation, validation guards and interaction order
public function makeDirectory(string $path, int $permissions = 0755, bool $recursive = true): bool
    {
        if (is_dir($path)) return true;
        @mkdir($path, $permissions, $recursive);
        return is_dir($path);
    }

Related types

Clone this wiki locally