You are here

function ReadableStreamBackupFile::__construct in Backup and Migrate 8.4

Constructor.

Parameters

string $filepath string The path to a file (which must already exist). Can be a stream URI.:

Throws

\Exception

1 call to ReadableStreamBackupFile::__construct()
WritableStreamBackupFile::__construct in lib/backup_migrate_core/src/File/WritableStreamBackupFile.php
Constructor. Create a new file object from .
1 method overrides ReadableStreamBackupFile::__construct()
WritableStreamBackupFile::__construct in lib/backup_migrate_core/src/File/WritableStreamBackupFile.php
Constructor. Create a new file object from .

File

lib/backup_migrate_core/src/File/ReadableStreamBackupFile.php, line 30

Class

ReadableStreamBackupFile
Class ReadableStreamBackupFile.

Namespace

BackupMigrate\Core\File

Code

function __construct($filepath) {

  // Check that the file exists and is readable.
  if (!file_exists($filepath)) {
    throw new \Exception("The file '{$filepath}' does not exists");
  }
  if (!is_readable($filepath)) {
    throw new \Exception("The file '{$filepath}' cannot be read");
  }
  $this->path = $filepath;

  // Get the basename and extensions.
  $this
    ->setFullName(basename($filepath));

  // Get the basic file stats since this is probably a read-only file option and these won't change.
  $this
    ->_loadFileStats();
}