function backup_migrate_to_bytes in Backup and Migrate 7.3
Helper function for byte conversion.
See also
http://php.net/manual/en/ini.core.php#ini.memory-limit
2 calls to backup_migrate_to_bytes()
- backup_migrate_perform_backup in ./
backup_migrate.module - Perform a backup with the given settings.
- BmTestBasics::testBackupMigrateToBytes in tests/
BmTestBasics.test - Confirm backup_migrate_to_bytes() works.
File
- ./
backup_migrate.module, line 1553 - Backup and restore databases for Drupal.
Code
function backup_migrate_to_bytes($from) {
$passes_sanity_check = preg_match('/^(-1|[0-9]+|[0-9]*(\\.[0-9]+)?[mg])$/i', $from);
if (!$passes_sanity_check) {
return 0;
}
if ($from === '-1') {
return -1;
}
$number = substr($from, 0, -1);
$unit = strtoupper(substr($from, -1));
switch ($unit) {
case "M":
return $number * pow(1024, 2);
break;
case "G":
return $number * pow(1024, 3);
break;
default:
return $number * pow(1024, 2);
}
}