You are here

public function ReadableStreamBackupFile::__construct in Backup and Migrate 5.0.x

Constructor.

Parameters

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

Throws

\Exception

File

src/Core/File/ReadableStreamBackupFile.php, line 27

Class

ReadableStreamBackupFile
Uses a readable PHP stream such as a local file.

Namespace

Drupal\backup_migrate\Core\File

Code

public 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();
}